Package org.openscience.jchempaint.controller.undoredo

Examples of org.openscience.jchempaint.controller.undoredo.UndoRedoHandler


            //this.renderer.getRenderer2DModel().setShowAromaticity(false);
        }
        this.setFitToScreen(fitToScreen);
        this.controllerModel = new ControllerModel();

        UndoRedoHandler undoredohandler = new UndoRedoHandler();
        undoredohandler.addIUndoListener(this);
        // connect the Renderer to the Hub
        this.hub = new ControllerHub(controllerModel, renderer, chemModel,
                this, undoredohandler, new SwingUndoRedoFactory(), isViewer, applet);
        pbg.setControllerHub(hub);
        pag.setControllerHub(hub);
View Full Code Here


            moleculeSet.getAtomContainer(0).add(molecule);
        else
            moleculeSet.addAtomContainer(molecule);

        IUndoRedoFactory undoRedoFactory= chemPaintPanel.get2DHub().getUndoRedoFactory();
        UndoRedoHandler undoRedoHandler= chemPaintPanel.get2DHub().getUndoRedoHandler();
       
        if (undoRedoFactory!=null) {
            IUndoRedoable undoredo = undoRedoFactory.getAddAtomsAndBondsEdit(chemPaintPanel.get2DHub().getIChemModel(),
            molecule, null, "Paste", chemPaintPanel.get2DHub());
            undoRedoHandler.postEdit(undoredo);
        }
       
        chemPaintPanel.getChemModel().setMoleculeSet(moleculeSet);
  chemPaintPanel.updateUndoRedoControls();
        chemPaintPanel.get2DHub().updateView();
View Full Code Here

      }
    }

    // Undo section to undo/redo the merge
    IUndoRedoFactory factory = getUndoRedoFactory();
    UndoRedoHandler handler = getUndoRedoHandler();
    if (movedDistance != null && factory != null && handler != null) {
      // we look if anything has been moved which was not merged
      IAtomContainer undoRedoContainer = getIChemModel().getBuilder()
          .newInstance(IAtomContainer.class);

      if (renderer.getRenderer2DModel().getSelection()
          .getConnectedAtomContainer() != null) {
        undoRedoContainer.add(renderer.getRenderer2DModel()
            .getSelection().getConnectedAtomContainer());
      }

      Iterator<IAtom> it2 = mergeMap.keySet().iterator();
      while (it2.hasNext()) {
        IAtom remove = it2.next();
        undoRedoContainer.removeAtom(remove);
      }
      IUndoRedoable moveundoredo = getUndoRedoFactory().getMoveAtomEdit(
          undoRedoContainer, movedDistance, "Move atom");
      IUndoRedoable undoredo = factory.getMergeMoleculesEdit(mergedAtoms,
          containers, droppedContainers, removedBondss,
          bondsWithReplacedAtoms, movedDistance, mergedPartnerAtoms,
          moveundoredo, oldRGroupHash, newRGroupHash,
          "Move and merge atoms", this);
      handler.postEdit(undoredo);

    }

    model.getMerge().clear();
    structureChanged();
View Full Code Here

                coords[0] = atom.getPoint2d();
            }

            /* Post the rotation */
            IUndoRedoFactory factory = chemModelRelay.getUndoRedoFactory();
            UndoRedoHandler handler = chemModelRelay.getUndoRedoHandler();
            if (factory != null && handler != null) {
                IUndoRedoable undoredo = factory.getChangeCoordsEdit(
                        atomCoordsMap, "Rotation");
                handler.postEdit(undoredo);
            }
        }
    }
View Full Code Here

    public void mouseClickedUp( Point2d worldCoord ) {
        chemModelRelay.clearPhantoms();
        if(isBond) return;

        IUndoRedoFactory factory = chemModelRelay.getUndoRedoFactory();
        UndoRedoHandler handler = chemModelRelay.getUndoRedoHandler();
        IAtomContainer containerForUndoRedo = chemModelRelay.getIChemModel().getBuilder().newInstance(IAtomContainer.class);
       
        IAtom newAtom;
        if(newSource) {
            newAtom = chemModelRelay.addAtomWithoutUndo( chemModelRelay.getController2DModel().getDrawElement(), start, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
            containerForUndoRedo.addAtom(newAtom);
        }
        else
            newAtom = source;

        // if merge is set either form a bond or add and form
        IAtomContainer removedContainer=null;
        if(merge!=null) {
                chemModelRelay.getRenderer().getRenderer2DModel().getMerge().remove(merge);
                removedContainer = ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), merge);
                IBond newBond = chemModelRelay.addBond( newAtom , merge, stereoForNewBond, orderForNewBond );
                containerForUndoRedo.addBond(newBond);
        } else {
            if(start.distance( worldCoord )<getHighlightDistance()) {
                if(!newSource) {
                    IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), newAtom, stereoForNewBond, orderForNewBond, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
                    containerForUndoRedo.addAtom(undoRedoAtom);
                    IAtomContainer atomCon =
                        ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), undoRedoAtom);
                    containerForUndoRedo.addElectronContainer(atomCon.getConnectedElectronContainersList(undoRedoAtom).get(0));
                } else if(makeInitialBond){
                    IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(
                            chemModelRelay.getController2DModel().getDrawElement(),
                            new Point2d(newAtom.getPoint2d().x+1.5,newAtom.getPoint2d().y),
                            chemModelRelay.getController2DModel().getDrawPseudoAtom());
                    containerForUndoRedo.addAtom(undoRedoAtom);
                    containerForUndoRedo.addBond(chemModelRelay.addBond(newAtom, undoRedoAtom, stereoForNewBond, orderForNewBond));
                }
            }else {
                IAtom atom = chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), dest, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
                containerForUndoRedo.addAtom(atom);
                IBond newBond = chemModelRelay.addBond( newAtom, atom, stereoForNewBond, orderForNewBond );
                containerForUndoRedo.addBond(newBond);
            }
        }

        if (factory != null && handler != null) {
            IUndoRedoable undoredo = chemModelRelay.getUndoRedoFactory().getAddAtomsAndBondsEdit
            (chemModelRelay.getIChemModel(), containerForUndoRedo, removedContainer, "Add Bond",chemModelRelay);
            handler.postEdit(undoredo);
        }
        chemModelRelay.updateView();
   
    }
View Full Code Here

            IAtom atom = chemModelRelay.addAtom( chemModelRelay.getController2DModel().getDrawElement(), chemModelRelay.getController2DModel().getDrawIsotopeNumber(), dest, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
            if(chemModelRelay.getController2DModel().getDrawIsotopeNumber()!=0)
                atom.setMassNumber(chemModelRelay.getController2DModel().getDrawIsotopeNumber());

            IUndoRedoFactory factory = chemModelRelay.getUndoRedoFactory();
            UndoRedoHandler handler = chemModelRelay.getUndoRedoHandler();
            IAtomContainer containerForUndoRedo = chemModelRelay.getIChemModel().getBuilder().newInstance(IAtomContainer.class);
            IBond bond = chemModelRelay.addBond( newAtom, atom, stereoForNewBond);
            containerForUndoRedo.addBond(bond);
            if (factory != null && handler != null) {
                IUndoRedoable undoredo = chemModelRelay.getUndoRedoFactory().getAddAtomsAndBondsEdit
                (chemModelRelay.getIChemModel(), containerForUndoRedo, null, "Add Bond",chemModelRelay);
                handler.postEdit(undoredo);
            }

           
    }else
            if(!newSource){
View Full Code Here

TOP

Related Classes of org.openscience.jchempaint.controller.undoredo.UndoRedoHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.