Skip to content

Commit

Permalink
Added an option to define a maximum drawable ring size for
Browse files Browse the repository at this point in the history
the aromatic ring representation. Added dynamic scaling
based on the ring size for inner bond elements.

Change-Id: I33cacb2a898fdcfa35fd634f175a36dfbb1dc909
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
Stephan Beisken authored and egonw committed Feb 20, 2013
1 parent 1e67f59 commit bc9d9fc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Expand Up @@ -161,6 +161,16 @@ public Double getDefault() {
*/
private double overrideBondWidth = -1;

/**
* The ideal ring size for the given center proportion.
*/
private int IDEAL_RINGSIZE = 6;

/**
* The minimum ring size factor to ensure a minimum gap.
*/
private double MIN_RINGSIZE_FACTOR = 2.5;

/**
* An empty constructor necessary for reflection.
*/
Expand Down Expand Up @@ -411,8 +421,9 @@ public LineElement generateInnerElement(
Point2d b = bond.getAtom(1).getPoint2d();

// the proportion to move in towards the ring center
double ringDistance =
model.getParameter(TowardsRingCenterProportion.class).getValue();
double distanceFactor = model.getParameter(TowardsRingCenterProportion.class).getValue();
double ringDistance = distanceFactor * IDEAL_RINGSIZE / ring.getAtomCount();
if (ringDistance < distanceFactor / MIN_RINGSIZE_FACTOR) ringDistance = distanceFactor / MIN_RINGSIZE_FACTOR;

Point2d w = new Point2d();
w.interpolate(a, center, ringDistance);
Expand Down
Expand Up @@ -79,6 +79,23 @@ public Boolean getDefault() {
/** If true, the aromatic ring is indicated by light gray inner bonds */
private IGeneratorParameter<Boolean> cdkStyleAromaticity = new CDKStyleAromaticity();

/**
* The maximum ring size for which an aromatic ring should be drawn.
*/
public static class MaxDrawableAromaticRing extends AbstractGeneratorParameter<Integer> {

/**
* The maximum default ring size for which an aromatic ring should be drawn.
*
* @return the maximum ring size
*/
public Integer getDefault() {

return 8;
}
}
private IGeneratorParameter<Integer> maxDrawableAromaticRing = new MaxDrawableAromaticRing();

/**
* The proportion of a ring bounds to use to draw the ring.
*/
Expand Down Expand Up @@ -108,7 +125,8 @@ public RingGenerator() {
/** {@inheritDoc} */
public IRenderingElement generateRingElements(
IBond bond, IRing ring, RendererModel model) {
if (ringIsAromatic(ring) && showAromaticity.getValue()) {
if (ringIsAromatic(ring) && showAromaticity.getValue()
&& ring.getAtomCount() < maxDrawableAromaticRing.getValue()) {
ElementGroup pair = new ElementGroup();
if (cdkStyleAromaticity.getValue()) {
pair.add(generateBondElement(bond, IBond.Order.SINGLE, model));
Expand Down Expand Up @@ -175,6 +193,7 @@ public List<IGeneratorParameter<?>> getParameters() {
pars.addAll(superPars);
pars.add(cdkStyleAromaticity);
pars.add(showAromaticity);
pars.add(maxDrawableAromaticRing);
pars.add(ringProportion);
return pars;
}
Expand Down

0 comments on commit bc9d9fc

Please sign in to comment.