Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactored foreground color into a IGeneratorParameter
  • Loading branch information
egonw committed May 19, 2012
1 parent 5b65078 commit 242c165
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 25 deletions.
Expand Up @@ -20,6 +20,7 @@
*/
package org.openscience.cdk.renderer.generators;

import java.awt.Color;
import java.awt.geom.Rectangle2D;

import org.openscience.cdk.interfaces.IAtomContainer;
Expand Down Expand Up @@ -60,12 +61,21 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
if (totalBounds == null) return null;

ElementGroup diagram = new ElementGroup();
diagram.add(new RectangleElement(totalBounds.getMinX()-DISTANCE,
totalBounds.getMinY()-DISTANCE,
totalBounds.getMaxX()+DISTANCE,
totalBounds.getMaxY()+DISTANCE,
model.getForeColor()));
diagram.add(new TextElement((totalBounds.getMinX()+totalBounds.getMaxX())/2, totalBounds.getMinY()-DISTANCE, "Products", model.getForeColor()));
Color foregroundColor = model.getRenderingParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
diagram.add(new RectangleElement(
totalBounds.getMinX()-DISTANCE,
totalBounds.getMinY()-DISTANCE,
totalBounds.getMaxX()+DISTANCE,
totalBounds.getMaxY()+DISTANCE,
foregroundColor
));
diagram.add(new TextElement(
(totalBounds.getMinX()+totalBounds.getMaxX())/2,
totalBounds.getMinY()-DISTANCE,
"Products",
foregroundColor
));
return diagram;
}

Expand Down
Expand Up @@ -52,11 +52,14 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
double minY = totalBounds.getMinY();
double maxX = totalBounds.getMaxX();
double maxY = totalBounds.getMaxY();
Color c = model.getForeColor();
Color foregroundColor = model.getRenderingParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
diagram.add(new RectangleElement(
minX - d, minY - d, maxX + d, maxY + d, c));
minX - d, minY - d, maxX + d, maxY + d, foregroundColor
));
diagram.add(new TextElement(
(minX+maxX)/2, minY-d, "Reactants", c));
(minX+maxX)/2, minY-d, "Reactants", foregroundColor
));
return diagram;
}

Expand Down
Expand Up @@ -18,6 +18,7 @@
*/
package org.openscience.cdk.renderer.generators;

import java.awt.Color;
import java.awt.geom.Rectangle2D;

import org.openscience.cdk.interfaces.IReaction;
Expand Down Expand Up @@ -45,10 +46,15 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
return null;

double d = model.getBondLength() / model.getScale();
return new ArrowElement(totalBoundsReactants.getMaxX() + d,
totalBoundsReactants.getCenterY(),
totalBoundsProducts.getMinX() - d,
totalBoundsReactants.getCenterY(),
1 / model.getScale(),true,model.getForeColor());
Color foregroundColor = model.getRenderingParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
return new ArrowElement(
totalBoundsReactants.getMaxX() + d,
totalBoundsReactants.getCenterY(),
totalBoundsProducts.getMinX() - d,
totalBoundsReactants.getCenterY(),
1 / model.getScale(), true,
foregroundColor
);
}
}
Expand Up @@ -18,6 +18,7 @@
*/
package org.openscience.cdk.renderer.generators;

import java.awt.Color;
import java.awt.geom.Rectangle2D;

import org.openscience.cdk.interfaces.IReaction;
Expand Down Expand Up @@ -45,17 +46,22 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
if (totalBounds == null) return null;

ElementGroup diagram = new ElementGroup();
diagram.add(new RectangleElement(totalBounds.getMinX()-d,
totalBounds.getMinY()-d,
totalBounds.getMaxX()+d,
totalBounds.getMaxY()+d,
model.getForeColor()));
Color foregroundColor = model.getRenderingParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
diagram.add(new RectangleElement(
totalBounds.getMinX()-d,
totalBounds.getMinY()-d,
totalBounds.getMaxX()+d,
totalBounds.getMaxY()+d,
foregroundColor
));
if (reaction.getID() != null) {
diagram.add(new TextElement((totalBounds.getMinX()
+totalBounds.getMaxX())/2,
totalBounds.getMinY()-d,
reaction.getID(),
model.getForeColor()));
diagram.add(new TextElement(
(totalBounds.getMinX()+totalBounds.getMaxX())/2,
totalBounds.getMinY()-d,
reaction.getID(),
foregroundColor
));
}
return diagram;
}
Expand Down
Expand Up @@ -47,7 +47,8 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
Rectangle2D bounds1 =
Renderer.calculateBounds(reactants.getAtomContainer(0));
double axis = totalBoundsReactants.getCenterY();
Color color = model.getForeColor();
Color color = model.getRenderingParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
for (int i = 1; i < reaction.getReactantCount(); i++) {
Rectangle2D bounds2 =
Renderer.calculateBounds(reactants.getAtomContainer(i));
Expand Down

0 comments on commit 242c165

Please sign in to comment.