Permalink
Browse files

Using IRenderer<T> interface instead of implementation

  • Loading branch information...
1 parent 067e4dc commit 4f0ac1d3af1aa8a547568a628c0610498c377876 @gilleain gilleain committed with egonw Sep 6, 2010
@@ -105,9 +105,9 @@
public class ChemModelRenderer extends AbstractRenderer<IChemModel>
implements IRenderer<IChemModel> {
- private MoleculeSetRenderer moleculeSetRenderer;
+ private IRenderer<IMoleculeSet> moleculeSetRenderer;
- private ReactionSetRenderer reactionSetRenderer;
+ private IRenderer<IReactionSet> reactionSetRenderer;
/**
* A renderer that generates diagrams using the specified
@@ -254,7 +254,7 @@ public Rectangle paint(IChemModel chemModel, IDrawVisitor drawVisitor) {
* @param resetCenter
* if true, set the modelCenter to the center of the ChemModel's bounds.
*/
- public void paintChemModel(IChemModel chemModel,
+ public void paint(IChemModel chemModel,
IDrawVisitor drawVisitor, Rectangle2D bounds, boolean resetCenter) {
// check for an empty model
IMoleculeSet moleculeSet = chemModel.getMoleculeSet();
@@ -264,7 +264,7 @@ public void paintChemModel(IChemModel chemModel,
// with BOTH a ReactionSet AND a MoleculeSet...
if (moleculeSet == null || reactionSet != null) {
if (reactionSet != null) {
- reactionSetRenderer.paintReactionSet(reactionSet, drawVisitor, bounds, resetCenter);
+ reactionSetRenderer.paint(reactionSet, drawVisitor, bounds, resetCenter);
}
return;
}
@@ -341,7 +341,7 @@ public double calculateScaleForBondLength(double modelBondLength) {
}
}
- public List<IGenerator<IReaction>> getReactionGenerators(){
- return reactionSetRenderer.getReactionGenerators();
+ public List<IGenerator<IChemModel>> getGenerators(){
+ return null;
}
}
@@ -104,7 +104,7 @@
public class MoleculeSetRenderer extends AbstractRenderer<IMoleculeSet>
implements IRenderer<IMoleculeSet> {
- private AtomContainerRenderer atomContainerRenderer;
+ private IRenderer<IAtomContainer> atomContainerRenderer;
/**
* A renderer that generates diagrams using the specified
@@ -233,7 +233,7 @@ public Rectangle paint(IMoleculeSet moleculeSet, IDrawVisitor drawVisitor) {
* @param resetCenter
* if true, set the draw center to be the center of bounds
*/
- public void paintMoleculeSet(IMoleculeSet molecules,
+ public void paint(IMoleculeSet molecules,
IDrawVisitor drawVisitor, Rectangle2D bounds, boolean resetCenter) {
// total up the bounding boxes
@@ -279,5 +279,10 @@ public double calculateScaleForBondLength(double modelBondLength) {
.getValue() / modelBondLength;
}
}
+
+ public List<IGenerator<IMoleculeSet>> getGenerators() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
@@ -31,8 +31,8 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemModel;
import org.openscience.cdk.interfaces.IMolecule;
+import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
-import org.openscience.cdk.interfaces.IReactionSet;
import org.openscience.cdk.renderer.elements.ElementGroup;
import org.openscience.cdk.renderer.elements.IRenderingElement;
import org.openscience.cdk.renderer.font.IFontManager;
@@ -105,7 +105,7 @@
public class ReactionRenderer extends AbstractRenderer<IReaction>
implements IRenderer<IReaction> {
- private MoleculeSetRenderer moleculeSetRenderer;
+ private IRenderer<IMoleculeSet> moleculeSetRenderer;
/**
* Generators specific to reactions
@@ -179,41 +179,6 @@ public Rectangle paint(IReaction reaction, IDrawVisitor drawVisitor) {
}
/**
- * Paint a set of reactions.
- *
- * @param reaction the reaction to paint
- * @param drawVisitor the visitor that does the drawing
- * @param bounds the bounds on the screen
- * @param resetCenter
- * if true, set the draw center to be the center of bounds
- */
- public void paintReactionSet(IReactionSet reactionSet,
- IDrawVisitor drawVisitor, Rectangle2D bounds, boolean resetCenter) {
-
- // total up the bounding boxes
- Rectangle2D totalBounds = null;
- for (IReaction reaction : reactionSet.reactions()) {
- Rectangle2D modelBounds = BoundsCalculator.calculateBounds(reaction);
- if (totalBounds == null) {
- totalBounds = modelBounds;
- } else {
- totalBounds = totalBounds.createUnion(modelBounds);
- }
- }
-
- this.setupTransformToFit(bounds, totalBounds,
- AverageBondLengthCalculator.calculateAverageBondLength(reactionSet), resetCenter);
-
- ElementGroup diagram = new ElementGroup();
- for (IReaction reaction : reactionSet.reactions()) {
- diagram.add(this.generateDiagram(reaction));
- }
-
- // paint them all
- this.paint(drawVisitor, diagram);
- }
-
- /**
* Paint a reaction.
*
* @param reaction the reaction to paint
@@ -222,7 +187,7 @@ public void paintReactionSet(IReactionSet reactionSet,
* @param resetCenter
* if true, set the draw center to be the center of bounds
*/
- public void paintReaction(IReaction reaction, IDrawVisitor drawVisitor,
+ public void paint(IReaction reaction, IDrawVisitor drawVisitor,
Rectangle2D bounds, boolean resetCenter) {
// calculate the bounds
@@ -273,7 +238,7 @@ public IRenderingElement generateDiagram(IReaction reaction) {
return diagram;
}
- public List<IGenerator<IReaction>> getReactionGenerators(){
+ public List<IGenerator<IReaction>> getGenerators(){
return new ArrayList<IGenerator<IReaction>>(reactionGenerators);
}
@@ -104,7 +104,7 @@
public class ReactionSetRenderer extends AbstractRenderer<IReactionSet>
implements IRenderer<IReactionSet> {
- private ReactionRenderer reactionRenderer;
+ private IRenderer<IReaction> reactionRenderer;
/**
@@ -193,7 +193,7 @@ public Rectangle paint(IReactionSet reactionSet, IDrawVisitor drawVisitor) {
* @param resetCenter
* if true, set the draw center to be the center of bounds
*/
- public void paintReactionSet(IReactionSet reactionSet,
+ public void paint(IReactionSet reactionSet,
IDrawVisitor drawVisitor, Rectangle2D bounds, boolean resetCenter) {
// total up the bounding boxes
@@ -241,7 +241,8 @@ public double calculateScaleForBondLength(double modelBondLength) {
}
}
- public List<IGenerator<IReaction>> getReactionGenerators(){
- return reactionRenderer.getReactionGenerators();
+ public List<IGenerator<IReactionSet>> getGenerators(){
+// return reactionRenderer.getReactionGenerators();
+ return null;
}
}

0 comments on commit 4f0ac1d

Please sign in to comment.