diff options
Diffstat (limited to 'source/com/c2kernel/graph/model/GraphableVertex.java')
| -rw-r--r-- | source/com/c2kernel/graph/model/GraphableVertex.java | 261 |
1 files changed, 0 insertions, 261 deletions
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 |
