diff options
Diffstat (limited to 'src/main/java/org/cristalise/gui/graph/controller/VertexConstructionController.java')
| -rw-r--r-- | src/main/java/org/cristalise/gui/graph/controller/VertexConstructionController.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/java/org/cristalise/gui/graph/controller/VertexConstructionController.java b/src/main/java/org/cristalise/gui/graph/controller/VertexConstructionController.java new file mode 100644 index 0000000..a2f5dc0 --- /dev/null +++ b/src/main/java/org/cristalise/gui/graph/controller/VertexConstructionController.java @@ -0,0 +1,54 @@ +package org.cristalise.gui.graph.controller;
+
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import org.cristalise.gui.MainFrame;
+import org.cristalise.gui.graph.view.EditorModeListener;
+import org.cristalise.gui.graph.view.EditorToolBar;
+import org.cristalise.kernel.graph.model.GraphModelManager;
+import org.cristalise.kernel.graph.model.GraphPoint;
+
+
+
+public class VertexConstructionController extends MouseAdapter implements EditorModeListener
+{
+ private GraphModelManager mGraphModelManager = null;
+ private EditorToolBar mEditorToolBar = null;
+ private boolean mCreatingVertices = false;
+
+
+ public void setGraphModelManager(GraphModelManager graphModelManager)
+ {
+ mGraphModelManager = graphModelManager;
+ }
+
+
+ public void setEditorToolBar(EditorToolBar editorToolBar)
+ {
+ mEditorToolBar = editorToolBar;
+ mEditorToolBar.addEditorModeListener(this);
+ }
+
+
+ @Override
+ public void editorModeChanged(String idOfNewMode)
+ {
+ mCreatingVertices = idOfNewMode.equals("Vertex");
+ }
+
+
+ @Override
+ public void mouseClicked(MouseEvent me)
+ {
+ if(mCreatingVertices && (mGraphModelManager != null) && (mEditorToolBar != null) && mGraphModelManager.isEditable())
+ {
+ try {
+ mGraphModelManager.getModel().createVertex(new GraphPoint(me.getPoint().x, me.getPoint().y), mEditorToolBar.getSelectedVertexType());
+ } catch (Exception e) {
+ MainFrame.exceptionDialog(e);
+ }
+ mEditorToolBar.enterSelectMode();
+ }
+ }
+}
|
