Search in sources :

Example 21 with GraphPoint

use of org.cristalise.kernel.graph.model.GraphPoint 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)

Example 22 with GraphPoint

use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.

the class DefaultGraphLayoutGenerator method fillInVertexLocations.

private static void fillInVertexLocations(GraphModel graphModel, Vector<Vector<Vertex>> rowVector, int valueOfLargestMidPoint, int[] midPoints) {
    Vector<Vertex> rowsVertices = null;
    Vertex vertex = null;
    int rowIndex = 0;
    int column = 0;
    int rowsLeftMargin = 0;
    GraphPoint point = new GraphPoint(0, 0);
    for (rowIndex = 0; rowIndex < rowVector.size(); rowIndex++) {
        rowsVertices = rowVector.elementAt(rowIndex);
        rowsLeftMargin = mLeftMargin + valueOfLargestMidPoint - midPoints[rowIndex];
        for (column = 0; column < rowsVertices.size(); column++) {
            vertex = rowsVertices.elementAt(column);
            point.x = rowsLeftMargin + column * mHorzGap;
            point.y = mTopMargin + rowIndex * mVertGap;
            vertex.moveAbsolute(point);
            graphModel.checkSize(vertex);
        }
    }
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 23 with GraphPoint

use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.

the class CompositeActivity method safeAddChild.

/**
 * Adds vertex to graph cloning GraphPoint first (NPE safe)
 *
 * @param v
 * @param g
 */
private void safeAddChild(GraphableVertex v, GraphPoint g) {
    GraphPoint p = null;
    if (g != null)
        p = new GraphPoint(g.x, g.y);
    addChild(v, p);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 24 with GraphPoint

use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.

the class AggregationMemberRenderer method draw.

@Override
public void draw(Graphics2D g2d, Vertex vertex) {
    GraphPoint centre = vertex.getCentrePoint();
    GraphPoint[] outline = vertex.getOutlinePoints();
    FontMetrics metrics = g2d.getFontMetrics();
    AggregationMember memberPair = mAggregation.getMemberPair(vertex.getID());
    try {
        String name = memberPair.getItemName();
        g2d.drawString(name, centre.x - metrics.stringWidth(name) / 2, vertex.getID() % 2 == 0 ? topYOfOutline(outline) : bottomYOfOutline(outline) + metrics.getHeight());
        g2d.drawImage(getImage(memberPair), centre.x - 8, centre.y - 8, null);
        // Draw the outline of the vertex
        if (outline.length > 1) {
            for (int i = 0; i < outline.length - 1; i++) {
                g2d.drawLine(outline[i].x, outline[i].y, outline[i + 1].x, outline[i + 1].y);
            }
            g2d.drawLine(outline[outline.length - 1].x, outline[outline.length - 1].y, outline[0].x, outline[0].y);
        }
    } catch (Exception ex) {
        Logger.error("AggregationMemberRenderer::draw() " + ex);
    }
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) FontMetrics(java.awt.FontMetrics) AggregationMember(org.cristalise.kernel.collection.AggregationMember) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 25 with GraphPoint

use of org.cristalise.kernel.graph.model.GraphPoint in project kernel by cristal-ise.

the class LifecycleRenderer method drawVertexHighlight.

// Draws the highlight of the specified vertex the specified dist from its outline
protected void drawVertexHighlight(Graphics2D g2d, Vertex vertex, int dist) {
    GraphPoint[] outlinePoints = vertex.getOutlinePoints();
    GraphPoint centrePoint = vertex.getCentrePoint();
    /*
         * float dash1[] ={5.0f}; BasicStroke bs = new BasicStroke(5.0f, BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,10.0f, dash1,0.0f);
         */
    for (int i = 0; i < outlinePoints.length - 1; i++) {
        drawShiftedLine(dist, g2d, centrePoint, outlinePoints[i].x, outlinePoints[i].y, outlinePoints[i + 1].x, outlinePoints[i + 1].y);
    }
    drawShiftedLine(dist, g2d, centrePoint, outlinePoints[outlinePoints.length - 1].x, outlinePoints[outlinePoints.length - 1].y, outlinePoints[0].x, outlinePoints[0].y);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Aggregations

GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)25 AffineTransform (java.awt.geom.AffineTransform)4 FontMetrics (java.awt.FontMetrics)3 Vertex (org.cristalise.kernel.graph.model.Vertex)3 Paint (java.awt.Paint)2 Aggregation (org.cristalise.kernel.collection.Aggregation)1 AggregationDescription (org.cristalise.kernel.collection.AggregationDescription)1 AggregationInstance (org.cristalise.kernel.collection.AggregationInstance)1 AggregationMember (org.cristalise.kernel.collection.AggregationMember)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 PersistencyException (org.cristalise.kernel.common.PersistencyException)1 DirectedEdge (org.cristalise.kernel.graph.model.DirectedEdge)1 GraphableEdge (org.cristalise.kernel.graph.model.GraphableEdge)1 Activity (org.cristalise.kernel.lifecycle.instance.Activity)1 CompositeActivity (org.cristalise.kernel.lifecycle.instance.CompositeActivity)1 Next (org.cristalise.kernel.lifecycle.instance.Next)1 Workflow (org.cristalise.kernel.lifecycle.instance.Workflow)1 DomainPath (org.cristalise.kernel.lookup.DomainPath)1 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)1 ItemPath (org.cristalise.kernel.lookup.ItemPath)1