From: <sh...@us...> - 2009-11-27 16:15:57
|
Revision: 15112 http://cdk.svn.sourceforge.net/cdk/?rev=15112&view=rev Author: shk3 Date: 2009-11-27 16:15:49 +0000 (Fri, 27 Nov 2009) Log Message: ----------- methods in controllerhub now get the information if pseudo atom or normal atom should be drawn passed in and do not take it from controllerModel, which is more in line with design Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddAtomModule.java jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddBondDragModule.java jchempaint/trunk/src/main/org/openscience/jchempaint/controller/ControllerHub.java jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IAtomBondEdits.java jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IChemModelRelay.java jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/EnterElementSwingModule.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddAtomModule.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddAtomModule.java 2009-11-27 15:27:59 UTC (rev 15111) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddAtomModule.java 2009-11-27 16:15:49 UTC (rev 15112) @@ -163,12 +163,7 @@ double dH = model.getHighlightDistance() / model.getScale(); IAtom newAtom; if(newSource){ - if(chemModelRelay.getController2DModel().getDrawPseudoAtom()){ - newAtom = chemModelRelay.addAtom("C", 12, start ); - newAtom = chemModelRelay.convertToPseudoAtom(newAtom, chemModelRelay.getController2DModel().getDrawElement()); - }else{ - newAtom = chemModelRelay.addAtom( chemModelRelay.getController2DModel().getDrawElement(), chemModelRelay.getController2DModel().getDrawIsotopeNumber(), start ); - } + newAtom = chemModelRelay.addAtom( chemModelRelay.getController2DModel().getDrawElement(), chemModelRelay.getController2DModel().getDrawIsotopeNumber(), start, chemModelRelay.getController2DModel().getDrawPseudoAtom() ); }else{ newAtom = source; } @@ -176,13 +171,7 @@ if(dest==null) dest=worldCoord; - IAtom atom; - if(chemModelRelay.getController2DModel().getDrawPseudoAtom()){ - atom = chemModelRelay.addAtom("C", 12, dest ); - atom = chemModelRelay.convertToPseudoAtom(atom, chemModelRelay.getController2DModel().getDrawElement()); - }else{ - atom = chemModelRelay.addAtom( chemModelRelay.getController2DModel().getDrawElement(), chemModelRelay.getController2DModel().getDrawIsotopeNumber(), dest ); - } + IAtom atom = chemModelRelay.addAtom( chemModelRelay.getController2DModel().getDrawElement(), chemModelRelay.getController2DModel().getDrawIsotopeNumber(), dest, chemModelRelay.getController2DModel().getDrawPseudoAtom() ); if(chemModelRelay.getController2DModel().getDrawIsotopeNumber()!=0) atom.setMassNumber(chemModelRelay.getController2DModel().getDrawIsotopeNumber()); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddBondDragModule.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddBondDragModule.java 2009-11-27 15:27:59 UTC (rev 15111) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/controller/AddBondDragModule.java 2009-11-27 16:15:49 UTC (rev 15112) @@ -196,7 +196,7 @@ IAtom newAtom; if(newSource) { - newAtom = chemModelRelay.addAtomWithoutUndo( chemModelRelay.getController2DModel().getDrawElement(), start ); + newAtom = chemModelRelay.addAtomWithoutUndo( chemModelRelay.getController2DModel().getDrawElement(), start, chemModelRelay.getController2DModel().getDrawPseudoAtom() ); containerForUndoRedo.addAtom(newAtom); } else @@ -212,7 +212,7 @@ } else { if(start.distance( worldCoord )<getHighlightDistance()) { if(!newSource) { - IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), newAtom, stereoForNewBond ); + IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), newAtom, stereoForNewBond, chemModelRelay.getController2DModel().getDrawPseudoAtom() ); containerForUndoRedo.addAtom(undoRedoAtom); IAtomContainer atomCon = ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), undoRedoAtom); @@ -220,12 +220,13 @@ } else if(makeInitialBond){ IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo( chemModelRelay.getController2DModel().getDrawElement(), - new Point2d(newAtom.getPoint2d().x+1.5,newAtom.getPoint2d().y)); + new Point2d(newAtom.getPoint2d().x+1.5,newAtom.getPoint2d().y), + chemModelRelay.getController2DModel().getDrawPseudoAtom()); containerForUndoRedo.addAtom(undoRedoAtom); containerForUndoRedo.addBond(chemModelRelay.addBond(newAtom, undoRedoAtom, stereoForNewBond)); } }else { - IAtom atom = chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), dest ); + IAtom atom = chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), dest, chemModelRelay.getController2DModel().getDrawPseudoAtom() ); containerForUndoRedo.addAtom(atom); IBond newBond = chemModelRelay.addBond( newAtom, atom, stereoForNewBond ); containerForUndoRedo.addBond(newBond); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/controller/ControllerHub.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/controller/ControllerHub.java 2009-11-27 15:27:59 UTC (rev 15111) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/controller/ControllerHub.java 2009-11-27 16:15:49 UTC (rev 15112) @@ -429,17 +429,17 @@ /* (non-Javadoc) * @see org.openscience.cdk.controller.IChemModelRelay#addAtom(java.lang.String, javax.vecmath.Point2d) */ - public IAtom addAtom(String atomType, Point2d worldCoord) { - return addAtom(atomType, 0, worldCoord); + public IAtom addAtom(String atomType, Point2d worldCoord, boolean makePseudoAtom) { + return addAtom(atomType, 0, worldCoord, makePseudoAtom); } //OK /* (non-Javadoc) * @see org.openscience.cdk.controller.IChemModelRelay#addAtom(java.lang.String, int, javax.vecmath.Point2d) */ - public IAtom addAtom(String atomType, int isotopeNumber, Point2d worldCoord) { + public IAtom addAtom(String atomType, int isotopeNumber, Point2d worldCoord, boolean makePseudoAtom) { IAtomContainer undoRedoContainer = chemModel.getBuilder().newAtomContainer(); - undoRedoContainer.addAtom(addAtomWithoutUndo(atomType, isotopeNumber, worldCoord)); + undoRedoContainer.addAtom(addAtomWithoutUndo(atomType, isotopeNumber, worldCoord, makePseudoAtom)); if (getUndoRedoFactory() != null && getUndoRedoHandler() != null) { IUndoRedoable undoredo = getUndoRedoFactory().getAddAtomsAndBondsEdit(chemModel, undoRedoContainer, null, "Add Atom", this); getUndoRedoHandler().postEdit(undoredo); @@ -451,8 +451,8 @@ /* (non-Javadoc) * @see org.openscience.cdk.controller.IChemModelRelay#addAtomWithoutUndo(java.lang.String, javax.vecmath.Point2d) */ - public IAtom addAtomWithoutUndo(String atomType, Point2d worldCoord) { - return addAtomWithoutUndo(atomType, 0, worldCoord); + public IAtom addAtomWithoutUndo(String atomType, Point2d worldCoord, boolean makePseudoAtom) { + return addAtomWithoutUndo(atomType, 0, worldCoord, makePseudoAtom); } //OK @@ -460,9 +460,9 @@ * @see org.openscience.cdk.controller.IChemModelRelay#addAtomWithoutUndo(java.lang.String, int, javax.vecmath.Point2d) */ public IAtom addAtomWithoutUndo(String atomType, - int isotopeNumber, Point2d worldCoord) { + int isotopeNumber, Point2d worldCoord, boolean makePseudoAtom) { IAtom newAtom; - if (controllerModel.getDrawPseudoAtom()) { + if (makePseudoAtom) { newAtom = chemModel.getBuilder().newPseudoAtom(atomType, worldCoord); } else { newAtom = chemModel.getBuilder().newAtom(atomType, worldCoord); @@ -494,9 +494,9 @@ } //OK - public IAtom addAtom(String atomType, IAtom atom) { + public IAtom addAtom(String atomType, IAtom atom, boolean makePseudoAtom) { IAtomContainer undoRedoContainer = atom.getBuilder().newAtomContainer(); - undoRedoContainer.addAtom(addAtomWithoutUndo(atomType, atom)); + undoRedoContainer.addAtom(addAtomWithoutUndo(atomType, atom, makePseudoAtom)); IAtomContainer atomContainer = ChemModelManipulator.getRelevantAtomContainer( getIChemModel(), undoRedoContainer.getAtom(0)); @@ -513,17 +513,17 @@ /* (non-Javadoc) * @see org.openscience.cdk.controller.IChemModelRelay#addAtomWithoutUndo(java.lang.String, org.openscience.cdk.interfaces.IAtom) */ - public IAtom addAtomWithoutUndo(String atomType, IAtom atom) { - return addAtomWithoutUndo(atomType, atom, IBond.Stereo.NONE); + public IAtom addAtomWithoutUndo(String atomType, IAtom atom, boolean makePseudoAtom) { + return addAtomWithoutUndo(atomType, atom, IBond.Stereo.NONE, makePseudoAtom); } //OK /* (non-Javadoc) * @see org.openscience.cdk.controller.IChemModelRelay#addAtomWithoutUndo(java.lang.String, org.openscience.cdk.interfaces.IAtom, int) */ - public IAtom addAtomWithoutUndo(String atomType, IAtom atom, IBond.Stereo stereo) { + public IAtom addAtomWithoutUndo(String atomType, IAtom atom, IBond.Stereo stereo, boolean makePseudoAtom) { IAtom newAtom; - if (controllerModel.getDrawPseudoAtom()) { + if (makePseudoAtom) { newAtom = chemModel.getBuilder().newPseudoAtom(atomType); } else { newAtom = chemModel.getBuilder().newAtom(atomType); @@ -599,17 +599,17 @@ } //OK - public void addNewBond(Point2d worldCoordinate) { + public void addNewBond(Point2d worldCoordinate, boolean makePseudoAtom) { IAtomContainer undoRedoContainer = getIChemModel().getBuilder().newAtomContainer(); // add the first atom in the new bond String atomType = getController2DModel().getDrawElement(); - IAtom atom = addAtomWithoutUndo(atomType, worldCoordinate); + IAtom atom = addAtomWithoutUndo(atomType, worldCoordinate, makePseudoAtom); undoRedoContainer.addAtom(atom); // add the second atom to this - IAtom newAtom = addAtomWithoutUndo(atomType, atom); + IAtom newAtom = addAtomWithoutUndo(atomType, atom, makePseudoAtom); undoRedoContainer.addAtom(newAtom); IAtomContainer atomContainer = @@ -667,7 +667,7 @@ //OK public IBond makeNewStereoBond(IAtom atom, Direction desiredDirection) { String atomType = getController2DModel().getDrawElement(); - IAtom newAtom = addAtomWithoutUndo(atomType, atom); + IAtom newAtom = addAtomWithoutUndo(atomType, atom, controllerModel.getDrawPseudoAtom()); IAtomContainer undoRedoContainer=getIChemModel().getBuilder().newAtomContainer(); // XXX these calls would not be necessary if addAtom returned a bond @@ -1986,7 +1986,7 @@ for(IAtom atom : containers.get(i).atoms()){ int hcount=atom.getHydrogenCount(); for(int k=0;k<hcount;k++){ - IAtom newAtom = this.addAtomWithoutUndo("H", atom); + IAtom newAtom = this.addAtomWithoutUndo("H", atom, false); IAtomContainer atomContainer = ChemModelManipulator.getRelevantAtomContainer( getIChemModel(), newAtom); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IAtomBondEdits.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IAtomBondEdits.java 2009-11-27 15:27:59 UTC (rev 15111) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IAtomBondEdits.java 2009-11-27 16:15:49 UTC (rev 15112) @@ -43,10 +43,10 @@ /* Editing actions for atoms */ public IAtomContainer removeAtom(IAtom atom); public IAtomContainer removeAtomWithoutUndo(IAtom atom); - public IAtom addAtom(String element, Point2d worldcoord); - public IAtom addAtomWithoutUndo(String element, Point2d worldcoord); - public IAtom addAtom(String element, IAtom atom); - public IAtom addAtomWithoutUndo(String element, IAtom atom); + public IAtom addAtom(String element, Point2d worldcoord, boolean makePseudoAtom); + public IAtom addAtomWithoutUndo(String element, Point2d worldcoord, boolean makePseudoAtom); + public IAtom addAtom(String element, IAtom atom, boolean makePseudoAtom); + public IAtom addAtomWithoutUndo(String element, IAtom atom, boolean makePseudoAtom); public void moveToWithoutUndo(IAtom atom, Point2d point); public void moveTo(IAtom atom, Point2d point); public void moveBy(Collection<IAtom> atoms, Vector2d move, Vector2d totalmove); @@ -68,7 +68,7 @@ public void moveToWithoutUndo(IBond bond, Point2d point); public void moveTo(IBond bond, Point2d point); public void setOrder(IBond bond, IBond.Order order); - public void addNewBond(Point2d worldCoordinate); + public void addNewBond(Point2d worldCoordinate, boolean makePseudoAtom); public void cycleBondValence(IBond bond); public void makeBondStereo(IBond bond, Direction desiredDirection); public IBond makeNewStereoBond(IAtom atom, Direction desiredDirection); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IChemModelRelay.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IChemModelRelay.java 2009-11-27 15:27:59 UTC (rev 15111) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/controller/IChemModelRelay.java 2009-11-27 16:15:49 UTC (rev 15112) @@ -189,9 +189,9 @@ public IUndoRedoFactory getUndoRedoFactory(); public UndoRedoHandler getUndoRedoHandler(); public IBond addBond(IAtom fromAtom, IAtom toAtom, IBond.Stereo stereo); - public IAtom addAtomWithoutUndo(String drawElement, IAtom newAtom, Stereo stereoForNewBond); + public IAtom addAtomWithoutUndo(String drawElement, IAtom newAtom, Stereo stereoForNewBond, boolean makePseudoAtom); public void setValence(IAtom atom, Integer newValence); - public IAtom addAtom(String drawElement, int drawIsotopeNumber, Point2d start); + public IAtom addAtom(String drawElement, int drawIsotopeNumber, Point2d start, boolean makePseudoAtom); public void removeBondAndLoneAtoms(IBond bond); public IAtom convertToPseudoAtom(IAtom newAtom, String drawElement); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/EnterElementSwingModule.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/EnterElementSwingModule.java 2009-11-27 15:27:59 UTC (rev 15111) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/EnterElementSwingModule.java 2009-11-27 16:15:49 UTC (rev 15112) @@ -190,7 +190,7 @@ if(iso!=null){ if(closestAtom==null){ IAtomContainer addatom=chemModelRelay.getIChemModel().getBuilder().newAtomContainer(); - addatom.addAtom(chemModelRelay.addAtomWithoutUndo(x, worldCoord)); + addatom.addAtom(chemModelRelay.addAtomWithoutUndo(x, worldCoord, false)); if(chemModelRelay.getUndoRedoFactory()!=null && chemModelRelay.getUndoRedoHandler()!=null){ IUndoRedoable undoredo = chemModelRelay.getUndoRedoFactory().getAddAtomsAndBondsEdit(chemModelRelay.getIChemModel(), addatom, null, GT._("Add Atom"), chemModelRelay); chemModelRelay.getUndoRedoHandler().postEdit(undoredo); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |