use of org.cristalise.kernel.graph.model.Vertex in project kernel by cristal-ise.
the class DefaultGraphLayoutGenerator method calculateRowMidPoints.
private static int calculateRowMidPoints(Vector<Vector<Vertex>> rowVector, int[] midPoints, int valueOfLargestMidPoint) {
Vector<Vertex> rowsVertices = null;
int newValueOfLargestMidPoint = valueOfLargestMidPoint;
int rowsWidth = 0;
int i = 0;
for (i = 0; i < midPoints.length; i++) {
rowsVertices = rowVector.elementAt(i);
rowsWidth = mHorzGap * (rowsVertices.size() - 1);
midPoints[i] = rowsWidth / 2;
if (midPoints[i] > newValueOfLargestMidPoint) {
newValueOfLargestMidPoint = midPoints[i];
}
}
return newValueOfLargestMidPoint;
}
use of org.cristalise.kernel.graph.model.Vertex in project kernel by cristal-ise.
the class DefaultGraphLayoutGenerator method layoutGraph.
public static void layoutGraph(GraphModel graphModel) {
Vertex start = graphModel.getStartVertex();
Vector<Vector<Vertex>> rowVector = new Vector<Vector<Vertex>>(10, 10);
int[] midPoints = null;
int valueOfLargestMidPoint = 0;
if (start == null) {
Logger.msg(1, "Error graph must have a starting vertex to be layed out");
return;
}
graphModel.clearTags(start);
visitVertex(graphModel, start, 0, rowVector, start);
midPoints = new int[rowVector.size()];
valueOfLargestMidPoint = calculateRowMidPoints(rowVector, midPoints, valueOfLargestMidPoint);
fillInVertexLocations(graphModel, rowVector, valueOfLargestMidPoint, midPoints);
fillInEdgeLocations(graphModel);
graphModel.forceNotify();
}
use of org.cristalise.kernel.graph.model.Vertex in project kernel by cristal-ise.
the class Aggregation method addSlot.
public AggregationMember addSlot(CastorHashMap props, String classProps, GraphPoint location, int w, int h) {
// Default geometry if not present
if (location == null)
location = new GraphPoint(100, 100 * getCounter());
if (w < 0)
w = 20;
if (h < 0)
h = 20;
// Create new member object
AggregationMember aggMem = new AggregationMember();
aggMem.setProperties(props);
aggMem.setClassProps(classProps);
// create vertex
Vertex vertex = new Vertex();
vertex.setHeight(h);
vertex.setWidth(w);
mLayout.addVertexAndCreateId(vertex, location);
aggMem.setCollection(this);
aggMem.setID(vertex.getID());
aggMem.setIsLayoutable(true);
mMembers.list.add(aggMem);
Logger.msg(8, "AggregationDescription::addSlot new slot linked to vertexid " + vertex.getID());
return aggMem;
}
use of org.cristalise.kernel.graph.model.Vertex in project kernel by cristal-ise.
the class LifecycleRenderer method draw.
public void draw(Graphics2D g2d) {
if (mGraphModel == null) {
Logger.warning("LifecycleGenerator.draw() - GraphModel is NULL!");
return;
}
DirectedEdge[] edges = mGraphModel.getEdges();
Vertex[] vertices = mGraphModel.getVertices();
// Draw the edges
for (int i = 0; i < edges.length; i++) mDirectedEdgeRenderer.draw(g2d, edges[i]);
// Draw the vertices
for (int i = 0; i < vertices.length; i++) mVertexRenderer.draw(g2d, vertices[i]);
g2d.setPaint(Color.green);
// Highlight the start vertex if there is one
Vertex startVertex = mGraphModel.getStartVertex();
if (startVertex != null)
drawVertexHighlight(g2d, startVertex, 1);
}
use of org.cristalise.kernel.graph.model.Vertex in project kernel by cristal-ise.
the class GraphTraversal method visitVertex.
private static void visitVertex(Vertex vertex, GraphModel graphModel, Vector<Vertex> path, int direction, Object tag, boolean ignoreBackLinks) {
Vertex[] children = null;
int i = 0;
if (direction == kDown) {
children = graphModel.getOutVertices(vertex);
} else {
children = graphModel.getInVertices(vertex);
}
vertex.setTag(tag);
path.add(vertex);
for (i = 0; i < children.length; i++) {
if (!(children[i].hasTag(tag))) {
boolean skipBackLink = false;
if (ignoreBackLinks && ((vertex.isJoin() && direction == kUp) || (vertex.isLoop() && direction == kDown))) {
Vertex[] following = getTraversal(graphModel, children[i], direction, false);
for (Vertex element : following) {
if (element == vertex) {
skipBackLink = true;
break;
}
}
}
if (!skipBackLink)
visitVertex(children[i], graphModel, path, direction, tag, ignoreBackLinks);
}
}
}
Aggregations