From: SourceForge.net <no...@so...> - 2009-01-21 10:54:28
|
Patches item #2526009, was opened at 2009-01-21 11:54 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=320024&aid=2526009&group_id=20024 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Needs Review Status: Open Resolution: None Priority: 5 Private: No Submitted By: Egon Willighagen (egonw) Assigned to: gilleain maclean torrance (gilleain) Summary: Simple event model for IChemObjectRelay Initial Comment: Intended for jchempaint-primary. Gilleain, please check. The patch (Bioclipse commit 8403 and 8404 combined): $ more event.patch diff --git a/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java b/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/ controller/ControllerHub.java index 7be9bd3..c729672 100644 --- a/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java +++ b/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java @@ -83,6 +83,8 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { private final static RingPlacer ringPlacer = new RingPlacer(); private IAtomContainer phantoms; + + private IChemModelEventRelayHandler changeHandler; public ControllerHub(IControllerModel controllerModel, IJava2DRenderer renderer, @@ -113,6 +115,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { public void setChemModel(IChemModel model) { this.chemModel = model; + structureChanged(); } /** @@ -305,6 +308,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { public void removeAtom(IAtom atom) { ChemModelManipulator.removeAtomAndConnectedElectronContainers(chemModel, atom); + structureChanged(); } public IAtom addAtom(String atomType, Point2d worldCoord) { @@ -323,6 +327,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { // FIXME : always add to the first container? molSet.getAtomContainer(0).addAtom(newAtom); } + structureChanged(); return newAtom; } @@ -371,6 +376,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { atomCon.addAtom(newAtom); atomCon.addBond(newBond); + structureChanged(); return newAtom; } @@ -379,6 +385,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { Point2d atomCoord = new Point2d( worldCoords ); atom.setPoint2d( atomCoord ); } + coordinatesChanged(); } public void moveTo( IBond bond, Point2d point ) { @@ -393,32 +400,39 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { atom.setPoint2d(result); } } + coordinatesChanged(); } public IBond addBond(IAtom fromAtom, IAtom toAtom) { IBond newBond = chemModel.getBuilder().newBond(fromAtom, toAtom); chemModel.getMoleculeSet().getAtomContainer(0).addBond(newBond); + structureChanged(); return newBond; } public void setCharge(IAtom atom, int charge) { atom.setFormalCharge(charge); + structurePropertiesChanged(); } public void setMassNumber(IAtom atom, int charge) { atom.setMassNumber(charge); + structurePropertiesChanged(); } public void setOrder(IBond bond, Order order) { bond.setOrder(order); + structurePropertiesChanged(); } public void setSymbol(IAtom atom, String symbol) { atom.setSymbol(symbol); + structurePropertiesChanged(); } public void setWedgeType(IBond bond, int type) { bond.setStereo(type); + structurePropertiesChanged(); } public void updateImplicitHydrogenCounts() { @@ -446,6 +460,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { } } } + structurePropertiesChanged(); } public void zap() { @@ -453,6 +468,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { ChemModelManipulator.getAllAtomContainers(chemModel)) { container.removeAllElements(); } + structureChanged(); } public void cleanup() { @@ -487,6 +503,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { e.printStackTrace(); } } + coordinatesChanged(); } public IRing addRing(int ringSize, Point2d worldcoord) { @@ -501,6 +518,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { chemModel.setMoleculeSet(set); } set.addAtomContainer(ring); + structureChanged(); return ring; } @@ -531,6 +549,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { for (IBond ringBond : newRing.bonds()) { sourceContainer.addBond(ringBond); } + structureChanged(); return newRing; } @@ -578,6 +597,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { for (IBond ringBond : newRing.bonds()) { sourceContainer.addBond(ringBond); } + structureChanged(); return newRing; } @@ -704,6 +724,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { sourceContainer.addBond(ringBond); } } + structureChanged(); return newRing; } @@ -778,6 +799,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { sourceContainer.addBond(ringBond); } } + structureChanged(); return newRing; } @@ -785,6 +807,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { IAtomContainer sourceContainer = ChemModelManipulator .getRelevantAtomContainer(chemModel, bond); sourceContainer.removeBond(bond); + structureChanged(); } public void addPhantomAtom( IAtom atom ) { @@ -826,4 +849,20 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { } return formula.toString(); } + + public void setEventHandler(IChemModelEventRelayHandler handler) { + this.changeHandler = handler; + } + + private void structureChanged() { + if (changeHandler != null) changeHandler.structureChanged(); + } + + private void structurePropertiesChanged() { + if (changeHandler != null) changeHandler.structurePropertiesChanged(); + } + + private void coordinatesChanged() { + if (changeHandler != null) changeHandler.coordinatesChanged(); + } } diff --git a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelEventRelayHandler.java b/cdk-externals/trunk/org.openscience.cdk.render/src/org/open science/cdk/controller/IChemModelEventRelayHandler.java new file mode 100644 index 0000000..ba17e5e --- /dev/null +++ b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelEventRelayHandler.java @@ -0,0 +1,53 @@ +/* $Revision: 7636 $ $Author: nielsout $ $Date: 2007-09-02 11:46:10 +0100 (su, 02 sep 2007) $ + * + * Copyright (C) 2009 Egon Willighagen <eg...@us...sts.sf> + * + * Contact: cdk...@li... + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * All I ask is that proper credit is given for my work, which includes + * - but is not limited to - adding the above copyright notice to the beginning + * of your source code files, and to any copyright notice that you may distribute + * with programs based on this work. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.openscience.cdk.controller; + +public interface IChemModelEventRelayHandler { + + /** + * Signals that the connectivity table of the structure has changed, for + * example, an atom or bond was added or removed. This implies that the + * coordinates have changed too. + */ + public void structureChanged(); + + /** + * Signals that the atom or bond properties have changed, like atom symbol + * or bond order. This excludes coordinate changes, for which + * {@link #coordinatesChanged()} is used. + */ + public void structurePropertiesChanged(); + + /** + * Signals that the coordinates of the structure or the coordinates + * boundaries of the structure have changed. + */ + public void coordinatesChanged(); + + /** + * Signals that a selection was added, removed or changed. + */ + public void selectionChanged(); +} diff --git a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/ controller/IChemModelRelay.java index 4cd42ce..da18cb4 100644 --- a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java +++ b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java @@ -47,6 +47,9 @@ public interface IChemModelRelay { public abstract IBond getClosestBond(Point2d worldCoord); public abstract void updateView(); + /* Event model */ + public void setEventHandler(IChemModelEventRelayHandler handler); + /** * Adds an temporary atom which might be cleared later, when the final * atom is added. Controllers can use this to draw temporary atoms, for ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=320024&aid=2526009&group_id=20024 |
From: SourceForge.net <no...@so...> - 2009-01-21 12:27:51
|
Patches item #2526009, was opened at 2009-01-21 11:54 Message generated for change (Settings changed) made by egonw You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=320024&aid=2526009&group_id=20024 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None >Group: Accepted >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Egon Willighagen (egonw) Assigned to: gilleain maclean torrance (gilleain) Summary: Simple event model for IChemObjectRelay Initial Comment: Intended for jchempaint-primary. Gilleain, please check. The patch (Bioclipse commit 8403 and 8404 combined): $ more event.patch diff --git a/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java b/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/ controller/ControllerHub.java index 7be9bd3..c729672 100644 --- a/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java +++ b/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java @@ -83,6 +83,8 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { private final static RingPlacer ringPlacer = new RingPlacer(); private IAtomContainer phantoms; + + private IChemModelEventRelayHandler changeHandler; public ControllerHub(IControllerModel controllerModel, IJava2DRenderer renderer, @@ -113,6 +115,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { public void setChemModel(IChemModel model) { this.chemModel = model; + structureChanged(); } /** @@ -305,6 +308,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { public void removeAtom(IAtom atom) { ChemModelManipulator.removeAtomAndConnectedElectronContainers(chemModel, atom); + structureChanged(); } public IAtom addAtom(String atomType, Point2d worldCoord) { @@ -323,6 +327,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { // FIXME : always add to the first container? molSet.getAtomContainer(0).addAtom(newAtom); } + structureChanged(); return newAtom; } @@ -371,6 +376,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { atomCon.addAtom(newAtom); atomCon.addBond(newBond); + structureChanged(); return newAtom; } @@ -379,6 +385,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { Point2d atomCoord = new Point2d( worldCoords ); atom.setPoint2d( atomCoord ); } + coordinatesChanged(); } public void moveTo( IBond bond, Point2d point ) { @@ -393,32 +400,39 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { atom.setPoint2d(result); } } + coordinatesChanged(); } public IBond addBond(IAtom fromAtom, IAtom toAtom) { IBond newBond = chemModel.getBuilder().newBond(fromAtom, toAtom); chemModel.getMoleculeSet().getAtomContainer(0).addBond(newBond); + structureChanged(); return newBond; } public void setCharge(IAtom atom, int charge) { atom.setFormalCharge(charge); + structurePropertiesChanged(); } public void setMassNumber(IAtom atom, int charge) { atom.setMassNumber(charge); + structurePropertiesChanged(); } public void setOrder(IBond bond, Order order) { bond.setOrder(order); + structurePropertiesChanged(); } public void setSymbol(IAtom atom, String symbol) { atom.setSymbol(symbol); + structurePropertiesChanged(); } public void setWedgeType(IBond bond, int type) { bond.setStereo(type); + structurePropertiesChanged(); } public void updateImplicitHydrogenCounts() { @@ -446,6 +460,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { } } } + structurePropertiesChanged(); } public void zap() { @@ -453,6 +468,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { ChemModelManipulator.getAllAtomContainers(chemModel)) { container.removeAllElements(); } + structureChanged(); } public void cleanup() { @@ -487,6 +503,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { e.printStackTrace(); } } + coordinatesChanged(); } public IRing addRing(int ringSize, Point2d worldcoord) { @@ -501,6 +518,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { chemModel.setMoleculeSet(set); } set.addAtomContainer(ring); + structureChanged(); return ring; } @@ -531,6 +549,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { for (IBond ringBond : newRing.bonds()) { sourceContainer.addBond(ringBond); } + structureChanged(); return newRing; } @@ -578,6 +597,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { for (IBond ringBond : newRing.bonds()) { sourceContainer.addBond(ringBond); } + structureChanged(); return newRing; } @@ -704,6 +724,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { sourceContainer.addBond(ringBond); } } + structureChanged(); return newRing; } @@ -778,6 +799,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { sourceContainer.addBond(ringBond); } } + structureChanged(); return newRing; } @@ -785,6 +807,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { IAtomContainer sourceContainer = ChemModelManipulator .getRelevantAtomContainer(chemModel, bond); sourceContainer.removeBond(bond); + structureChanged(); } public void addPhantomAtom( IAtom atom ) { @@ -826,4 +849,20 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { } return formula.toString(); } + + public void setEventHandler(IChemModelEventRelayHandler handler) { + this.changeHandler = handler; + } + + private void structureChanged() { + if (changeHandler != null) changeHandler.structureChanged(); + } + + private void structurePropertiesChanged() { + if (changeHandler != null) changeHandler.structurePropertiesChanged(); + } + + private void coordinatesChanged() { + if (changeHandler != null) changeHandler.coordinatesChanged(); + } } diff --git a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelEventRelayHandler.java b/cdk-externals/trunk/org.openscience.cdk.render/src/org/open science/cdk/controller/IChemModelEventRelayHandler.java new file mode 100644 index 0000000..ba17e5e --- /dev/null +++ b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelEventRelayHandler.java @@ -0,0 +1,53 @@ +/* $Revision: 7636 $ $Author: nielsout $ $Date: 2007-09-02 11:46:10 +0100 (su, 02 sep 2007) $ + * + * Copyright (C) 2009 Egon Willighagen <eg...@us...sts.sf> + * + * Contact: cdk...@li... + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * All I ask is that proper credit is given for my work, which includes + * - but is not limited to - adding the above copyright notice to the beginning + * of your source code files, and to any copyright notice that you may distribute + * with programs based on this work. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.openscience.cdk.controller; + +public interface IChemModelEventRelayHandler { + + /** + * Signals that the connectivity table of the structure has changed, for + * example, an atom or bond was added or removed. This implies that the + * coordinates have changed too. + */ + public void structureChanged(); + + /** + * Signals that the atom or bond properties have changed, like atom symbol + * or bond order. This excludes coordinate changes, for which + * {@link #coordinatesChanged()} is used. + */ + public void structurePropertiesChanged(); + + /** + * Signals that the coordinates of the structure or the coordinates + * boundaries of the structure have changed. + */ + public void coordinatesChanged(); + + /** + * Signals that a selection was added, removed or changed. + */ + public void selectionChanged(); +} diff --git a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/ controller/IChemModelRelay.java index 4cd42ce..da18cb4 100644 --- a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java +++ b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java @@ -47,6 +47,9 @@ public interface IChemModelRelay { public abstract IBond getClosestBond(Point2d worldCoord); public abstract void updateView(); + /* Event model */ + public void setEventHandler(IChemModelEventRelayHandler handler); + /** * Adds an temporary atom which might be cleared later, when the final * atom is added. Controllers can use this to draw temporary atoms, for ---------------------------------------------------------------------- Comment By: gilleain maclean torrance (gilleain) Date: 2009-01-21 12:44 Message: Looks good. I showed it to stefan as well, and we agree that it will fix problems like updating the status bar on highlighting. It should make refreshing the screen more efficient, too. I think that these 4 are all of the desirable events to throw. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=320024&aid=2526009&group_id=20024 |
From: SourceForge.net <no...@so...> - 2009-01-21 12:29:53
|
Patches item #2526009, was opened at 2009-01-21 10:54 Message generated for change (Comment added) made by gilleain You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=320024&aid=2526009&group_id=20024 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Needs Review Status: Open Resolution: None Priority: 5 Private: No Submitted By: Egon Willighagen (egonw) Assigned to: gilleain maclean torrance (gilleain) Summary: Simple event model for IChemObjectRelay Initial Comment: Intended for jchempaint-primary. Gilleain, please check. The patch (Bioclipse commit 8403 and 8404 combined): $ more event.patch diff --git a/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java b/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/ controller/ControllerHub.java index 7be9bd3..c729672 100644 --- a/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java +++ b/cdk-externals/trunk/org.openscience.cdk.control/src/org/openscience/cdk/controller/ControllerHub.java @@ -83,6 +83,8 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { private final static RingPlacer ringPlacer = new RingPlacer(); private IAtomContainer phantoms; + + private IChemModelEventRelayHandler changeHandler; public ControllerHub(IControllerModel controllerModel, IJava2DRenderer renderer, @@ -113,6 +115,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { public void setChemModel(IChemModel model) { this.chemModel = model; + structureChanged(); } /** @@ -305,6 +308,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { public void removeAtom(IAtom atom) { ChemModelManipulator.removeAtomAndConnectedElectronContainers(chemModel, atom); + structureChanged(); } public IAtom addAtom(String atomType, Point2d worldCoord) { @@ -323,6 +327,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { // FIXME : always add to the first container? molSet.getAtomContainer(0).addAtom(newAtom); } + structureChanged(); return newAtom; } @@ -371,6 +376,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { atomCon.addAtom(newAtom); atomCon.addBond(newBond); + structureChanged(); return newAtom; } @@ -379,6 +385,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { Point2d atomCoord = new Point2d( worldCoords ); atom.setPoint2d( atomCoord ); } + coordinatesChanged(); } public void moveTo( IBond bond, Point2d point ) { @@ -393,32 +400,39 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { atom.setPoint2d(result); } } + coordinatesChanged(); } public IBond addBond(IAtom fromAtom, IAtom toAtom) { IBond newBond = chemModel.getBuilder().newBond(fromAtom, toAtom); chemModel.getMoleculeSet().getAtomContainer(0).addBond(newBond); + structureChanged(); return newBond; } public void setCharge(IAtom atom, int charge) { atom.setFormalCharge(charge); + structurePropertiesChanged(); } public void setMassNumber(IAtom atom, int charge) { atom.setMassNumber(charge); + structurePropertiesChanged(); } public void setOrder(IBond bond, Order order) { bond.setOrder(order); + structurePropertiesChanged(); } public void setSymbol(IAtom atom, String symbol) { atom.setSymbol(symbol); + structurePropertiesChanged(); } public void setWedgeType(IBond bond, int type) { bond.setStereo(type); + structurePropertiesChanged(); } public void updateImplicitHydrogenCounts() { @@ -446,6 +460,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { } } } + structurePropertiesChanged(); } public void zap() { @@ -453,6 +468,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { ChemModelManipulator.getAllAtomContainers(chemModel)) { container.removeAllElements(); } + structureChanged(); } public void cleanup() { @@ -487,6 +503,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { e.printStackTrace(); } } + coordinatesChanged(); } public IRing addRing(int ringSize, Point2d worldcoord) { @@ -501,6 +518,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { chemModel.setMoleculeSet(set); } set.addAtomContainer(ring); + structureChanged(); return ring; } @@ -531,6 +549,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { for (IBond ringBond : newRing.bonds()) { sourceContainer.addBond(ringBond); } + structureChanged(); return newRing; } @@ -578,6 +597,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { for (IBond ringBond : newRing.bonds()) { sourceContainer.addBond(ringBond); } + structureChanged(); return newRing; } @@ -704,6 +724,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { sourceContainer.addBond(ringBond); } } + structureChanged(); return newRing; } @@ -778,6 +799,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { sourceContainer.addBond(ringBond); } } + structureChanged(); return newRing; } @@ -785,6 +807,7 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { IAtomContainer sourceContainer = ChemModelManipulator .getRelevantAtomContainer(chemModel, bond); sourceContainer.removeBond(bond); + structureChanged(); } public void addPhantomAtom( IAtom atom ) { @@ -826,4 +849,20 @@ public class ControllerHub implements IMouseEventRelay, IChemModelRelay { } return formula.toString(); } + + public void setEventHandler(IChemModelEventRelayHandler handler) { + this.changeHandler = handler; + } + + private void structureChanged() { + if (changeHandler != null) changeHandler.structureChanged(); + } + + private void structurePropertiesChanged() { + if (changeHandler != null) changeHandler.structurePropertiesChanged(); + } + + private void coordinatesChanged() { + if (changeHandler != null) changeHandler.coordinatesChanged(); + } } diff --git a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelEventRelayHandler.java b/cdk-externals/trunk/org.openscience.cdk.render/src/org/open science/cdk/controller/IChemModelEventRelayHandler.java new file mode 100644 index 0000000..ba17e5e --- /dev/null +++ b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelEventRelayHandler.java @@ -0,0 +1,53 @@ +/* $Revision: 7636 $ $Author: nielsout $ $Date: 2007-09-02 11:46:10 +0100 (su, 02 sep 2007) $ + * + * Copyright (C) 2009 Egon Willighagen <eg...@us...sts.sf> + * + * Contact: cdk...@li... + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * All I ask is that proper credit is given for my work, which includes + * - but is not limited to - adding the above copyright notice to the beginning + * of your source code files, and to any copyright notice that you may distribute + * with programs based on this work. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.openscience.cdk.controller; + +public interface IChemModelEventRelayHandler { + + /** + * Signals that the connectivity table of the structure has changed, for + * example, an atom or bond was added or removed. This implies that the + * coordinates have changed too. + */ + public void structureChanged(); + + /** + * Signals that the atom or bond properties have changed, like atom symbol + * or bond order. This excludes coordinate changes, for which + * {@link #coordinatesChanged()} is used. + */ + public void structurePropertiesChanged(); + + /** + * Signals that the coordinates of the structure or the coordinates + * boundaries of the structure have changed. + */ + public void coordinatesChanged(); + + /** + * Signals that a selection was added, removed or changed. + */ + public void selectionChanged(); +} diff --git a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/ controller/IChemModelRelay.java index 4cd42ce..da18cb4 100644 --- a/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java +++ b/cdk-externals/trunk/org.openscience.cdk.render/src/org/openscience/cdk/controller/IChemModelRelay.java @@ -47,6 +47,9 @@ public interface IChemModelRelay { public abstract IBond getClosestBond(Point2d worldCoord); public abstract void updateView(); + /* Event model */ + public void setEventHandler(IChemModelEventRelayHandler handler); + /** * Adds an temporary atom which might be cleared later, when the final * atom is added. Controllers can use this to draw temporary atoms, for ---------------------------------------------------------------------- >Comment By: gilleain maclean torrance (gilleain) Date: 2009-01-21 11:44 Message: Looks good. I showed it to stefan as well, and we agree that it will fix problems like updating the status bar on highlighting. It should make refreshing the screen more efficient, too. I think that these 4 are all of the desirable events to throw. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=320024&aid=2526009&group_id=20024 |