From 11eb9557a35e17450c0aefb758471f1ff3148336 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 29 Jun 2012 16:20:11 +0200 Subject: Pull remaining graph GUI components into cristal-gui --- .../com/c2kernel/collection/AggregationMember.java | 10 - .../gui/model/AggregationVertexFactory.java | 6 +- .../graph/event/ElasticBandResizedEvent.java | 6 - .../c2kernel/graph/event/ElasticBandSetEvent.java | 6 - .../graph/event/SelectionChangedEvent.java | 9 - .../c2kernel/graph/event/SelectionMovedEvent.java | 7 - .../java/com/c2kernel/graph/model/ElasticBand.java | 17 - .../java/com/c2kernel/graph/model/GraphModel.java | 367 ++------------------- .../c2kernel/graph/model/GraphModelManager.java | 19 +- .../com/c2kernel/graph/model/GraphableVertex.java | 7 +- .../java/com/c2kernel/graph/model/Selection.java | 35 -- .../com/c2kernel/graph/model/VertexFactory.java | 5 +- .../c2kernel/lifecycle/CompositeActivityDef.java | 4 +- .../com/c2kernel/lifecycle/instance/Activity.java | 4 - .../lifecycle/instance/CompositeActivity.java | 19 +- .../com/c2kernel/lifecycle/instance/EventList.java | 19 -- .../c2kernel/lifecycle/instance/EventStorage.java | 24 -- .../com/c2kernel/lifecycle/instance/ParserWF.java | 10 +- .../com/c2kernel/lifecycle/instance/Workflow.java | 3 +- .../predefined/AddStepsFromDescription.java | 5 +- .../instance/predefined/ReplaceDomainWorkflow.java | 5 +- src/main/java/com/c2kernel/utils/Resource.java | 53 --- 22 files changed, 58 insertions(+), 582 deletions(-) delete mode 100644 src/main/java/com/c2kernel/graph/event/ElasticBandResizedEvent.java delete mode 100644 src/main/java/com/c2kernel/graph/event/ElasticBandSetEvent.java delete mode 100644 src/main/java/com/c2kernel/graph/event/SelectionChangedEvent.java delete mode 100644 src/main/java/com/c2kernel/graph/event/SelectionMovedEvent.java delete mode 100644 src/main/java/com/c2kernel/graph/model/ElasticBand.java delete mode 100644 src/main/java/com/c2kernel/graph/model/Selection.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/EventList.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/EventStorage.java (limited to 'src/main/java/com/c2kernel') diff --git a/src/main/java/com/c2kernel/collection/AggregationMember.java b/src/main/java/com/c2kernel/collection/AggregationMember.java index e3b213e..49b9ab7 100644 --- a/src/main/java/com/c2kernel/collection/AggregationMember.java +++ b/src/main/java/com/c2kernel/collection/AggregationMember.java @@ -1,6 +1,5 @@ package com.c2kernel.collection; -import java.awt.Image; import java.util.StringTokenizer; import com.c2kernel.common.ObjectNotFoundException; @@ -12,7 +11,6 @@ import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; import com.c2kernel.utils.Logger; -import com.c2kernel.utils.Resource; /** * @version $Revision: 1.11 $ $Date: 2005/12/01 14:23:15 $ @@ -31,7 +29,6 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb private Aggregation mCollection = null; private String mClassProps = null; String entityName; - Image image; /************************************************************************** @@ -134,13 +131,6 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb } - public Image getImage() { - if (image == null) { - image = Resource.findImage("typeicons/"+getProperties().get("Type")+"_16.png").getImage(); - } - return image; - } - public String getEntityName() { if (entityName == null) { if (mEntityKey > -1) { diff --git a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java index 7094644..88dcc3a 100644 --- a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java +++ b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java @@ -1,7 +1,5 @@ package com.c2kernel.collection.gui.model; -import java.awt.Point; - import com.c2kernel.collection.Aggregation; import com.c2kernel.graph.model.GraphModelManager; import com.c2kernel.graph.model.GraphPoint; @@ -27,12 +25,12 @@ public class AggregationVertexFactory implements VertexFactory public void create ( GraphModelManager graphModelManager, - Point location, + GraphPoint location, TypeNameAndConstructionInfo typeNameAndConstructionInfo ) throws Exception { if (typeNameAndConstructionInfo.mInfo.equals("AggregationMember")) { - mAggregation.addMember(-1, new CastorHashMap(), "", new GraphPoint(location.x, location.y), 40, 40); + mAggregation.addMember(-1, new CastorHashMap(), "",location, 40, 40); } } } diff --git a/src/main/java/com/c2kernel/graph/event/ElasticBandResizedEvent.java b/src/main/java/com/c2kernel/graph/event/ElasticBandResizedEvent.java deleted file mode 100644 index cb8ae3e..0000000 --- a/src/main/java/com/c2kernel/graph/event/ElasticBandResizedEvent.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.c2kernel.graph.event; - - -public class ElasticBandResizedEvent extends GraphModelEvent -{ -} diff --git a/src/main/java/com/c2kernel/graph/event/ElasticBandSetEvent.java b/src/main/java/com/c2kernel/graph/event/ElasticBandSetEvent.java deleted file mode 100644 index 6211513..0000000 --- a/src/main/java/com/c2kernel/graph/event/ElasticBandSetEvent.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.c2kernel.graph.event; - - -public class ElasticBandSetEvent extends GraphModelEvent -{ -} diff --git a/src/main/java/com/c2kernel/graph/event/SelectionChangedEvent.java b/src/main/java/com/c2kernel/graph/event/SelectionChangedEvent.java deleted file mode 100644 index f95e6d3..0000000 --- a/src/main/java/com/c2kernel/graph/event/SelectionChangedEvent.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.c2kernel.graph.event; - -import com.c2kernel.graph.model.Selection; - - -public class SelectionChangedEvent extends GraphModelEvent -{ - public Selection mSelection = null; -} diff --git a/src/main/java/com/c2kernel/graph/event/SelectionMovedEvent.java b/src/main/java/com/c2kernel/graph/event/SelectionMovedEvent.java deleted file mode 100644 index 2d892a9..0000000 --- a/src/main/java/com/c2kernel/graph/event/SelectionMovedEvent.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.c2kernel.graph.event; - - - -public class SelectionMovedEvent extends GraphModelEvent -{ -} diff --git a/src/main/java/com/c2kernel/graph/model/ElasticBand.java b/src/main/java/com/c2kernel/graph/model/ElasticBand.java deleted file mode 100644 index 38497ef..0000000 --- a/src/main/java/com/c2kernel/graph/model/ElasticBand.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.c2kernel.graph.model; - -import java.awt.Point; - - -public class ElasticBand -{ - public Point mFixedCorner = null; - public Point mMovingCorner = null; - - - public ElasticBand(Point fixedCorner, Point movingCorner) - { - mFixedCorner = fixedCorner; - mMovingCorner = movingCorner; - } -} diff --git a/src/main/java/com/c2kernel/graph/model/GraphModel.java b/src/main/java/com/c2kernel/graph/model/GraphModel.java index 6f5ced5..c428e79 100644 --- a/src/main/java/com/c2kernel/graph/model/GraphModel.java +++ b/src/main/java/com/c2kernel/graph/model/GraphModel.java @@ -1,7 +1,5 @@ package com.c2kernel.graph.model; -import java.awt.Point; -import java.awt.Polygon; import java.io.Serializable; import java.util.Hashtable; import java.util.Vector; @@ -9,14 +7,10 @@ import java.util.Vector; import com.c2kernel.graph.event.ClearedEvent; import com.c2kernel.graph.event.EdgeRemovedEvent; import com.c2kernel.graph.event.EdgesChangedEvent; -import com.c2kernel.graph.event.ElasticBandResizedEvent; -import com.c2kernel.graph.event.ElasticBandSetEvent; import com.c2kernel.graph.event.ForcedNotifyEvent; import com.c2kernel.graph.event.GraphModelEvent; import com.c2kernel.graph.event.GraphModelResizedEvent; import com.c2kernel.graph.event.NewEdgeEndPointChangedEvent; -import com.c2kernel.graph.event.SelectionChangedEvent; -import com.c2kernel.graph.event.SelectionMovedEvent; import com.c2kernel.graph.event.StartVertexIdChangedEvent; import com.c2kernel.graph.event.VertexAddedEvent; import com.c2kernel.graph.event.VertexCreatedEvent; @@ -25,8 +19,8 @@ import com.c2kernel.graph.event.VertexRemovedEvent; import com.c2kernel.graph.event.VerticesChangedEvent; import com.c2kernel.utils.Logger; -public class GraphModel implements Serializable{ - /* Persistant data */ +public class GraphModel implements Serializable { + /* Persistent data */ private int mWidth = 0; private int mHeight = 0; @@ -38,11 +32,9 @@ public class GraphModel implements Serializable{ /* Transient data */ - // There should always be a Selection object - protected Selection mSelection = new Selection(null, null, 0, 0, 0, 0); protected Vertex mNewEdgeOriginVertex = null; - protected Point mNewEdgeEndPoint = null; - private ElasticBand mElasticBand = null; + protected GraphPoint mNewEdgeEndPoint = null; + private GraphModelManager mManager = null; /* External factories */ @@ -61,16 +53,12 @@ public class GraphModel implements Serializable{ private final EdgesChangedEvent mEdgesChangedEvent = new EdgesChangedEvent(); private final ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent(); private final NewEdgeEndPointChangedEvent mNewEdgeEndPointChangedEvent = new NewEdgeEndPointChangedEvent(); - private final SelectionChangedEvent mSelectionChangedEvent = new SelectionChangedEvent(); private final StartVertexIdChangedEvent mStartVertexIdChangedEvent = new StartVertexIdChangedEvent(); private final VertexAddedEvent mVertexAddedEvent = new VertexAddedEvent(); private final VertexCreatedEvent mVertexCreatedEvent = new VertexCreatedEvent(); private final VertexMovedEvent mVertexMovedEvent = new VertexMovedEvent(); - private final SelectionMovedEvent mSelectionMovedEvent = new SelectionMovedEvent(); private final VertexRemovedEvent mVertexRemovedEvent = new VertexRemovedEvent(); private final VerticesChangedEvent mVerticesChangedEvent = new VerticesChangedEvent(); - private final ElasticBandSetEvent mElasticBandSetEvent = new ElasticBandSetEvent(); - private final ElasticBandResizedEvent mElasticBandResizedEvent = new ElasticBandResizedEvent(); private final GraphModelResizedEvent mGraphModelResizedEvent = new GraphModelResizedEvent(); // Calling this constructor does not create a vertex outline creator @@ -90,16 +78,6 @@ public class GraphModel implements Serializable{ return number; } - private void setChanged() { - if (mManager != null) - mManager.setChanged(); - } - - private void notifyObservers(GraphModelEvent ev) { - if (mManager != null) - mManager.notifyObservers(ev); - } - public void setNextId(int id) { mNextId = id; } @@ -152,14 +130,14 @@ public class GraphModel implements Serializable{ } if (resized) { - setChanged(); - notifyObservers(mGraphModelResizedEvent); + publishEvent(mGraphModelResizedEvent); } } public void setStartVertexId(int id) { mStartVertexId = id; + publishEvent(mStartVertexIdChangedEvent); } public int getStartVertexId() { @@ -190,8 +168,7 @@ public class GraphModel implements Serializable{ checkSize(vertice); } - setChanged(); - notifyObservers(mVerticesChangedEvent); + publishEvent(mVerticesChangedEvent); } public Vertex[] getVertices() { @@ -209,8 +186,7 @@ public class GraphModel implements Serializable{ for (DirectedEdge edge : edges) { mEdgeHashtable.put(String.valueOf(edge.getID()), edge); } - setChanged(); - notifyObservers(mEdgesChangedEvent); + publishEvent(mEdgesChangedEvent); } public DirectedEdge[] getEdges() { @@ -304,12 +280,7 @@ public class GraphModel implements Serializable{ terminus.removeInEdgeId(edgeId); // Remove the edge mEdgeHashtable.remove(String.valueOf(e.getID())); - setChanged(); - notifyObservers(mEdgeRemovedEvent); - } - - public int addVertexAndCreateId(Vertex v, Point location) { - return addVertexAndCreateId(v, new GraphPoint(location.x, location.y)); + publishEvent(mEdgeRemovedEvent); } public int addVertexAndCreateId(Vertex v, GraphPoint location) { @@ -332,8 +303,7 @@ public class GraphModel implements Serializable{ if (mVertexOutlineCreator != null) { mVertexOutlineCreator.setOutline(v); } - setChanged(); - notifyObservers(mVertexAddedEvent); + publishEvent(mVertexAddedEvent); checkSize(v); } @@ -365,8 +335,7 @@ public class GraphModel implements Serializable{ } // Remove the vertex mVertexHashtable.remove(String.valueOf(v.getID())); - setChanged(); - notifyObservers(mVertexRemovedEvent); + publishEvent(mVertexRemovedEvent); } public void moveAbsoluteVertex(Vertex v, GraphPoint p) { @@ -376,8 +345,7 @@ public class GraphModel implements Serializable{ if (p.x > mWidth) p.x = mWidth; if (p.y > mHeight) p.y = mHeight; moveAbsoluteVertexAndConnectingEdges(v, p); - setChanged(); - notifyObservers(mVertexMovedEvent); + publishEvent(mVertexMovedEvent); } private void moveAbsoluteVertexAndConnectingEdges(Vertex v, GraphPoint p) { @@ -397,43 +365,7 @@ public class GraphModel implements Serializable{ checkSize(v); } - public void moveAbsoluteSelection(int newTopLeftX, int newTopLeftY) { - int selectionHeight = mSelection.mBottomRightY - mSelection.mTopLeftY; - int selectionWidth = mSelection.mBottomRightX - mSelection.mTopLeftX; - int bottomRightX = newTopLeftX + selectionWidth; - int bottomRightY = newTopLeftY + selectionHeight; - GraphPoint oldCentrePoint = null; - GraphPoint newCentrePoint = null; - int distXFromTopLeft = 0; - int distYFromTopLeft = 0; - int i = 0; - // Make sure the selection does not move - // outside the boundaries of the graph - if (newTopLeftX < 0) newTopLeftX = 0; - if (newTopLeftY < 0) newTopLeftY = 0; - if (bottomRightX > mWidth) newTopLeftX = mWidth - selectionWidth; - if (bottomRightY > mHeight) newTopLeftY = mHeight - selectionHeight; - // For each selected vertex - for (i = 0; i < mSelection.mVertices.length; i++) { - // Calculate the new centre point of the vertex. - // First calculate the distance of the centre point - // from the old top left hand corner of the selection, - // then move the point to the new top left hand - // corner plus the distance. - oldCentrePoint = mSelection.mVertices[i].getCentrePoint(); - distXFromTopLeft = oldCentrePoint.x - mSelection.mTopLeftX; - distYFromTopLeft = oldCentrePoint.y - mSelection.mTopLeftY; - newCentrePoint = new GraphPoint(newTopLeftX + distXFromTopLeft, newTopLeftY + distYFromTopLeft); - moveAbsoluteVertexAndConnectingEdges(mSelection.mVertices[i], newCentrePoint); - } - // Update the top left and bottom right corners - mSelection.mTopLeftX = newTopLeftX; - mSelection.mTopLeftY = newTopLeftY; - mSelection.mBottomRightX = newTopLeftX + selectionWidth; - mSelection.mBottomRightY = newTopLeftY + selectionHeight; - setChanged(); - notifyObservers(mSelectionMovedEvent); - } + public Vertex resolveVertex(int id) { return mVertexHashtable.get(String.valueOf(id)); @@ -525,62 +457,17 @@ public class GraphModel implements Serializable{ } public void forceNotify() { - setChanged(); - notifyObservers(mForcedNotifyEvent); + publishEvent(mForcedNotifyEvent); } public void clear() { mVertexHashtable = new Hashtable(); mEdgeHashtable = new Hashtable(); mStartVertexId = -1; - setChanged(); - notifyObservers(mClearedEvent); + publishEvent(mClearedEvent); } - public void setSelection(Selection s) { - // If the there is a change - if (selectionChanged(s)) { - mSelection = s; - mSelectionChangedEvent.mSelection = s; - setChanged(); - notifyObservers(mSelectionChangedEvent); - } - } - private boolean selectionChanged(Selection newValue) { - int i = 0; - if (mSelection.mEdge != newValue.mEdge) { - return true; - } - if (mSelection.mVertices == null) { - if (newValue.mVertices == null) { - return false; - } - else { - return true; - } - } - else { - if (newValue.mVertices == null) { - return true; - } - else { - if (mSelection.mVertices.length != newValue.mVertices.length) { - return true; - } - for (i = 0; i < mSelection.mVertices.length; i++) { - if (mSelection.mVertices[i] != newValue.mVertices[i]) { - return true; - } - } - return false; - } - } - } - - public Selection getSelection() { - return mSelection; - } public void setNewEdgeOriginVertex(Vertex v) { mNewEdgeOriginVertex = v; @@ -590,13 +477,12 @@ public class GraphModel implements Serializable{ return mNewEdgeOriginVertex; } - public void setNewEdgeEndPoint(Point p) { + public void setNewEdgeEndPoint(GraphPoint p) { mNewEdgeEndPoint = p; - setChanged(); - notifyObservers(mNewEdgeEndPointChangedEvent); + publishEvent(mNewEdgeEndPointChangedEvent); } - public Point getNewEdgeEndPoint() { + public GraphPoint getNewEdgeEndPoint() { return mNewEdgeEndPoint; } @@ -604,15 +490,20 @@ public class GraphModel implements Serializable{ mExternalVertexFactory = factory; } - public void createVertex(Point location, TypeNameAndConstructionInfo typeNameAndConstructionInfo) throws Exception { + public void createVertex(GraphPoint location, TypeNameAndConstructionInfo typeNameAndConstructionInfo) throws Exception { if (mExternalVertexFactory != null) { mExternalVertexFactory.create(mManager, location, typeNameAndConstructionInfo); - setChanged(); - notifyObservers(mVertexCreatedEvent); + publishEvent(mVertexCreatedEvent); } } - public void setExternalEdgeFactory(EdgeFactory factory) { + private void publishEvent(GraphModelEvent event) { + if (mManager!=null) + mManager.notifyObservers(event); + + } + + public void setExternalEdgeFactory(EdgeFactory factory) { mExternalEdgeFactory = factory; } @@ -626,211 +517,7 @@ public class GraphModel implements Serializable{ } } - public void selectAll() { - Vertex[] allVertices = getVertices(); - if (allVertices.length > 0) { - mSelection.mEdge = null; - mSelection.mVertices = allVertices; - updateSelectionCorners(); - mSelectionChangedEvent.mSelection = mSelection; - setChanged(); - notifyObservers(mSelectionChangedEvent); - } - } - - public void selectContentsOfElasticBand() { - if (mElasticBand == null) return; - Polygon bandPolygon = new Polygon(); - Vertex[] allVertices = getVertices(); - GraphPoint centrePoint = null; - Vector verticesInside = new Vector(10, 10); - int i = 0; - // Create a polygon representing the elastic band - bandPolygon.addPoint(mElasticBand.mFixedCorner.x, mElasticBand.mFixedCorner.y); - bandPolygon.addPoint(mElasticBand.mMovingCorner.x, mElasticBand.mFixedCorner.y); - bandPolygon.addPoint(mElasticBand.mMovingCorner.x, mElasticBand.mMovingCorner.y); - bandPolygon.addPoint(mElasticBand.mFixedCorner.x, mElasticBand.mMovingCorner.y); - // Create a vector of all of the vertices within the elastic band polygon - for (i = 0; i < allVertices.length; i++) { - centrePoint = allVertices[i].getCentrePoint(); - if (bandPolygon.contains(centrePoint.x, centrePoint.y)) { - verticesInside.add(allVertices[i]); - } - } - - // Select the vertices found within the elastic band polygon - if (verticesInside.size() == 0) { - mSelection.mTopLeftX = 0; - mSelection.mTopLeftY = 0; - mSelection.mBottomRightX = 0; - mSelection.mBottomRightY = 0; - mSelection.mEdge = null; - if (mContainingVertex != null) - verticesInside.add(mContainingVertex); - else - mSelection.mVertices = null; - } - - if (verticesInside.size() > 0) { - mSelection.mEdge = null; - mSelection.mVertices = new Vertex[verticesInside.size()]; - for (i = 0; i < verticesInside.size(); i++) { - mSelection.mVertices[i] = verticesInside.elementAt(i); - } - updateSelectionCorners(); - } - // Remove the elastic band - mElasticBand = null; - mSelectionChangedEvent.mSelection = mSelection; - setChanged(); - notifyObservers(mSelectionChangedEvent); - } - - // Updates the top left and bottom right corners of the selection - private void updateSelectionCorners() { - Vertex vertex = mSelection.mVertices[0]; - GraphPoint centrePoint = vertex.getCentrePoint(); - if (centrePoint == null) return; - mSelection.mTopLeftX = centrePoint.x; - mSelection.mTopLeftY = centrePoint.y; - mSelection.mBottomRightX = centrePoint.x; - mSelection.mBottomRightY = centrePoint.y; - for (Vertex mVertice : mSelection.mVertices) { - vertex = mVertice; - centrePoint = vertex.getCentrePoint(); - if (centrePoint.x < mSelection.mTopLeftX) { - mSelection.mTopLeftX = centrePoint.x; - } - if (centrePoint.y < mSelection.mTopLeftY) { - mSelection.mTopLeftY = centrePoint.y; - } - if (centrePoint.x > mSelection.mBottomRightX) { - mSelection.mBottomRightX = centrePoint.x; - } - if (centrePoint.y > mSelection.mBottomRightY) { - mSelection.mBottomRightY = centrePoint.y; - } - } - } - - public void deleteSelection() { - int i = 0; - if (mSelection.mVertices != null) { - for (i = 0; i < mSelection.mVertices.length; i++) { - removeVertex(mSelection.mVertices[i]); - } - } - else if (mSelection.mEdge != null) { - removeEdge(mSelection.mEdge); - } - // Make sure nothing is selected - if ((mSelection.mEdge != null) || (mSelection.mVertices != null)) { - mSelection.mEdge = null; - mSelection.mVertices = null; - mSelectionChangedEvent.mSelection = mSelection; - setChanged(); - notifyObservers(mSelectionChangedEvent); - } - } - public void setSelectedVertexToBeStart() { - if (mSelection.mVertices != null) { - if (mSelection.mVertices.length == 1) { - setStartVertexId(mSelection.mVertices[0].getID()); - setChanged(); - notifyObservers(mStartVertexIdChangedEvent); - } - } - } - - public void setElasticBand(ElasticBand elasticBand) { - mElasticBand = elasticBand; - setChanged(); - notifyObservers(mElasticBandSetEvent); - } - - public ElasticBand getElasticBand() { - return mElasticBand; - } - - public void resizeElasticBand(Point movingCorner) { - mElasticBand.mMovingCorner = movingCorner; - setChanged(); - notifyObservers(mElasticBandResizedEvent); - } - - public boolean inSelection(Vertex v) { - int i = 0; - if (mSelection.mVertices == null) { - return false; - } - else { - for (i = 0; i < mSelection.mVertices.length; i++) { - if (mSelection.mVertices[i] == v) { - return true; - } - } - return false; - } - } - - // Only use this method to remove one vertex. - // If you wish to remove more, it would - // propably be more efficient to create a - // new Selection object. - public void removeFromSelection(Vertex v) { - Vertex[] vertices = null; - int i = 0; - int j = 0; - if (mSelection.mVertices.length == 1) { - mSelection.mVertices = null; - mSelection.mTopLeftX = 0; - mSelection.mTopLeftY = 0; - mSelection.mBottomRightX = 0; - mSelection.mBottomRightY = 0; - } - else { - vertices = new Vertex[mSelection.mVertices.length - 1]; - for (i = 0; i < mSelection.mVertices.length; i++) { - if (mSelection.mVertices[i] != v) { - vertices[j] = mSelection.mVertices[i]; - j++; - } - } - mSelection.mVertices = vertices; - updateSelectionCorners(); - } - setChanged(); - notifyObservers(mSelectionChangedEvent); - } - - // Only use this method to add one vertex. - // If you wish to add more, it would - // propably be more efficient to create a - // new Selection object. - public void addToSelection(Vertex v) { - Vertex[] vertices = new Vertex[mSelection.mVertices.length + 1]; - GraphPoint centrePoint = null; - int i = 0; - if (mSelection.mVertices == null) { - centrePoint = v.getCentrePoint(); - mSelection.mVertices = new Vertex[] { v }; - mSelection.mTopLeftX = centrePoint.x; - mSelection.mTopLeftY = centrePoint.y; - mSelection.mBottomRightX = centrePoint.x; - mSelection.mBottomRightY = centrePoint.y; - } - else { - for (i = 0; i < mSelection.mVertices.length; i++) { - vertices[i] = mSelection.mVertices[i]; - } - vertices[mSelection.mVertices.length] = v; - mSelection.mVertices = vertices; - updateSelectionCorners(); - } - setChanged(); - notifyObservers(mSelectionChangedEvent); - } public void resetVertexOutlines() { Vertex[] vertices = getVertices(); diff --git a/src/main/java/com/c2kernel/graph/model/GraphModelManager.java b/src/main/java/com/c2kernel/graph/model/GraphModelManager.java index 68d47e0..f639d07 100644 --- a/src/main/java/com/c2kernel/graph/model/GraphModelManager.java +++ b/src/main/java/com/c2kernel/graph/model/GraphModelManager.java @@ -18,10 +18,10 @@ public class GraphModelManager extends Observable private EdgeFactory mEdgeFactory; private VertexFactory mVertexFactory; private VertexOutlineCreator mVertexOutlineCreator; - private EntireModelChangedEvent mEntireModelChangedEvent = new EntireModelChangedEvent(); - private ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent(); - private Stack mParentModels = new Stack(); - private ArrayList mParentIds = new ArrayList(); + private final EntireModelChangedEvent mEntireModelChangedEvent = new EntireModelChangedEvent(); + private final ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent(); + private final Stack mParentModels = new Stack(); + private final ArrayList mParentIds = new ArrayList(); private boolean mEditable = true; // Calling this constructor does not create a vertex outline creator @@ -60,7 +60,6 @@ public class GraphModelManager extends Observable public void setModel(GraphModel newModel) { // reset transient data - newModel.mSelection = new Selection(null, null, 0, 0, 0, 0); newModel.mNewEdgeOriginVertex = null; newModel.mNewEdgeEndPoint = null; @@ -74,7 +73,6 @@ public class GraphModelManager extends Observable mGraphModel = newModel; // notify - setChanged(); notifyObservers(mEntireModelChangedEvent); } @@ -99,7 +97,6 @@ public class GraphModelManager extends Observable public void forceNotify() { - setChanged(); notifyObservers(mForcedNotifyEvent); } @@ -122,12 +119,8 @@ public class GraphModelManager extends Observable mGraphModel.setVertexOutlineCreator(newVertexOutlineCreator); } - @Override - protected void setChanged() { - super.setChanged(); - } - - protected void notifyObservers(GraphModelEvent ev) { + public void notifyObservers(GraphModelEvent ev) { + setChanged(); super.notifyObservers(ev); } diff --git a/src/main/java/com/c2kernel/graph/model/GraphableVertex.java b/src/main/java/com/c2kernel/graph/model/GraphableVertex.java index fc04743..cb4724d 100644 --- a/src/main/java/com/c2kernel/graph/model/GraphableVertex.java +++ b/src/main/java/com/c2kernel/graph/model/GraphableVertex.java @@ -3,7 +3,7 @@ package com.c2kernel.graph.model; * @version $Revision: 1.24 $ $Date: 2005/10/05 07:39:37 $ * @author $Author: abranson $ */ -import java.awt.Point; + import com.c2kernel.utils.CastorHashMap; import com.c2kernel.utils.KeyValuePair; @@ -177,10 +177,7 @@ public abstract class GraphableVertex extends Vertex { mIsComposite = isComposite; } - public void addChild(GraphableVertex graphableVertex, Point p) - { - addChild(graphableVertex, new GraphPoint(p.x, p.y)); - } + public void addChild(GraphableVertex graphableVertex, GraphPoint g) { getChildGraphModel().addVertexAndCreateId(graphableVertex, g); diff --git a/src/main/java/com/c2kernel/graph/model/Selection.java b/src/main/java/com/c2kernel/graph/model/Selection.java deleted file mode 100644 index dcc7b46..0000000 --- a/src/main/java/com/c2kernel/graph/model/Selection.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.c2kernel.graph.model; - -import java.io.Serializable; - - - -public class Selection implements Serializable -{ - // Either a single edge can be selected or - // one or more vertices can be selected. - // It is impossible to select an edge and a - // vertex at the same time. - public DirectedEdge mEdge = null; - public Vertex[] mVertices = null; - public int mTopLeftX = 0; - public int mTopLeftY = 0; - public int mBottomRightX = 0; - public int mBottomRightY = 0; - - - public Selection(DirectedEdge edge, - Vertex[] vertices, - int topLeftX, - int topLeftY, - int bottomRightX, - int bottomRightY) - { - mEdge = edge; - mVertices = vertices; - mTopLeftX = topLeftX; - mTopLeftY = topLeftY; - mBottomRightX = bottomRightX; - mBottomRightY = bottomRightY; - } -} diff --git a/src/main/java/com/c2kernel/graph/model/VertexFactory.java b/src/main/java/com/c2kernel/graph/model/VertexFactory.java index 02681bd..069f4ff 100644 --- a/src/main/java/com/c2kernel/graph/model/VertexFactory.java +++ b/src/main/java/com/c2kernel/graph/model/VertexFactory.java @@ -1,14 +1,11 @@ package com.c2kernel.graph.model; -import java.awt.Point; - - public interface VertexFactory { public void create ( GraphModelManager graphModelManager, - Point location, + GraphPoint location, TypeNameAndConstructionInfo typeNameAndConstructionInfo ) throws Exception; diff --git a/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java b/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java index df97086..54487f4 100644 --- a/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java +++ b/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java @@ -1,6 +1,4 @@ package com.c2kernel.lifecycle; -import java.awt.Point; - import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.graph.model.GraphModel; @@ -83,7 +81,7 @@ public class CompositeActivityDef extends ActivityDef * @param location * @return WfVertexDef */ - public WfVertexDef newChild(String Name, String Type, Point location) + public WfVertexDef newChild(String Name, String Type, GraphPoint location) { changed = true; WfVertexDef child; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java index 8a07d15..8d92522 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java @@ -45,9 +45,6 @@ public class Activity extends WfVertex public boolean active = false; /** used in verify() */ private boolean loopTested; - //public Vector eventIds; - /** Storage of eventIds thrown by the Activity */ - public EventStorage eventIds; private GTimeStamp mStartDate; private GTimeStamp mActiveDate; private String mType; @@ -58,7 +55,6 @@ public class Activity extends WfVertex setProperties(new WfCastorHashMap()); mErrors = new Vector(0, 1); machine = new StateMachine(this); - eventIds = new EventStorage(); mStartDate = new GTimeStamp(); mActiveDate = new GTimeStamp(); DateUtility.setToNow(mActiveDate); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java index 74f71ba..0928c83 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java @@ -1,6 +1,5 @@ package com.c2kernel.lifecycle.instance; -import java.awt.Point; import java.util.ArrayList; import java.util.Vector; @@ -78,7 +77,7 @@ public class CompositeActivity extends Activity * if true, the activity Waiting will be one of the first * launched by the parent activity */ - public void initChild(Activity act, boolean first, Point point) + public void initChild(Activity act, boolean first, GraphPoint point) { this.addChild(act, new GraphPoint(point.x, point.y)); if (first) @@ -96,7 +95,7 @@ public class CompositeActivity extends Activity * @param point * @return WfVertex */ - public WfVertex newExistingChild(Activity child, String Name, Point point) + public WfVertex newExistingChild(Activity child, String Name, GraphPoint point) { child.setName(Name); addChild(child, new GraphPoint(point.x, point.y)); @@ -111,7 +110,7 @@ public class CompositeActivity extends Activity * @param point * @return WfVertex */ - public WfVertex newChild(String Name, String Type, Point point) + public WfVertex newChild(String Name, String Type, GraphPoint point) { WfVertex v = newChild(Type, point); v.setName(Name); @@ -125,7 +124,7 @@ public class CompositeActivity extends Activity * @param point * @return WfVertex */ - public WfVertex newChild(String vertexTypeId, Point point) + public WfVertex newChild(String vertexTypeId, GraphPoint point) { WfVertex wfVertex = null; if (vertexTypeId.equals("Atomic")) @@ -168,7 +167,7 @@ public class CompositeActivity extends Activity * @return CompositeActivity Create an initialize a composite Activity * attached to the current activity */ - public CompositeActivity newCompChild(String id, boolean first, Point point) + public CompositeActivity newCompChild(String id, boolean first, GraphPoint point) { CompositeActivity act = new CompositeActivity(); initChild(act, first, point); @@ -186,7 +185,7 @@ public class CompositeActivity extends Activity * current activity * */ - public Activity newAtomChild(String id, boolean first, Point point) + public Activity newAtomChild(String id, boolean first, GraphPoint point) { Activity act = new Activity(); initChild(act, first, point); @@ -201,7 +200,7 @@ public class CompositeActivity extends Activity * @param point * @return Split */ - public Split newSplitChild(String Type, Point point) + public Split newSplitChild(String Type, GraphPoint point) { Split split; if (Type.equals("Or")) @@ -227,7 +226,7 @@ public class CompositeActivity extends Activity * @param point * @return Join */ - public Join newJoinChild(Point point) + public Join newJoinChild(GraphPoint point) { Join join = new Join(); join.getProperties().put("Type", "Join"); @@ -235,7 +234,7 @@ public class CompositeActivity extends Activity return join; } - public Join newRouteChild(Point point) + public Join newRouteChild(GraphPoint point) { Join join = new Join(); join.getProperties().put("Type", "Route"); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/EventList.java b/src/main/java/com/c2kernel/lifecycle/instance/EventList.java deleted file mode 100644 index be255fb..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/EventList.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.c2kernel.lifecycle.instance; - -import java.io.Serializable; - -/** - * @version $Revision: 1.9 $ $Date: 2005/06/08 19:47:59 $ - * @author $Author: abranson $ - */ -public class EventList implements Serializable { - private int[] dummy = new int[0]; - public int transition=-1; - - public int[] getNums() { - return dummy; - } - - public void setNums(int[] nums) { - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/EventStorage.java b/src/main/java/com/c2kernel/lifecycle/instance/EventStorage.java deleted file mode 100644 index 40cffaf..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/EventStorage.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.c2kernel.lifecycle.instance; -import java.io.Serializable; -import java.util.Hashtable; - -/** - * @version $Revision: 1.15 $ $Date: 2005/06/08 19:48:00 $ - * @author $Author: abranson $ - */ -public class EventStorage implements Serializable -{ - private Hashtable mLists; - private EventList[] dummy = new EventList[0]; - public Integer lastTransitionStored; - - public EventList[] getLists() - { - return dummy; - } - - public void setLists(EventList[] lists) - { - } - -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/ParserWF.java b/src/main/java/com/c2kernel/lifecycle/instance/ParserWF.java index 02a0c6d..1e52e6b 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/ParserWF.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/ParserWF.java @@ -1,9 +1,9 @@ package com.c2kernel.lifecycle.instance; -import java.awt.Point; import java.io.IOException; import java.util.Vector; +import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.lookup.AgentPath; import com.c2kernel.utils.CastorHashMap; import com.c2kernel.utils.Logger; @@ -53,7 +53,7 @@ public class ParserWF { if (nexts.elementAt(j)[0].equals(nexts.elementAt(k)[0])) { - int tmp = act.newSplitChild("And", new Point(0, 0)).getID(); + int tmp = act.newSplitChild("And", new GraphPoint(0, 0)).getID(); ((WfVertex) act.search(nexts.elementAt(k)[0])).addNext(act.search(tmp)); ((Split) act.search(tmp)).addNext((WfVertex) act.search(nexts.elementAt(k)[1])); ((Split) act.search(tmp)).addNext((WfVertex) act.search(nexts.elementAt(j)[1])); @@ -73,7 +73,7 @@ public class ParserWF { if (nexts.elementAt(j)[1].equals(nexts.elementAt(k)[1])) { - int tmp = act.newJoinChild(new Point(0, 0)).getID(); + int tmp = act.newJoinChild(new GraphPoint(0, 0)).getID(); ((WfVertex) act.search(nexts.elementAt(j)[0])).addNext(act.search(tmp)); ((WfVertex) act.search(nexts.elementAt(k)[0])).addNext(act.search(tmp)); ((Join) act.search(tmp)).addNext(nexts.elementAt(j)[1]); @@ -122,7 +122,7 @@ public class ParserWF Logger.msg(7, " txtCache = new Hashtable(); - static private Hashtable imgCache = new Hashtable(); static private URL baseURL = getURLorResURL("com/c2kernel/utils/resources/"); static private HashMap moduleBaseURLs = new HashMap(); - static public final ImageIcon nullImg = new ImageIcon(new byte[] { 0 }); public static URL getKernelBaseURL() { return baseURL; @@ -105,55 +101,6 @@ public class Resource { throw new ObjectNotFoundException(e.getMessage(),null); } } - /** - * Gets an image from the resource directories - * - * @param resName - filename after resources/images - * @return - */ - static public ImageIcon findImage(String resName) { - try { - for (String ns : getModuleBaseURLs().keySet()) { - try { - return getImage(ns, resName); - } catch (ObjectNotFoundException ex) { } - } - return getImage(null, resName); - } catch (ObjectNotFoundException ex) { - Logger.warning("Image '"+resName+"' not found. Using null icon"); - return nullImg; - } - } - - static public ImageIcon getImage(String ns, String resName) throws ObjectNotFoundException { - if (resName == null) - return nullImg; - - if (imgCache.containsKey(ns+'/'+resName)) { - return imgCache.get(ns+'/'+resName); - } - - URL imgLocation = null; - if (ns == null) - try { - imgLocation = getKernelResourceURL("images/"+resName); - } catch (MalformedURLException ex) { } - else - try { - imgLocation = getModuleResourceURL(ns, "images/"+resName); - } catch (MalformedURLException ex) { } - - if (imgLocation!= null) { - ImageIcon newImg = new ImageIcon(imgLocation); - - if (newImg.getIconHeight() > -1) { - imgCache.put(ns+'/'+resName, newImg); - Logger.msg(0, "Loaded "+resName+" "+newImg.getIconWidth()+"x"+newImg.getIconHeight()); - return newImg; - } - } - throw new ObjectNotFoundException(); - } static public String getKernelVersion() { try { -- cgit v1.2.3