summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/graph/model
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-10-07 09:18:11 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-10-07 09:18:11 +0200
commit0ed2c1124cf1b9e49a2ec1fa0126a8df09f9e758 (patch)
treee3a56cee83865f8c703deb790c15d3e79e871a82 /src/main/java/com/c2kernel/graph/model
parent50aa8aaab42fa62267aa1ae6a6070013096f5082 (diff)
Repackage to org.cristalise
Diffstat (limited to 'src/main/java/com/c2kernel/graph/model')
-rw-r--r--src/main/java/com/c2kernel/graph/model/DirectedEdge.java118
-rw-r--r--src/main/java/com/c2kernel/graph/model/EdgeFactory.java34
-rw-r--r--src/main/java/com/c2kernel/graph/model/GraphModel.java543
-rw-r--r--src/main/java/com/c2kernel/graph/model/GraphModelCastorData.java50
-rw-r--r--src/main/java/com/c2kernel/graph/model/GraphModelManager.java156
-rw-r--r--src/main/java/com/c2kernel/graph/model/GraphPoint.java37
-rw-r--r--src/main/java/com/c2kernel/graph/model/Graphable.java75
-rw-r--r--src/main/java/com/c2kernel/graph/model/GraphableEdge.java91
-rw-r--r--src/main/java/com/c2kernel/graph/model/GraphableVertex.java283
-rw-r--r--src/main/java/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java43
-rw-r--r--src/main/java/com/c2kernel/graph/model/Vertex.java327
-rw-r--r--src/main/java/com/c2kernel/graph/model/VertexFactory.java33
-rw-r--r--src/main/java/com/c2kernel/graph/model/VertexOutlineCreator.java30
13 files changed, 0 insertions, 1820 deletions
diff --git a/src/main/java/com/c2kernel/graph/model/DirectedEdge.java b/src/main/java/com/c2kernel/graph/model/DirectedEdge.java
deleted file mode 100644
index 7de85d3..0000000
--- a/src/main/java/com/c2kernel/graph/model/DirectedEdge.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-
-
-
-public abstract class DirectedEdge
-{
- // 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/src/main/java/com/c2kernel/graph/model/EdgeFactory.java b/src/main/java/com/c2kernel/graph/model/EdgeFactory.java
deleted file mode 100644
index 402e8b7..0000000
--- a/src/main/java/com/c2kernel/graph/model/EdgeFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-
-
-public interface EdgeFactory
-{
- public void create
- (
- GraphModelManager graphModelManager,
- Vertex origin,
- Vertex terminus,
- TypeNameAndConstructionInfo typeNameAndConstructionInfo
- );
-}
diff --git a/src/main/java/com/c2kernel/graph/model/GraphModel.java b/src/main/java/com/c2kernel/graph/model/GraphModel.java
deleted file mode 100644
index d2d39d9..0000000
--- a/src/main/java/com/c2kernel/graph/model/GraphModel.java
+++ /dev/null
@@ -1,543 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-import java.util.Hashtable;
-
-import com.c2kernel.graph.event.ClearedEvent;
-import com.c2kernel.graph.event.EdgeRemovedEvent;
-import com.c2kernel.graph.event.EdgesChangedEvent;
-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.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 {
- /* Persistent 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 */
-
- protected transient Vertex mNewEdgeOriginVertex = null;
- protected transient GraphPoint mNewEdgeEndPoint = null;
-
- private transient GraphModelManager mManager = null;
-
- /* External factories */
-
- private VertexFactory mExternalVertexFactory = null;
- private EdgeFactory mExternalEdgeFactory = null;
-
- /* Vertex outline creator */
-
- private VertexOutlineCreator mVertexOutlineCreator = null;
-
- /* Notification Events */
-
- private final ClearedEvent mClearedEvent = new ClearedEvent();
- private final EdgeRemovedEvent mEdgeRemovedEvent = new EdgeRemovedEvent();
- private final EdgesChangedEvent mEdgesChangedEvent = new EdgesChangedEvent();
- private final ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent();
- private final NewEdgeEndPointChangedEvent mNewEdgeEndPointChangedEvent = new NewEdgeEndPointChangedEvent();
- 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 VertexRemovedEvent mVertexRemovedEvent = new VertexRemovedEvent();
- private final VerticesChangedEvent mVerticesChangedEvent = new VerticesChangedEvent();
- private final 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;
- }
-
- 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) {
- publishEvent(mGraphModelResizedEvent);
- }
-
- }
-
- public void setStartVertexId(int id) {
- mStartVertexId = id;
- publishEvent(mStartVertexIdChangedEvent);
- }
-
- 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);
-
- }
- publishEvent(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);
- }
- publishEvent(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;
- }
-
- public Vertex getVertexById(int id) {
- return mVertexHashtable.get(String.valueOf(id));
- }
-
-
- 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()));
- publishEvent(mEdgeRemovedEvent);
- }
-
- 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);
- }
- publishEvent(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()));
- publishEvent(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);
- publishEvent(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 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() {
- publishEvent(mForcedNotifyEvent);
- }
-
- public void clear() {
- mVertexHashtable = new Hashtable<String, Vertex>();
- mEdgeHashtable = new Hashtable<String, DirectedEdge>();
- mStartVertexId = -1;
- publishEvent(mClearedEvent);
- }
-
-
-
- public void setNewEdgeOriginVertex(Vertex v) {
- mNewEdgeOriginVertex = v;
- }
-
- public Vertex getNewEdgeOriginVertex() {
- return mNewEdgeOriginVertex;
- }
-
- public void setNewEdgeEndPoint(GraphPoint p) {
- mNewEdgeEndPoint = p;
- publishEvent(mNewEdgeEndPointChangedEvent);
- }
-
- public GraphPoint getNewEdgeEndPoint() {
- return mNewEdgeEndPoint;
- }
-
- public void setExternalVertexFactory(VertexFactory factory) {
- mExternalVertexFactory = factory;
- }
-
- public void createVertex(GraphPoint location, TypeNameAndConstructionInfo typeNameAndConstructionInfo) throws Exception {
- if (mExternalVertexFactory != null) {
- mExternalVertexFactory.create(mManager, location, typeNameAndConstructionInfo);
- publishEvent(mVertexCreatedEvent);
- }
- }
-
- private void publishEvent(GraphModelEvent event) {
- if (mManager!=null)
- mManager.notifyObservers(event);
-
- }
-
- 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 resetVertexOutlines() {
- Vertex[] vertices = getVertices();
- int i = 0;
- for (i = 0; i < vertices.length; i++) {
- mVertexOutlineCreator.setOutline(vertices[i]);
- }
- }
-
- public void setGraphModelCastorData(GraphModelCastorData data) {
- int i = 0;
-
- // 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];
- }
- // Disable persistency of the vertex outline creator: determined by container
- // 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/src/main/java/com/c2kernel/graph/model/GraphModelCastorData.java b/src/main/java/com/c2kernel/graph/model/GraphModelCastorData.java
deleted file mode 100644
index e0c0c84..0000000
--- a/src/main/java/com/c2kernel/graph/model/GraphModelCastorData.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-
-public class GraphModelCastorData
-{
- // Deprecated: Vertex outline creator is now set by the container
- 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/src/main/java/com/c2kernel/graph/model/GraphModelManager.java b/src/main/java/com/c2kernel/graph/model/GraphModelManager.java
deleted file mode 100644
index a4209ce..0000000
--- a/src/main/java/com/c2kernel/graph/model/GraphModelManager.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-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 final EntireModelChangedEvent mEntireModelChangedEvent = new EntireModelChangedEvent();
- private final ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent();
- private final Stack<GraphModel> mParentModels = new Stack<GraphModel>();
- private final 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.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
- notifyObservers(mEntireModelChangedEvent);
- }
-
- public void zoomIn(Vertex child) {
- GraphModel childModel = child.getChildGraphModel();
- if (childModel != null) {
- mParentModels.push(mGraphModel);
- mParentIds.add(Integer.valueOf(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()
- {
- 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);
- }
-
- public void notifyObservers(GraphModelEvent ev) {
- setChanged();
- super.notifyObservers(ev);
- }
-
- public void setEditable(boolean editable) {
- mEditable = editable;
- }
-
- public boolean isEditable() {
- return mEditable;
- }
-
-
-}
diff --git a/src/main/java/com/c2kernel/graph/model/GraphPoint.java b/src/main/java/com/c2kernel/graph/model/GraphPoint.java
deleted file mode 100644
index dad49f9..0000000
--- a/src/main/java/com/c2kernel/graph/model/GraphPoint.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-
-public class GraphPoint {
-
- 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/src/main/java/com/c2kernel/graph/model/Graphable.java b/src/main/java/com/c2kernel/graph/model/Graphable.java
deleted file mode 100644
index b2d6573..0000000
--- a/src/main/java/com/c2kernel/graph/model/Graphable.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-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/src/main/java/com/c2kernel/graph/model/GraphableEdge.java b/src/main/java/com/c2kernel/graph/model/GraphableEdge.java
deleted file mode 100644
index 8a48056..0000000
--- a/src/main/java/com/c2kernel/graph/model/GraphableEdge.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-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/src/main/java/com/c2kernel/graph/model/GraphableVertex.java b/src/main/java/com/c2kernel/graph/model/GraphableVertex.java
deleted file mode 100644
index b90441b..0000000
--- a/src/main/java/com/c2kernel/graph/model/GraphableVertex.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-/**
-* @version $Revision: 1.24 $ $Date: 2005/10/05 07:39:37 $
-* @author $Author: abranson $
-*/
-
-
-import com.c2kernel.common.InvalidDataException;
-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;
- }
- protected Integer getVersionNumberProperty(String propName) throws InvalidDataException {
- Object val = getProperties().get(propName);
- if (val == null || val.equals("") || val.toString().equals("-1")) return null;
- try {
- return Integer.valueOf(val.toString());
- } catch (NumberFormatException ex) {
- throw new InvalidDataException("Invalid version number for property '"+propName+"': "+val.toString());
- }
- }
- 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;
- }
-
- /**@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, 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/src/main/java/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java b/src/main/java/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java
deleted file mode 100644
index f3b348a..0000000
--- a/src/main/java/com/c2kernel/graph/model/TypeNameAndConstructionInfo.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-
-
-public class TypeNameAndConstructionInfo
-{
- 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/src/main/java/com/c2kernel/graph/model/Vertex.java b/src/main/java/com/c2kernel/graph/model/Vertex.java
deleted file mode 100644
index 2aaa423..0000000
--- a/src/main/java/com/c2kernel/graph/model/Vertex.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-import java.awt.Polygon;
-import java.util.Vector;
-
-
-public class Vertex
-{
- 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 final 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(Integer.valueOf(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(Integer.valueOf(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(Integer.valueOf(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(Integer.valueOf(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/src/main/java/com/c2kernel/graph/model/VertexFactory.java b/src/main/java/com/c2kernel/graph/model/VertexFactory.java
deleted file mode 100644
index 21b5906..0000000
--- a/src/main/java/com/c2kernel/graph/model/VertexFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-public interface VertexFactory
-{
- public void create
- (
- GraphModelManager graphModelManager,
- GraphPoint location,
- TypeNameAndConstructionInfo typeNameAndConstructionInfo
- ) throws Exception;
-
- public void setCreationContext(Object newContext);
-}
diff --git a/src/main/java/com/c2kernel/graph/model/VertexOutlineCreator.java b/src/main/java/com/c2kernel/graph/model/VertexOutlineCreator.java
deleted file mode 100644
index a1680ce..0000000
--- a/src/main/java/com/c2kernel/graph/model/VertexOutlineCreator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.graph.model;
-
-
-
-// Classes that implement this interface must
-// have a parameter less constructor
-public interface VertexOutlineCreator
-{
- public void setOutline(Vertex vertex);
-}