From: <eg...@us...> - 2008-12-03 16:37:07
|
Revision: 13445 http://cdk.svn.sourceforge.net/cdk/?rev=13445&view=rev Author: egonw Date: 2008-12-03 16:37:03 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Added experimental concept of phantoms, for temporary atoms and bonds which might be drawn Modified Paths: -------------- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/ControllerHub.java cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/IChemModelRelay.java Modified: cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/ControllerHub.java =================================================================== --- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/ControllerHub.java 2008-12-03 16:25:49 UTC (rev 13444) +++ cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/ControllerHub.java 2008-12-03 16:37:03 UTC (rev 13445) @@ -81,6 +81,8 @@ private IControllerModule activeDrawModule; private final static RingPlacer ringPlacer = new RingPlacer(); + private IAtomContainer phantoms; + public ControllerHub(IControllerModel controllerModel, IJava2DRenderer renderer, IChemModel chemModel, @@ -89,6 +91,7 @@ this.renderer = renderer; this.chemModel = chemModel; this.eventRelay = eventRelay; + this.phantoms = chemModel.getBuilder().newAtomContainer(); generalModules = new ArrayList<IControllerModule>(); @@ -702,4 +705,20 @@ .getRelevantAtomContainer(chemModel, bond); sourceContainer.removeBond(bond); } + + public void addPhantomAtom( IAtom atom ) { + this.phantoms.addAtom(atom); + } + + public void addPhantomBond( IBond bond ) { + this.phantoms.addBond(bond); + } + + public void clearPhantoms() { + this.phantoms.removeAllElements(); + } + + public IAtomContainer getPhantoms() { + return this.phantoms; + } } Modified: cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/IChemModelRelay.java =================================================================== --- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/IChemModelRelay.java 2008-12-03 16:25:49 UTC (rev 13444) +++ cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/IChemModelRelay.java 2008-12-03 16:37:03 UTC (rev 13445) @@ -27,6 +27,7 @@ import javax.vecmath.Point2d; import org.openscience.cdk.interfaces.IAtom; +import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.renderer.IJava2DRenderer; @@ -43,6 +44,31 @@ public abstract IAtom getClosestAtom(Point2d worldCoord); public abstract IBond getClosestBond(Point2d worldCoord); public abstract void updateView(); + + /** + * Adds an temporary atom which might be cleared later, when the final + * atom is added. Controllers can use this to draw temporary atoms, for + * example while drawing new bonds. + * + * @param atom atom to add as phantom + */ + public void addPhantomAtom(IAtom atom); + /** + * Adds an temporary bond which might be cleared later, when the final + * bond is added. Controllers can use this to draw temporary bonds, for + * example while drawing new bonds. + * + * @param bond bond to add as phantom + */ + public void addPhantomBond(IBond bond); + /** + * Returns an IAtomContainer containing all phantom atoms and bonds. + */ + public IAtomContainer getPhantoms(); + /** + * Deletes all temporary atoms. + */ + public void clearPhantoms(); /* Editing actions for the complete model */ public abstract void updateImplicitHydrogenCounts(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |