From bc4d8f9fca275eceee86e38c52975461ca504d07 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 26 Jun 2012 20:57:01 +0200 Subject: More GUI refactoring --- .../lifecycle/instance/CompositeActivity.java | 1 - .../lifecycle/instance/WfVertexOutlineCreator.java | 51 ++++++++++++ .../instance/gui/model/WfEdgeFactory.java | 35 -------- .../instance/gui/model/WfVertexFactory.java | 92 ---------------------- .../instance/gui/model/WfVertexOutlineCreator.java | 52 ------------ 5 files changed, 51 insertions(+), 180 deletions(-) create mode 100644 src/main/java/com/c2kernel/lifecycle/instance/WfVertexOutlineCreator.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfEdgeFactory.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexOutlineCreator.java (limited to 'src/main/java/com/c2kernel/lifecycle/instance') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java index c080a37..74f71ba 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java @@ -12,7 +12,6 @@ import com.c2kernel.entity.agent.Job; import com.c2kernel.graph.model.GraphModel; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.GraphableVertex; -import com.c2kernel.lifecycle.instance.gui.model.WfVertexOutlineCreator; import com.c2kernel.lifecycle.instance.stateMachine.StateMachine; import com.c2kernel.lifecycle.instance.stateMachine.States; import com.c2kernel.lifecycle.instance.stateMachine.Transitions; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertexOutlineCreator.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertexOutlineCreator.java new file mode 100644 index 0000000..3ae1730 --- /dev/null +++ b/src/main/java/com/c2kernel/lifecycle/instance/WfVertexOutlineCreator.java @@ -0,0 +1,51 @@ +package com.c2kernel.lifecycle.instance; + +import java.io.Serializable; + +import com.c2kernel.graph.model.GraphPoint; +import com.c2kernel.graph.model.Vertex; +import com.c2kernel.graph.model.VertexOutlineCreator; + +public class WfVertexOutlineCreator implements VertexOutlineCreator,Serializable +{ + private final int mActivityWidth = 130; + private final int mActivityHeight = 60; + private final int mSplitJoinWidth = 60; + private final int mSplitJoinHeight = 25; + + @Override + public void setOutline(Vertex vertex) + { + GraphPoint centrePoint = vertex.getCentrePoint(); + GraphPoint[] outlinePoints = new GraphPoint[ 4 ]; + int vertexWidth = 0; + int vertexHeight = 0; + + if(vertex instanceof Activity) + { + vertexWidth = mActivityWidth; + vertexHeight = mActivityHeight; + } + else + { + vertexWidth = mSplitJoinWidth; + vertexHeight = mSplitJoinHeight; + } + + outlinePoints[ 0 ] = new GraphPoint(); + outlinePoints[ 0 ].x = centrePoint.x - vertexWidth / 2; + outlinePoints[ 0 ].y = centrePoint.y - vertexHeight / 2; + outlinePoints[ 1 ] = new GraphPoint(); + outlinePoints[ 1 ].x = centrePoint.x + vertexWidth / 2; + outlinePoints[ 1 ].y = centrePoint.y - vertexHeight / 2; + outlinePoints[ 2 ] = new GraphPoint(); + outlinePoints[ 2 ].x = centrePoint.x + vertexWidth / 2; + outlinePoints[ 2 ].y = centrePoint.y + vertexHeight / 2; + outlinePoints[ 3 ] = new GraphPoint(); + outlinePoints[ 3 ].x = centrePoint.x - vertexWidth / 2; + outlinePoints[ 3 ].y = centrePoint.y + vertexHeight / 2; + + vertex.setOutlinePoints( outlinePoints ); + } +} + diff --git a/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfEdgeFactory.java b/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfEdgeFactory.java deleted file mode 100644 index e96ef37..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfEdgeFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.c2kernel.lifecycle.instance.gui.model; - -import com.c2kernel.graph.model.DirectedEdge; -import com.c2kernel.graph.model.EdgeFactory; -import com.c2kernel.graph.model.GraphModelManager; -import com.c2kernel.graph.model.TypeNameAndConstructionInfo; -import com.c2kernel.graph.model.Vertex; -import com.c2kernel.lifecycle.instance.WfVertex; - -public class WfEdgeFactory implements EdgeFactory -{ - @Override - public void create - ( - GraphModelManager graphModelManager, - Vertex origin, - Vertex terminus, - TypeNameAndConstructionInfo typeNameAndConstructionInfo - ) - { - if ( validCreation( graphModelManager, origin, terminus ) ) - ((WfVertex)origin).addNext((WfVertex)terminus); - - } - - private static boolean validCreation( GraphModelManager graphModelManager, Vertex origin, Vertex terminus ) - { - DirectedEdge[] connectingEdgesAToB = graphModelManager.getModel().getConnectingEdges( origin.getID() , terminus.getID() ); - DirectedEdge[] connectingEdgesBToA = graphModelManager.getModel().getConnectingEdges( terminus.getID(), origin.getID() ); - - - return ( origin != terminus ) && ( connectingEdgesAToB.length == 0 ) && ( connectingEdgesBToA.length == 0 ); - } -} - diff --git a/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java b/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java deleted file mode 100644 index 39e7ee9..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.c2kernel.lifecycle.instance.gui.model; -import java.awt.Point; -import java.io.Serializable; -import java.util.HashMap; - -import javax.swing.JOptionPane; - -import com.c2kernel.graph.model.GraphModelManager; -import com.c2kernel.graph.model.TypeNameAndConstructionInfo; -import com.c2kernel.graph.model.VertexFactory; -import com.c2kernel.lifecycle.ActivityDef; -import com.c2kernel.lifecycle.chooser.ActivityChooser; -import com.c2kernel.lifecycle.chooser.WorkflowDialogue; -import com.c2kernel.lifecycle.instance.Activity; -import com.c2kernel.lifecycle.instance.CompositeActivity; -import com.c2kernel.utils.Language; -import com.c2kernel.utils.LocalObjectLoader; -import com.c2kernel.utils.Resource; -public class WfVertexFactory implements VertexFactory, WorkflowDialogue -{ - protected CompositeActivity mRootAct = null; - @Override - public void create(GraphModelManager graphModelManager, Point location, TypeNameAndConstructionInfo typeNameAndConstructionInfo) - { - String vertexTypeId = null; - if (mRootAct != null && typeNameAndConstructionInfo.mInfo instanceof String) - { - vertexTypeId = (String) typeNameAndConstructionInfo.mInfo; - if (vertexTypeId.equals("Atomic") || vertexTypeId.equals("Composite")) - { - HashMap mhm = new HashMap(); - mhm.put("P1", vertexTypeId); - mhm.put("P2", location); - //************************************************ - ActivityChooser a = - new ActivityChooser( - Language.translate("Please enter a Type for the new activity"), - Language.translate("New " + vertexTypeId + " Activity"), - Resource.findImage("graph/newvertex_large.png").getImage(), - this, - mhm); - a.setVisible(true); - } - else - mRootAct.newChild(vertexTypeId, location); - } - } - @Override - public void setCreationContext(Object newContext) - { - if (newContext != null && newContext instanceof CompositeActivity) - mRootAct = (CompositeActivity) newContext; - } - @Override - public void loadThisWorkflow(String newName, HashMap hashMap) - { - String vertexTypeId = (String) hashMap.get("P1"); - Point location = (Point) hashMap.get("P2"); - if (newName == null) - return; - - - String unicName = newName; - while (mRootAct.search(mRootAct.getPath() + "/" + unicName) != null) - { - unicName = - (String) JOptionPane.showInputDialog( - null, - Language.translate("Activity name not unique. Please give another."), - Language.translate("New " + vertexTypeId + " Activity"), - JOptionPane.QUESTION_MESSAGE, - Resource.findImage("graph/newvertex_large.png"), - null, - null); - if (newName.equals("")) - return; - } - Activity act = null; - try - { - ActivityDef actD = LocalObjectLoader.getActDef(newName, "last"); - act = (Activity)actD.instantiate(unicName); - } - catch (Exception e) - { - } - if (act == null) - mRootAct.newChild(unicName, vertexTypeId, location); - else - mRootAct.newExistingChild(act, unicName, location); - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexOutlineCreator.java b/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexOutlineCreator.java deleted file mode 100644 index e8cb303..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/gui/model/WfVertexOutlineCreator.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.c2kernel.lifecycle.instance.gui.model; - -import java.io.Serializable; - -import com.c2kernel.graph.model.GraphPoint; -import com.c2kernel.graph.model.Vertex; -import com.c2kernel.graph.model.VertexOutlineCreator; -import com.c2kernel.lifecycle.instance.Activity; - -public class WfVertexOutlineCreator implements VertexOutlineCreator,Serializable -{ - private final int mActivityWidth = 130; - private final int mActivityHeight = 60; - private final int mSplitJoinWidth = 60; - private final int mSplitJoinHeight = 25; - - @Override - public void setOutline(Vertex vertex) - { - GraphPoint centrePoint = vertex.getCentrePoint(); - GraphPoint[] outlinePoints = new GraphPoint[ 4 ]; - int vertexWidth = 0; - int vertexHeight = 0; - - if(vertex instanceof Activity) - { - vertexWidth = mActivityWidth; - vertexHeight = mActivityHeight; - } - else - { - vertexWidth = mSplitJoinWidth; - vertexHeight = mSplitJoinHeight; - } - - outlinePoints[ 0 ] = new GraphPoint(); - outlinePoints[ 0 ].x = centrePoint.x - vertexWidth / 2; - outlinePoints[ 0 ].y = centrePoint.y - vertexHeight / 2; - outlinePoints[ 1 ] = new GraphPoint(); - outlinePoints[ 1 ].x = centrePoint.x + vertexWidth / 2; - outlinePoints[ 1 ].y = centrePoint.y - vertexHeight / 2; - outlinePoints[ 2 ] = new GraphPoint(); - outlinePoints[ 2 ].x = centrePoint.x + vertexWidth / 2; - outlinePoints[ 2 ].y = centrePoint.y + vertexHeight / 2; - outlinePoints[ 3 ] = new GraphPoint(); - outlinePoints[ 3 ].x = centrePoint.x - vertexWidth / 2; - outlinePoints[ 3 ].y = centrePoint.y + vertexHeight / 2; - - vertex.setOutlinePoints( outlinePoints ); - } -} - -- cgit v1.2.3