Search in sources :

Example 1 with Vertex

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

Example 2 with Vertex

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

Example 3 with Vertex

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

Example 4 with Vertex

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

Example 5 with Vertex

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

Aggregations

Vertex (org.cristalise.kernel.graph.model.Vertex)14 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)7 WfVertex (org.cristalise.kernel.lifecycle.instance.WfVertex)3 DirectedEdge (org.cristalise.kernel.graph.model.DirectedEdge)2 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)1 InvalidCollectionModification (org.cristalise.kernel.common.InvalidCollectionModification)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 BuiltInVertexProperties (org.cristalise.kernel.graph.model.BuiltInVertexProperties)1 GraphableVertex (org.cristalise.kernel.graph.model.GraphableVertex)1 PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)1 CastorHashMap (org.cristalise.kernel.utils.CastorHashMap)1 KeyValuePair (org.cristalise.kernel.utils.KeyValuePair)1