summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/graph/model
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/graph/model')
-rw-r--r--source/com/c2kernel/graph/model/DirectedEdge.java99
-rwxr-xr-xsource/com/c2kernel/graph/model/EdgeFactory.java14
-rwxr-xr-xsource/com/c2kernel/graph/model/ElasticBand.java17
-rw-r--r--source/com/c2kernel/graph/model/GraphModel.java900
-rwxr-xr-xsource/com/c2kernel/graph/model/GraphModelCastorData.java29
-rw-r--r--source/com/c2kernel/graph/model/GraphModelManager.java143
-rw-r--r--source/com/c2kernel/graph/model/GraphPoint.java18
-rw-r--r--source/com/c2kernel/graph/model/Graphable.java55
-rw-r--r--source/com/c2kernel/graph/model/GraphableEdge.java71
-rw-r--r--source/com/c2kernel/graph/model/GraphableVertex.java261
-rwxr-xr-xsource/com/c2kernel/graph/model/Selection.java35
-rw-r--r--source/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java24
-rw-r--r--source/com/c2kernel/graph/model/Vertex.java308
-rw-r--r--source/com/c2kernel/graph/model/VertexFactory.java16
-rwxr-xr-xsource/com/c2kernel/graph/model/VertexOutlineCreator.java10
15 files changed, 0 insertions, 2000 deletions
diff --git a/source/com/c2kernel/graph/model/DirectedEdge.java b/source/com/c2kernel/graph/model/DirectedEdge.java
deleted file mode 100644
index 830d70d..0000000
--- a/source/com/c2kernel/graph/model/DirectedEdge.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.c2kernel.graph.model;
-
-import java.io.Serializable;
-
-
-
-public abstract class DirectedEdge implements Serializable
-{
- // Persistent data
- private int mId = -1;
- private GraphPoint mOriginPoint = new GraphPoint(0, 0);
- private GraphPoint mTerminusPoint = new GraphPoint(0, 0);
- private int mOriginVertexId = -1;
- private int mTerminusVertexId = -1;
-
-
- public void setID(int id)
- {
- mId = id;
- }
-
-
- public int getID()
- {
- return mId;
- }
-
-
- public void setOriginPoint(GraphPoint p)
- {
- mOriginPoint = p;
- }
-
-
- public GraphPoint getOriginPoint()
- {
- return mOriginPoint;
- }
-
-
- public void setTerminusPoint(GraphPoint p)
- {
- mTerminusPoint = p;
- }
-
-
- public GraphPoint getTerminusPoint()
- {
- return mTerminusPoint;
- }
-
-
- public boolean containsPoint(GraphPoint p)
- {
- int midX = mOriginPoint.x + (mTerminusPoint.x - mOriginPoint.x)/2;
- int midY = mOriginPoint.y + (mTerminusPoint.y - mOriginPoint.y)/2;
- int minX = midX - 10;
- int minY = midY - 10;
- int maxX = midX + 10;
- int maxY = midY + 10;
-
- return (p.x >= minX) && (p.x <= maxX) && (p.y >= minY) && (p.y <= maxY);
- }
-
-
- public void setOriginVertexId(int id)
- {
- mOriginVertexId = id;
- }
-
-
- public int getOriginVertexId()
- {
- return mOriginVertexId;
- }
-
-
- public void setTerminusVertexId(int id)
- {
- mTerminusVertexId = id;
- }
-
-
- public int getTerminusVertexId()
- {
- return mTerminusVertexId;
- }
-
-
- public void setName(String name)
- {
- }
-
-
- public String getName()
- {
- return null;
- }
-}
diff --git a/source/com/c2kernel/graph/model/EdgeFactory.java b/source/com/c2kernel/graph/model/EdgeFactory.java
deleted file mode 100755
index 083f616..0000000
--- a/source/com/c2kernel/graph/model/EdgeFactory.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.c2kernel.graph.model;
-
-
-
-public interface EdgeFactory
-{
- public void create
- (
- GraphModelManager graphModelManager,
- Vertex origin,
- Vertex terminus,
- TypeNameAndConstructionInfo typeNameAndConstructionInfo
- );
-}
diff --git a/source/com/c2kernel/graph/model/ElasticBand.java b/source/com/c2kernel/graph/model/ElasticBand.java
deleted file mode 100755
index 38497ef..0000000
--- a/source/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/source/com/c2kernel/graph/model/GraphModel.java b/source/com/c2kernel/graph/model/GraphModel.java
deleted file mode 100644
index 47f368d..0000000
--- a/source/com/c2kernel/graph/model/GraphModel.java
+++ /dev/null
@@ -1,900 +0,0 @@
-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;
-
-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;
-import com.c2kernel.graph.event.VertexMovedEvent;
-import com.c2kernel.graph.event.VertexRemovedEvent;
-import com.c2kernel.graph.event.VerticesChangedEvent;
-import com.c2kernel.utils.Logger;
-
-public class GraphModel implements Serializable{
- /* Persistant data */
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mNextId = 0;
- protected int mStartVertexId = -1;
- protected Hashtable<String, Vertex> mVertexHashtable = new Hashtable<String, Vertex>();
- protected Hashtable<String, DirectedEdge> mEdgeHashtable = new Hashtable<String, DirectedEdge>();
- private GraphableVertex mContainingVertex;
-
- /* 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;
- private GraphModelManager mManager = null;
-
- /* External factories */
-
- private VertexFactory mExternalVertexFactory = null;
- private EdgeFactory mExternalEdgeFactory = null;
-
- /* Vertex outline creator */
-
- private VertexOutlineCreator mVertexOutlineCreator = null;
-
- /* Notification Events */
-
- private ClearedEvent mClearedEvent = new ClearedEvent();
- private EdgeRemovedEvent mEdgeRemovedEvent = new EdgeRemovedEvent();
- private EdgesChangedEvent mEdgesChangedEvent = new EdgesChangedEvent();
- private ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent();
- private NewEdgeEndPointChangedEvent mNewEdgeEndPointChangedEvent = new NewEdgeEndPointChangedEvent();
- private SelectionChangedEvent mSelectionChangedEvent = new SelectionChangedEvent();
- private StartVertexIdChangedEvent mStartVertexIdChangedEvent = new StartVertexIdChangedEvent();
- private VertexAddedEvent mVertexAddedEvent = new VertexAddedEvent();
- private VertexCreatedEvent mVertexCreatedEvent = new VertexCreatedEvent();
- private VertexMovedEvent mVertexMovedEvent = new VertexMovedEvent();
- private SelectionMovedEvent mSelectionMovedEvent = new SelectionMovedEvent();
- private VertexRemovedEvent mVertexRemovedEvent = new VertexRemovedEvent();
- private VerticesChangedEvent mVerticesChangedEvent = new VerticesChangedEvent();
- private ElasticBandSetEvent mElasticBandSetEvent = new ElasticBandSetEvent();
- private ElasticBandResizedEvent mElasticBandResizedEvent = new ElasticBandResizedEvent();
- private GraphModelResizedEvent mGraphModelResizedEvent = new GraphModelResizedEvent();
-
- // Calling this constructor does not create a vertex outline creator
- // which is required by the method addVertexAndCreateId()
-
- private static int count=0;
-
- // count instances for debugging
- private int number;
-
- public GraphModel() {
- number=++count;
-
- }
-
- public int getNumber() {
- 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;
- }
-
- public int getNextId() {
- return mNextId;
- }
-
- public void setManager(GraphModelManager mgr) {
- mManager = mgr;
- }
-
- public GraphModelManager getManager() {
- return mManager;
- }
-
- public GraphModel(VertexOutlineCreator vertexOutlineCreator) {
- mVertexOutlineCreator = vertexOutlineCreator;
- }
-
- public void setWidth(int width) {
-
- mWidth = width;
- }
-
- public int getWidth() {
- return mWidth;
- }
-
- public void setHeight(int height) {
-
- mHeight = height;
- }
-
- public int getHeight() {
- return mHeight;
- }
-
- public void checkSize(Vertex v) {
- boolean resized = false;
- GraphPoint centre = v.getCentrePoint();
- if (getWidth() < centre.x + v.getWidth()/2 +10 ) {
- setWidth( centre.x + v.getWidth()/2 +10 );
- resized = true;
- }
-
- if (getHeight() < centre.y + v.getHeight()/2 +10 ) {
- setHeight(centre.y + v.getHeight()/2 +10 );
- resized = true;
- }
-
- if (resized) {
- setChanged();
- notifyObservers(mGraphModelResizedEvent);
- }
-
- }
-
- public void setStartVertexId(int id) {
- mStartVertexId = id;
- }
-
- public int getStartVertexId() {
- return mStartVertexId;
- }
-
- public Vertex getStartVertex() {
- return resolveVertex(getStartVertexId());
- }
-
- /**
- * @return Returns the mParentVertex.
- */
- public GraphableVertex getContainingVertex() {
- return mContainingVertex;
- }
- /**
- * @param parentVertex The mParentVertex to set.
- */
- public void setContainingVertex(GraphableVertex vertex) {
- mContainingVertex = vertex;
- }
-
- public void setVertices(Vertex[] vertices) {
- mVertexHashtable = new Hashtable<String, Vertex>();
- for (Vertex vertice : vertices) {
- mVertexHashtable.put(String.valueOf(vertice.getID()), vertice);
- checkSize(vertice);
-
- }
- setChanged();
- notifyObservers(mVerticesChangedEvent);
- }
-
- public Vertex[] getVertices() {
- Object[] vertexObjs = mVertexHashtable.values().toArray();
- Vertex[] vertices = new Vertex[vertexObjs.length];
- int i = 0;
- for (i = 0; i < vertices.length; i++) {
- vertices[i] = (Vertex)vertexObjs[i];
- }
- return vertices;
- }
-
- public void setEdges(DirectedEdge[] edges) {
- mEdgeHashtable = new Hashtable<String, DirectedEdge>();
- for (DirectedEdge edge : edges) {
- mEdgeHashtable.put(String.valueOf(edge.getID()), edge);
- }
- setChanged();
- notifyObservers(mEdgesChangedEvent);
- }
-
- public DirectedEdge[] getEdges() {
- Object[] edgeObjs = mEdgeHashtable.values().toArray();
- DirectedEdge[] edges = new DirectedEdge[edgeObjs.length];
- int i = 0;
- for (i = 0; i < edges.length; i++) {
- edges[i] = (DirectedEdge)edgeObjs[i];
- }
- return edges;
- }
-
- // If the specified point is within more than one vertex,
- // then the smallest vertex is returned.
- public Vertex getVertex(GraphPoint p) {
- Object[] vertexObjs = mVertexHashtable.values().toArray();
- Vertex vertex = null;
- Vector<Vertex> vertexVector = new Vector<Vertex>(10, 10);
- int numVerticesFound = 0;
- Vertex smallestVertex = null;
- int sizeOfSmallestVertex = 0;
- int sizeOfVertex = 0;
- int i = 0;
- for (i = 0; i < vertexObjs.length; i++) {
- vertex = (Vertex)vertexObjs[i];
- if (vertex.containsPoint(p)) {
- vertexVector.add(vertex);
- }
- }
- numVerticesFound = vertexVector.size();
- if (numVerticesFound == 0) {
- return null;
- }
- else {
- smallestVertex = vertexVector.elementAt(0);
- sizeOfSmallestVertex = smallestVertex.getHeight() * smallestVertex.getWidth();
- // Determine the smallest vertex
- for (i = 1; i < numVerticesFound; i++) {
- vertex = vertexVector.elementAt(i);
- sizeOfVertex = vertex.getHeight() * vertex.getWidth();
- if (sizeOfVertex < sizeOfSmallestVertex) {
- smallestVertex = vertex;
- sizeOfSmallestVertex = sizeOfVertex;
- }
- }
- return smallestVertex;
- }
- }
-
- public Vertex getVertexById(int id) {
- return mVertexHashtable.get(String.valueOf(id));
- }
-
- public DirectedEdge getEdge(GraphPoint p) {
- Object[] edgeObjs = mEdgeHashtable.values().toArray();
- DirectedEdge edge = null;
- int i = 0;
- for (i = 0; i < edgeObjs.length; i++) {
- edge = (DirectedEdge)edgeObjs[i];
- if (edge.containsPoint(p)) {
- return edge;
- }
- }
- return null;
- }
-
- public int addEdgeAndCreateId(DirectedEdge e, int originId, int terminusId) {
- return addEdgeAndCreateId(e, resolveVertex(originId), resolveVertex(terminusId));
- }
-
- public int addEdgeAndCreateId(DirectedEdge e, Vertex origin, Vertex terminus) {
- e.setID(mNextId);
- e.setOriginVertexId(origin.getID());
- e.setOriginPoint(origin.getCentrePoint());
- e.setTerminusVertexId(terminus.getID());
- e.setTerminusPoint(terminus.getCentrePoint());
- origin.addOutEdgeId(mNextId);
- terminus.addInEdgeId(mNextId);
- mEdgeHashtable.put(String.valueOf(mNextId), e);
- mNextId++;
- return mNextId - 1;
- }
-
- // Removes an edge, but does not modify the selection
- public void removeEdge(DirectedEdge e) {
- Vertex origin = getOrigin(e);
- Vertex terminus = getTerminus(e);
- int edgeId = e.getID();
- // Remove the id of the edge from the origin and terminus vertices
- origin.removeOutEdgeId(edgeId);
- 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));
- }
-
- public int addVertexAndCreateId(Vertex v, GraphPoint location) {
- if (location!= null)
- {
- if (mVertexOutlineCreator == null) {
- Logger.msg(1,"You cannot add a vertex with no outline creator");
- return -1;
-
- }
- mVertexHashtable.put(String.valueOf(mNextId), v);
- placeVertex(v, location);
- }
- v.setID(mNextId);
- return mNextId++;
- }
-
- public void placeVertex(Vertex v, GraphPoint location) {
- v.setCentrePoint(location);
- if (mVertexOutlineCreator != null) {
- mVertexOutlineCreator.setOutline(v);
- }
- setChanged();
- notifyObservers(mVertexAddedEvent);
- checkSize(v);
- }
-
- // Removes a vertex, but does not modify the selection
- public void removeVertex(Vertex v) {
- DirectedEdge[] inEdges = getInEdges(v);
- DirectedEdge[] outEdges = getOutEdges(v);
- Vertex origin = null;
- Vertex terminus = null;
- int edgeId = -1;
- int i = 0;
- // For each in edge
- for (i = 0; i < inEdges.length; i++) {
- edgeId = inEdges[i].getID();
- origin = getOrigin(inEdges[i]);
- // Remove the id of the edge from the origin vertex
- origin.removeOutEdgeId(edgeId);
- // Remove the edge
- mEdgeHashtable.remove(String.valueOf(edgeId));
- }
- // Remove all the out edges
- for (i = 0; i < outEdges.length; i++) {
- edgeId = outEdges[i].getID();
- terminus = getTerminus(outEdges[i]);
- // Remove the id of the edge from the terminus vertex
- terminus.removeInEdgeId(edgeId);
- // Remove the edge
- mEdgeHashtable.remove(String.valueOf(edgeId));
- }
- // Remove the vertex
- mVertexHashtable.remove(String.valueOf(v.getID()));
- setChanged();
- notifyObservers(mVertexRemovedEvent);
- }
-
- public void moveAbsoluteVertex(Vertex v, GraphPoint p) {
- // Make sure the new position stays within the graph
- if (p.x < 0) p.x = 0;
- if (p.y < 0) p.y = 0;
- if (p.x > mWidth) p.x = mWidth;
- if (p.y > mHeight) p.y = mHeight;
- moveAbsoluteVertexAndConnectingEdges(v, p);
- setChanged();
- notifyObservers(mVertexMovedEvent);
- }
-
- private void moveAbsoluteVertexAndConnectingEdges(Vertex v, GraphPoint p) {
- DirectedEdge[] inEdges = getInEdges(v);
- DirectedEdge[] outEdges = getOutEdges(v);
- int i = 0;
- // Move the vertex to the new position
- v.moveAbsolute(p);
- // Move the ends of the incoming edges to the new position
- for (i = 0; i < inEdges.length; i++) {
- inEdges[i].setTerminusPoint(p);
- }
- // Move the ends of the outgoing edges to the new position
- for (i = 0; i < outEdges.length; i++) {
- outEdges[i].setOriginPoint(p);
- }
- 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));
- }
-
- public DirectedEdge resolveEdge(int id) {
- return mEdgeHashtable.get(String.valueOf(id));
- }
-
- public DirectedEdge[] getInEdges(Vertex v) {
- int[] ids = v.getInEdgeIds();
- return resolveEdges(ids);
- }
-
- public DirectedEdge[] getOutEdges(Vertex v) {
- int[] ids = v.getOutEdgeIds();
- return resolveEdges(ids);
- }
-
- private DirectedEdge[] resolveEdges(int[] ids) {
- DirectedEdge[] edges = new DirectedEdge[ids.length];
- int i = 0;
- for (i = 0; i < ids.length; i++) {
- edges[i] = resolveEdge(ids[i]);
- }
- return edges;
- }
-
- public Vertex getOrigin(DirectedEdge e) {
- return resolveVertex(e.getOriginVertexId());
- }
-
- public Vertex getTerminus(DirectedEdge e) {
- return resolveVertex(e.getTerminusVertexId());
- }
-
- public Vertex[] getInVertices(Vertex v) {
- DirectedEdge[] inEdges = getInEdges(v);
- Vertex[] inVertices = new Vertex[inEdges.length];
- int i = 0;
- for (i = 0; i < inEdges.length; i++) {
- inVertices[i] = getOrigin(inEdges[i]);
- }
- return inVertices;
- }
-
- public Vertex[] getOutVertices(Vertex v) {
- DirectedEdge[] outEdges = getOutEdges(v);
- Vertex[] outVertices = new Vertex[outEdges.length];
- int i = 0;
- for (i = 0; i < outEdges.length; i++) {
- outVertices[i] = getTerminus(outEdges[i]);
- }
- return outVertices;
- }
-
- public DirectedEdge[] getConnectingEdges(int originVertexId, int terminusVertexId) {
- Vertex origin = resolveVertex(originVertexId);
- DirectedEdge[] outEdges = null;
- int numEdgesFound = 0;
- DirectedEdge[] edgesFound = null;
- int i = 0;
- int j = 0;
- if (origin == null) return null;
- outEdges = getOutEdges(origin);
- for (i = 0; i < outEdges.length; i++) {
- if (outEdges[i].getTerminusVertexId() == terminusVertexId) {
- numEdgesFound++;
- }
- }
- edgesFound = new DirectedEdge[numEdgesFound];
- for (i = 0; i < outEdges.length; i++) {
- if (outEdges[i].getTerminusVertexId() == terminusVertexId) {
- edgesFound[j] = outEdges[i];
- j++;
- }
- }
- return edgesFound;
- }
-
- public void clearTags(Object tag) {
- Vertex vertex = null;
- Object[] vertexObjs = mVertexHashtable.values().toArray();
- int i = 0;
- for (i = 0; i < vertexObjs.length; i++) {
- vertex = (Vertex)vertexObjs[i];
- vertex.clearTag(tag);
- }
- }
-
- public void forceNotify() {
- setChanged();
- notifyObservers(mForcedNotifyEvent);
- }
-
- public void clear() {
- mVertexHashtable = new Hashtable<String, Vertex>();
- mEdgeHashtable = new Hashtable<String, DirectedEdge>();
- mStartVertexId = -1;
- setChanged();
- notifyObservers(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;
- }
-
- public Vertex getNewEdgeOriginVertex() {
- return mNewEdgeOriginVertex;
- }
-
- public void setNewEdgeEndPoint(Point p) {
- mNewEdgeEndPoint = p;
- setChanged();
- notifyObservers(mNewEdgeEndPointChangedEvent);
- }
-
- public Point getNewEdgeEndPoint() {
- return mNewEdgeEndPoint;
- }
-
- public void setExternalVertexFactory(VertexFactory factory) {
- mExternalVertexFactory = factory;
- }
-
- public void createVertex(Point location, TypeNameAndConstructionInfo typeNameAndConstructionInfo) {
- if (mExternalVertexFactory != null) {
- mExternalVertexFactory.create(mManager, location, typeNameAndConstructionInfo);
- setChanged();
- notifyObservers(mVertexCreatedEvent);
- }
- }
-
- public void setExternalEdgeFactory(EdgeFactory factory) {
- mExternalEdgeFactory = factory;
- }
-
- public void setVertexOutlineCreator(VertexOutlineCreator outlineCreator) {
- mVertexOutlineCreator = outlineCreator;
- }
-
- public void createDirectedEdge(Vertex origin, Vertex terminus, TypeNameAndConstructionInfo typeNameAndConstructionInfo) {
- if (mExternalEdgeFactory != null) {
- mExternalEdgeFactory.create(mManager, origin, terminus, typeNameAndConstructionInfo);
- }
- }
-
- 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<Vertex> verticesInside = new Vector<Vertex>(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();
- int i = 0;
- for (i = 0; i < vertices.length; i++) {
- mVertexOutlineCreator.setOutline(vertices[i]);
- }
- }
-
- public void setGraphModelCastorData(GraphModelCastorData data) {
- Class<?> vertexOutlineCreatorClass = null;
- int i = 0;
- // Create the vertex outline creator
- if (data.mClassNameOfVertexOutlineCreator.equals("")) {
- mVertexOutlineCreator = null;
- }
- else {
- try {
- vertexOutlineCreatorClass = Class.forName(data.mClassNameOfVertexOutlineCreator);
- mVertexOutlineCreator = (VertexOutlineCreator)vertexOutlineCreatorClass.newInstance();
- }
- catch (Exception e) {
- e.printStackTrace();
- mVertexOutlineCreator = null;
- }
- }
- // Create and populate the vertex hashtable
- mVertexHashtable = new Hashtable<String, Vertex>();
- for (i = 0; i < data.mVertexImpls.length; i++) {
- mVertexHashtable.put(String.valueOf(data.mVertexImpls[i].getID()), data.mVertexImpls[i]);
- checkSize(data.mVertexImpls[i]);
- }
- // Create and populate the edge hastable
- mEdgeHashtable = new Hashtable<String, DirectedEdge>();
- for (i = 0; i < data.mEdgeImpls.length; i++) {
- mEdgeHashtable.put(String.valueOf(data.mEdgeImpls[i].getID()), data.mEdgeImpls[i]);
- }
- // Set the start vertex id and the id generation counter
- mStartVertexId = data.mStartVertexId;
- mNextId = data.mNextId;
- }
-
- public GraphModelCastorData getGraphModelCastorData() {
- Object[] vertexObjs = mVertexHashtable.values().toArray();
- Vertex[] vertexImpls = new Vertex[vertexObjs.length];
- Object[] edgeObjs = mEdgeHashtable.values().toArray();
- DirectedEdge[] directedEdgeImpls = new DirectedEdge[edgeObjs.length];
- String className = null;
- int i = 0;
- // Put in the vertices
- for (i = 0; i < vertexImpls.length; i++) {
- vertexImpls[i] = (Vertex)vertexObjs[i];
- }
- // Put in the edges
- for (i = 0; i < directedEdgeImpls.length; i++) {
- directedEdgeImpls[i] = (DirectedEdge)edgeObjs[i];
- }
- // Determine the class name of the vertex outline creator
- if (mVertexOutlineCreator == null) {
- className = "";
- }
- else {
- className = mVertexOutlineCreator.getClass().getName();
- }
- return new GraphModelCastorData(className, vertexImpls, directedEdgeImpls, mStartVertexId, mNextId);
- }
-}
diff --git a/source/com/c2kernel/graph/model/GraphModelCastorData.java b/source/com/c2kernel/graph/model/GraphModelCastorData.java
deleted file mode 100755
index 7717c33..0000000
--- a/source/com/c2kernel/graph/model/GraphModelCastorData.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.c2kernel.graph.model;
-
-
-public class GraphModelCastorData
-{
- public String mClassNameOfVertexOutlineCreator = "";
- public Vertex[] mVertexImpls = {};
- public DirectedEdge[] mEdgeImpls = {};
- public int mStartVertexId = 0;
- public int mNextId = 0;
-
-
- public GraphModelCastorData()
- {
- }
-
- public GraphModelCastorData(String classNameOfVertexOutlineCreator,
- Vertex[] vertexImpls,
- DirectedEdge[] edgeImpls,
- int startVertexId,
- int nextId)
- {
- mClassNameOfVertexOutlineCreator = classNameOfVertexOutlineCreator;
- mVertexImpls = vertexImpls;
- mEdgeImpls = edgeImpls;
- mStartVertexId = startVertexId;
- mNextId = nextId;
- }
-}
diff --git a/source/com/c2kernel/graph/model/GraphModelManager.java b/source/com/c2kernel/graph/model/GraphModelManager.java
deleted file mode 100644
index 68d47e0..0000000
--- a/source/com/c2kernel/graph/model/GraphModelManager.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.c2kernel.graph.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Observable;
-import java.util.Stack;
-
-import com.c2kernel.graph.event.EntireModelChangedEvent;
-import com.c2kernel.graph.event.ForcedNotifyEvent;
-import com.c2kernel.graph.event.GraphModelEvent;
-import com.c2kernel.utils.Logger;
-
-
-public class GraphModelManager extends Observable
-{
-
- private GraphModel mGraphModel;
- private EdgeFactory mEdgeFactory;
- private VertexFactory mVertexFactory;
- private VertexOutlineCreator mVertexOutlineCreator;
- private EntireModelChangedEvent mEntireModelChangedEvent = new EntireModelChangedEvent();
- private ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent();
- private Stack<GraphModel> mParentModels = new Stack<GraphModel>();
- private ArrayList<Integer> mParentIds = new ArrayList<Integer>();
- private boolean mEditable = true;
-
- // Calling this constructor does not create a vertex outline creator
- // which is required by the method addVertexAndCreateId()
- public GraphModelManager()
- {
- mGraphModel = new GraphModel();
- mGraphModel.setManager(this);
- }
-
- public GraphModelManager(GraphModel newModel) {
- newModel.setManager(this);
- mGraphModel = newModel;
- }
-
- public void replace(GraphModel newModel) {
- mParentModels.clear();
-
- //zoom back to where we were
- for (Iterator<Integer> iter = mParentIds.iterator(); iter.hasNext();) {
- Integer parentId = iter.next();
- GraphableVertex childModelVertex = (GraphableVertex)newModel.getVertexById(parentId.intValue());
- if (childModelVertex == null) { // we've been deleted, stay here
- Logger.msg(7, "Didn't find "+parentId+" in new model tree. Stopping here.");
- do { iter.remove(); } while (iter.hasNext());
- break;
- }
- else {
- mParentModels.push(newModel);
- Logger.msg(7, "Pushing model and switching to "+parentId);
- newModel = childModelVertex.getChildGraphModel();
- }
- }
- setModel(newModel);
- }
-
- public void setModel(GraphModel newModel) {
- // reset transient data
- newModel.mSelection = new Selection(null, null, 0, 0, 0, 0);
- newModel.mNewEdgeOriginVertex = null;
- newModel.mNewEdgeEndPoint = null;
-
- // copy factories over
- newModel.setExternalEdgeFactory(mEdgeFactory);
- newModel.setExternalVertexFactory(mVertexFactory);
- newModel.setVertexOutlineCreator(mVertexOutlineCreator);
- mVertexFactory.setCreationContext(newModel.getContainingVertex());
- newModel.setManager(this);
- mGraphModel.setManager(null);
- mGraphModel = newModel;
-
- // notify
- setChanged();
- notifyObservers(mEntireModelChangedEvent);
- }
-
- public void zoomIn(Vertex child) {
- GraphModel childModel = child.getChildGraphModel();
- if (childModel != null) {
- mParentModels.push(mGraphModel);
- mParentIds.add(new Integer(child.getID()));
- setModel(childModel);
- Logger.msg(7, "ZoomIn - Stack size: "+mParentModels.size()+" ids:"+mParentIds.size());
- }
- }
-
- public void zoomOut() {
- if (!mParentModels.empty()) {
- setModel(mParentModels.pop());
- mParentIds.remove(mParentIds.size()-1);
- }
- Logger.msg(7, "ZoomOut - Stack size: "+mParentModels.size()+" ids:"+mParentIds.size());
-
- }
-
- public void forceNotify()
- {
- setChanged();
- notifyObservers(mForcedNotifyEvent);
- }
-
- public GraphModel getModel() {
- return mGraphModel;
- }
-
- public void setExternalEdgeFactory(EdgeFactory newEdgeFactory) {
- mEdgeFactory = newEdgeFactory;
- mGraphModel.setExternalEdgeFactory(newEdgeFactory);
- }
-
- public void setExternalVertexFactory(VertexFactory newVertexFactory) {
- mVertexFactory = newVertexFactory;
- mGraphModel.setExternalVertexFactory(newVertexFactory);
- }
-
- public void setVertexOutlineCreator(VertexOutlineCreator newVertexOutlineCreator) {
- mVertexOutlineCreator = newVertexOutlineCreator;
- mGraphModel.setVertexOutlineCreator(newVertexOutlineCreator);
- }
-
- @Override
- protected void setChanged() {
- super.setChanged();
- }
-
- protected void notifyObservers(GraphModelEvent ev) {
- super.notifyObservers(ev);
- }
-
- public void setEditable(boolean editable) {
- mEditable = editable;
- }
-
- public boolean isEditable() {
- return mEditable;
- }
-
-
-}
diff --git a/source/com/c2kernel/graph/model/GraphPoint.java b/source/com/c2kernel/graph/model/GraphPoint.java
deleted file mode 100644
index f2aa165..0000000
--- a/source/com/c2kernel/graph/model/GraphPoint.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.c2kernel.graph.model;
-
-import java.io.Serializable;
-
-public class GraphPoint implements Serializable{
-
- public int x;
- public int y;
-
- public GraphPoint() {
- x=0; y=0;
- }
-
- public GraphPoint(int x, int y) {
- this.x = x;
- this.y = y;
- }
-}
diff --git a/source/com/c2kernel/graph/model/Graphable.java b/source/com/c2kernel/graph/model/Graphable.java
deleted file mode 100644
index ed55271..0000000
--- a/source/com/c2kernel/graph/model/Graphable.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.c2kernel.graph.model;
-
-/**
-* @version $Revision: 1.6 $ $Date: 2003/05/12 13:10:20 $
-* @author $Author: abranson $
-*/
-
-import com.c2kernel.utils.CastorHashMap;
-
-abstract public class Graphable extends Vertex
-{
-
- protected CastorHashMap mProperties = null;
- public GraphModel children;
-
- public void setProperties(CastorHashMap props)
- {
- mProperties = props;
- }
-
- public CastorHashMap getProperties()
- {
- return mProperties;
- }
- /** @associates Graphable that is directly containing it*/
- private Graphable parent;
-
- /**
- * Returns the parent.
- * @return Graphable
- */
- public Graphable getParent()
- {
- return parent;
- }
-
- /**
- * Sets the parent.
- * @param parent The parent to set
- */
- public void setParent(Graphable parent)
- {
- this.parent = parent;
- }
- @Override
- public GraphModel getChildGraphModel() {
- return children;
- }
-
- @Override
- public Object getCreationContext() {
- return this;
- }
-
-}
diff --git a/source/com/c2kernel/graph/model/GraphableEdge.java b/source/com/c2kernel/graph/model/GraphableEdge.java
deleted file mode 100644
index 23499be..0000000
--- a/source/com/c2kernel/graph/model/GraphableEdge.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.c2kernel.graph.model;
-
-import com.c2kernel.utils.CastorHashMap;
-import com.c2kernel.utils.KeyValuePair;
-
-/**
-* @version $Revision: 1.2 $ $Date: 2003/05/12 13:10:20 $
-* @author $Author: abranson $
-*/
-public abstract class GraphableEdge extends DirectedEdge
-{
-
- private GraphableVertex mParent;
- private CastorHashMap mProperties = null;
-
- public GraphableEdge()
- {
- mProperties = new CastorHashMap();
- }
-
- public GraphableEdge(GraphableVertex pre, GraphableVertex nex)
- {
- mProperties = new CastorHashMap();
- setParent(pre.getParent());
- pre.getParent().getChildrenGraphModel().addEdgeAndCreateId(this, pre, nex);
- }
-
- /**
- * Returns the parent.
- * @return GraphableVertex
- */
- public GraphableVertex getParent()
- {
- return mParent;
- }
-
- /**
- * Sets the parent.
- * @param parent The parent to set
- */
- public void setParent(GraphableVertex parent)
- {
- mParent = parent;
- }
-
- /**
- * Returns the properties.
- * @return CastorHashMap
- */
- public CastorHashMap getProperties()
- {
- return mProperties;
- }
-
- /**
- * Sets the properties.
- * @param properties The properties to set
- */
- public void setProperties(CastorHashMap properties)
- {
- mProperties = properties;
- }
-
- public KeyValuePair[] getKeyValuePairs() {
- return mProperties.getKeyValuePairs();
- }
-
- public void setKeyValuePairs(KeyValuePair[] pairs) {
- mProperties.setKeyValuePairs(pairs);
- }
-}
diff --git a/source/com/c2kernel/graph/model/GraphableVertex.java b/source/com/c2kernel/graph/model/GraphableVertex.java
deleted file mode 100644
index fc04743..0000000
--- a/source/com/c2kernel/graph/model/GraphableVertex.java
+++ /dev/null
@@ -1,261 +0,0 @@
-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;
-public abstract class GraphableVertex extends Vertex
-{
- private CastorHashMap mProperties = null;
- private boolean mIsLayoutable;
- protected boolean mIsComposite;
- private GraphModel mChildrenGraphModel;
- public GraphableVertex()
- {
- mProperties = new CastorHashMap();
- }
- public void setProperties(CastorHashMap props)
- {
- mProperties = props;
- }
- public CastorHashMap getProperties()
- {
- return mProperties;
- }
- public KeyValuePair[] getKeyValuePairs()
- {
- return mProperties.getKeyValuePairs();
- }
- public void setKeyValuePairs(KeyValuePair[] pairs)
- {
- mProperties.setKeyValuePairs(pairs);
- }
- /** @associates Graphable that is directly containing it*/
- private GraphableVertex parent;
- /**
- * Returns the parent.
- * @return Graphable
- */
- public GraphableVertex getParent()
- {
- return parent;
- }
- /**
- * Sets the parent.
- * @param parent The parent to set
- */
- public void setParent(GraphableVertex parent)
- {
- if (this.equals(parent))
- throw new ExceptionInInitializerError();
- this.parent = parent;
- }
- @Override
- public GraphModel getChildGraphModel()
- {
- return mChildrenGraphModel;
- }
- @Override
- public Object getCreationContext()
- {
- return this;
- }
- public Vertex[] getOutGraphables()
- {
- if (parent == null)
- return new Vertex[0]; // none if no parent
- return parent.mChildrenGraphModel.getOutVertices(this);
- }
- public DirectedEdge[] getOutEdges()
- {
- if (parent == null)
- return new DirectedEdge[0]; // none if no parent
- return parent.mChildrenGraphModel.getOutEdges(this);
- }
- public DirectedEdge[] getInEdges()
- {
- if (parent == null)
- return new DirectedEdge[0]; // none if no parent
- DirectedEdge[] edges = getParent().mChildrenGraphModel.getInEdges(this);
- if (edges != null)
- return edges;
- else
- return new DirectedEdge[0];
- }
- public GraphableVertex[] getChildren()
- {
- return getLayoutableChildren();
- }
-
- public DirectedEdge[] getChildrenEdges()
- {
- if (getIsComposite())
- {
- return getChildGraphModel().getEdges();
- }
- return null;
- }
-
- public GraphableVertex[] getLayoutableChildren()
- {
- if (getIsComposite())
- {
- Vertex[] vs = mChildrenGraphModel.getVertices();
- GraphableVertex[] gvs = new GraphableVertex[vs.length];
- for (int i = 0; i < vs.length; i++)
- {
- gvs[i] = (GraphableVertex) vs[i];
- }
- return gvs;
- }
- return null;
- }
- // deprecated methods
- public GraphableVertex[] getCNonLayoutableChildren() {
- return new GraphableVertex[0];
- }
- public void setCNonLayoutableChildren(GraphableVertex[] dummy) { }
-
- /**@returns the Graphable searched or null if not this or children*/
- public GraphableVertex search(String ids)
- {
- if (getName().equals(ids))
- return this;
- if (String.valueOf(getID()).equals(ids))
- return this;
- if (getIsComposite())
- {
- GraphableVertex[] graphables = getChildren();
- if (ids.startsWith(String.valueOf(getID())))
- ids = ids.substring(ids.indexOf("/") + 1);
- else if (ids.startsWith(getName()))
- ids = ids.substring(getName().length() + 1);
- else if (ids.startsWith(getPath()))
- ids = ids.substring(getPath().length() + 1);
- else
- return null;
-
- for (GraphableVertex graphable : graphables) {
- GraphableVertex grap = graphable.search(ids);
- if (grap != null) return grap;
- }
- }
- return null;
- }
- /**
- * Returns the isLayoutable.
- * @return boolean
- */
- public boolean getIsLayoutable()
- {
- return mIsLayoutable;
- }
- /**
- * Sets the isLayoutable.
- * @param isLayoutable The isLayoutable to set
- */
- public void setIsLayoutable(boolean isLayoutable)
- {
- mIsLayoutable = isLayoutable;
- }
- /**
- * Returns the isComposite.
- * @return boolean
- */
- public boolean getIsComposite()
- {
- return mIsComposite;
- }
- /**
- * Sets the isComposite.
- * @param isComposite The isComposite to set
- */
- public void setIsComposite(boolean isComposite)
- {
- 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);
- graphableVertex.setParent(this);
- }
- /**
- * Returns the childrenGraph.
- * @return GraphModel
- */
- public GraphModel getChildrenGraphModel()
- {
- return mChildrenGraphModel;
- }
- /**
- * Sets the childrenGraph.
- * @param childrenGraph The childrenGraph to set
- */
- public void setChildrenGraphModel(GraphModel childrenGraph)
- {
- mChildrenGraphModel = childrenGraph;
- DirectedEdge[] edges = mChildrenGraphModel.getEdges();
- GraphableVertex[] graphables = this.getLayoutableChildren();
- if (graphables != null)
- for (GraphableVertex graphable : graphables)
- graphable.setParent(this);
- if (edges != null)
- for (DirectedEdge edge : edges)
- ((GraphableEdge) edge).setParent(this);
- childrenGraph.setContainingVertex(this);
- }
-
- /**
- * @see com.c2kernel.graph.model.Vertex#getCentrePoint()
- */
- @Override
- public GraphPoint getCentrePoint()
- {
- if (!getIsLayoutable())
- return null;
- return super.getCentrePoint();
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#getInEdgeIds()
- */
- @Override
- public int[] getInEdgeIds()
- {
- if (!getIsLayoutable())
- return null;
- return super.getInEdgeIds();
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#getOutEdgeIds()
- */
- @Override
- public int[] getOutEdgeIds()
- {
- if (!getIsLayoutable())
- return null;
- return super.getOutEdgeIds();
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#getOutlinePoints()
- */
- @Override
- public GraphPoint[] getOutlinePoints()
- {
- if (!getIsLayoutable())
- return null;
- return super.getOutlinePoints();
- }
- public String getPath()
- {
- if (getName() != null && !getName().equals(""))
- return getParent().getPath() + "/" + getName();
- return getParent().getPath() + "/" + getID();
- }
-} \ No newline at end of file
diff --git a/source/com/c2kernel/graph/model/Selection.java b/source/com/c2kernel/graph/model/Selection.java
deleted file mode 100755
index dcc7b46..0000000
--- a/source/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/source/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java b/source/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java
deleted file mode 100644
index e5b6c3d..0000000
--- a/source/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.c2kernel.graph.model;
-
-import java.io.Serializable;
-
-
-public class TypeNameAndConstructionInfo implements Serializable
-{
- public String mName = null;
- public Object mInfo = null;
-
-
- public TypeNameAndConstructionInfo(String name, Object info)
- {
- mName = name;
- mInfo = info;
- }
-
-
- @Override
- public String toString()
- {
- return mName;
- }
-}
diff --git a/source/com/c2kernel/graph/model/Vertex.java b/source/com/c2kernel/graph/model/Vertex.java
deleted file mode 100644
index ccef437..0000000
--- a/source/com/c2kernel/graph/model/Vertex.java
+++ /dev/null
@@ -1,308 +0,0 @@
-package com.c2kernel.graph.model;
-
-import java.awt.Polygon;
-import java.io.Serializable;
-import java.util.Vector;
-
-
-public class Vertex implements Serializable
-{
- private int mId = -1;
- private String mName = "";
- private GraphPoint mCentrePoint = new GraphPoint(0, 0);
- private int mHeight = 0;
- private int mWidth = 0;
- private Vector<Integer> mInEdgeIdVector = new Vector<Integer>();
- private Vector<Integer> mOutEdgeIdVector = new Vector<Integer>();
- private Vector<Object> mTags = new Vector<Object>();
-
- // The Java Polygon class is used to determine if a point
- // lies within the outline of a vertex. Unfortunately
- // both the polygon and the set of outline points need to
- // kept in memory because a polygon never has 0 points
- // which is required by Castor's unmarshall object mechanism
- private Polygon mOutlinePolygon = new Polygon();
- private GraphPoint[] mOutlinePoints = new GraphPoint[0];
-
-
- private GraphModel graphModel;
-
- public void setID(int id)
- {
- mId = id;
- }
-
-
- public int getID()
- {
- return mId;
- }
-
-
- public void setName(String n)
- {
- mName = n;
- }
-
-
- public String getName()
- {
- return mName;
- }
-
-
- public void setCentrePoint(GraphPoint p)
- {
- mCentrePoint = p;
- }
-
-
- public GraphPoint getCentrePoint()
- {
- return mCentrePoint;
- }
-
-
- public void setHeight(int h)
- {
- mHeight = h;
- }
-
-
- public int getHeight()
- {
- return mHeight;
- }
-
-
- public void setWidth(int w)
- {
- mWidth = w;
- }
-
-
- public int getWidth()
- {
- return mWidth;
- }
-
-
- // Sets the outline points and re-calculates the
- // height and width
- public void setOutlinePoints(GraphPoint[] outline)
- {
- int topLeftX = outline[0].x;
- int topLeftY = outline[0].y;
- int bottomRightX = 0;
- int bottomRightY = 0;
- int i = 0;
-
- mOutlinePoints = outline;
-
- // Construct a polygon in the outline of the vertex
- // and calculate the top left and bottom right corners
- mOutlinePolygon = new Polygon();
-
- for(i=0; i<outline.length; i++)
- {
- mOutlinePolygon.addPoint(outline[i].x, outline[i].y);
-
- if(outline[i].x < topLeftX)
- {
- topLeftX = outline[i].x;
- }
-
- if(outline[i].y < topLeftY)
- {
- topLeftY = outline[i].y;
- }
-
- if(outline[i].x > bottomRightX)
- {
- bottomRightX = outline[i].x;
- }
-
-
- if(outline[i].y > bottomRightY)
- {
- bottomRightY = outline[i].y;
- }
- }
-
- // Set the height and width
- mHeight = bottomRightY - topLeftY;
- mWidth = bottomRightX - topLeftX;
- }
-
-
- public GraphPoint[] getOutlinePoints()
- {
- return mOutlinePoints;
- }
-
- public void moveAbsolute(GraphPoint p)
- {
- int deltaX = p.x - mCentrePoint.x;
- int deltaY = p.y - mCentrePoint.y;
- int i = 0;
-
- // Update the outline points and the polygon
- for(i=0; i<mOutlinePoints.length; i++)
- {
- mOutlinePoints[i].x += deltaX;
- mOutlinePoints[i].y += deltaY;
- }
-
- mOutlinePolygon.translate(deltaX, deltaY);
-
- mCentrePoint.x = p.x;
- mCentrePoint.y = p.y;
- }
-
-
- public boolean containsPoint(GraphPoint p)
- {
- return mOutlinePolygon.contains(p.x, p.y);
- }
-
-
- public void setInEdgeIds(int[] ids)
- {
- int i = 0;
-
- mInEdgeIdVector = new Vector<Integer>(10, 10);
- for(i=0; i<ids.length; i++)
- mInEdgeIdVector.add(new Integer(ids[i]));
- }
-
-
- public int[] getInEdgeIds()
- {
- return integerVectorToIntArray(mInEdgeIdVector);
- }
-
-
- public void setOutEdgeIds(int[] ids)
- {
- int i = 0;
-
- mOutEdgeIdVector = new Vector<Integer>(10, 10);
- for(i=0; i<ids.length; i++)
- mOutEdgeIdVector.add(new Integer(ids[i]));
- }
-
-
- public int[] getOutEdgeIds()
- {
- return integerVectorToIntArray(mOutEdgeIdVector);
- }
-
-
- private static int[] integerVectorToIntArray(Vector<Integer> vector)
- {
- int[] array = new int[vector.size()];
- Integer integer = null;
- int i = 0;
-
- for(i=0; i<array.length; i++)
- {
- integer = vector.elementAt(i);
- array[i] = integer.intValue();
- }
-
- return array;
- }
-
-
- public void addInEdgeId(int id)
- {
- mInEdgeIdVector.add(new Integer(id));
- }
-
-
- public void removeInEdgeId(int id)
- {
- Integer integer = null;
- int i = 0;
-
- for(i=0; i<mInEdgeIdVector.size(); i++)
- {
- integer = mInEdgeIdVector.elementAt(i);
-
- if(integer.intValue() == id)
- {
- mInEdgeIdVector.removeElementAt(i);
- return;
- }
- }
- }
-
-
- public void addOutEdgeId(int id)
- {
- mOutEdgeIdVector.add(new Integer(id));
- }
-
-
- public void removeOutEdgeId(int id)
- {
- Integer integer = null;
- int i = 0;
-
- for(i=0; i<mOutEdgeIdVector.size(); i++)
- {
- integer = mOutEdgeIdVector.elementAt(i);
-
- if(integer.intValue() == id)
- {
- mOutEdgeIdVector.removeElementAt(i);
- return;
- }
- }
- }
-
-
- public void setTag(Object o)
- {
- mTags.add(o);
- }
-
-
- public boolean hasTag(Object o)
- {
- return mTags.contains(o);
- }
-
- public void clearTag(Object o)
- {
- mTags.remove(o);
- }
-
-
- public GraphModel getChildGraphModel() {
- return null;
- }
-
- public Object getCreationContext() {
- return null;
- }
-
-
- public GraphModel getGraphModel()
- {
- return graphModel;
- }
-
- public void setGraphModel(GraphModel graphModel)
- {
- this.graphModel = graphModel;
- }
-
- public boolean isJoin() {
- return false;
- }
- public boolean isLoop() {
- return false;
- }
-
-}
diff --git a/source/com/c2kernel/graph/model/VertexFactory.java b/source/com/c2kernel/graph/model/VertexFactory.java
deleted file mode 100644
index 550367e..0000000
--- a/source/com/c2kernel/graph/model/VertexFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.c2kernel.graph.model;
-
-import java.awt.Point;
-
-
-public interface VertexFactory
-{
- public void create
- (
- GraphModelManager graphModelManager,
- Point location,
- TypeNameAndConstructionInfo typeNameAndConstructionInfo
- );
-
- public void setCreationContext(Object newContext);
-}
diff --git a/source/com/c2kernel/graph/model/VertexOutlineCreator.java b/source/com/c2kernel/graph/model/VertexOutlineCreator.java
deleted file mode 100755
index 627395e..0000000
--- a/source/com/c2kernel/graph/model/VertexOutlineCreator.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.c2kernel.graph.model;
-
-
-
-// Classes that implement this interface must
-// have a parameter less constructor
-public interface VertexOutlineCreator
-{
- public void setOutline(Vertex vertex);
-}