use of org.cristalise.kernel.graph.model.DirectedEdge 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.DirectedEdge in project kernel by cristal-ise.
the class OrSplit method runNext.
@Override
public void runNext(AgentPath agent, ItemPath itemPath, Object locker) throws InvalidDataException {
String[] nextsTab = calculateNexts(itemPath, locker);
int active = 0;
DirectedEdge[] outEdges = getOutEdges();
for (String thisNext : nextsTab) {
Logger.msg(7, "OrSplit.runNext() - Finding next " + thisNext);
for (DirectedEdge outEdge : outEdges) {
Next nextEdge = (Next) outEdge;
if (thisNext != null && thisNext.equals(nextEdge.getBuiltInProperty(ALIAS))) {
WfVertex term = nextEdge.getTerminusVertex();
try {
term.run(agent, itemPath, locker);
} catch (InvalidDataException e) {
Logger.error(e);
throw new InvalidDataException("Error enabling next " + thisNext);
}
Logger.msg(7, "OrSplit.runNext() - Running " + nextEdge.getBuiltInProperty(ALIAS));
active++;
}
}
}
// if no active nexts throw exception
if (active == 0)
throw new InvalidDataException("No nexts were activated!");
}
use of org.cristalise.kernel.graph.model.DirectedEdge in project kernel by cristal-ise.
the class XOrSplit method runNext.
@Override
public void runNext(AgentPath agent, ItemPath itemPath, Object locker) throws InvalidDataException {
String[] nextsTab = calculateNexts(itemPath, locker);
ArrayList<DirectedEdge> nextsToFollow = new ArrayList<DirectedEdge>();
DirectedEdge[] outEdges = getOutEdges();
for (DirectedEdge outEdge : outEdges) {
if (isInTable((String) ((Next) outEdge).getBuiltInProperty(ALIAS), nextsTab))
nextsToFollow.add(outEdge);
}
if (nextsToFollow.size() != 1)
throw new InvalidDataException("not good number of active next");
followNext((Next) nextsToFollow.get(0), agent, itemPath, locker);
}
use of org.cristalise.kernel.graph.model.DirectedEdge in project kernel by cristal-ise.
the class DefaultGraphLayoutGenerator method fillInEdgeLocations.
private static void fillInEdgeLocations(GraphModel graphModel) {
Vertex[] vertices = graphModel.getVertices();
GraphPoint centrePoint = null;
DirectedEdge[] inEdges = null;
DirectedEdge[] outEdges = null;
int i = 0;
int j = 0;
for (i = 0; i < vertices.length; i++) {
centrePoint = vertices[i].getCentrePoint();
inEdges = graphModel.getInEdges(vertices[i]);
outEdges = graphModel.getOutEdges(vertices[i]);
for (j = 0; j < inEdges.length; j++) {
inEdges[j].setTerminusPoint(centrePoint);
}
for (j = 0; j < outEdges.length; j++) {
outEdges[j].setOriginPoint(centrePoint);
}
}
}
Aggregations