Search in sources :

Example 1 with DirectedEdge

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);
}
Also used : DirectedEdge(org.cristalise.kernel.graph.model.DirectedEdge) Vertex(org.cristalise.kernel.graph.model.Vertex) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 2 with DirectedEdge

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!");
}
Also used : DirectedEdge(org.cristalise.kernel.graph.model.DirectedEdge) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 3 with DirectedEdge

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);
}
Also used : DirectedEdge(org.cristalise.kernel.graph.model.DirectedEdge) ArrayList(java.util.ArrayList) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 4 with DirectedEdge

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);
        }
    }
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex) DirectedEdge(org.cristalise.kernel.graph.model.DirectedEdge) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Aggregations

DirectedEdge (org.cristalise.kernel.graph.model.DirectedEdge)4 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)2 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)2 Vertex (org.cristalise.kernel.graph.model.Vertex)2 ArrayList (java.util.ArrayList)1