Search in sources :

Example 16 with GraphPoint

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

the class DefaultDirectedEdgeRenderer method drawBrokenPipeWithArrow.

/**
 * Draw a line of 2 segments (vertical, horizontal) between origin and terminus point
 *
 * @param g2d the canvas
 * @param directedEdge edge to be drawn
 */
private void drawBrokenPipeWithArrow(Graphics2D g2d, DirectedEdge directedEdge) {
    GraphPoint originPoint = directedEdge.getOriginPoint();
    GraphPoint terminusPoint = directedEdge.getTerminusPoint();
    g2d.drawLine(originPoint.x, originPoint.y, originPoint.x, terminusPoint.y);
    g2d.drawLine(originPoint.x, terminusPoint.y, terminusPoint.x, terminusPoint.y);
    boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
    GraphPoint midPoint = new GraphPoint();
    midPoint.x = arrowOnY ? originPoint.x : (originPoint.x + terminusPoint.x) / 2;
    midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : terminusPoint.y;
    // Draw the transformed arrow
    AffineTransform transform = new AffineTransform();
    transform.translate(midPoint.x, midPoint.y);
    transform.rotate(calcArrowAngle(arrowOnY ? terminusPoint.x : originPoint.x, arrowOnY ? originPoint.y : originPoint.y, arrowOnY ? terminusPoint.x : terminusPoint.x, arrowOnY ? terminusPoint.y : originPoint.y));
    g2d.draw(mArrowTemplate.createTransformedShape(transform));
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) AffineTransform(java.awt.geom.AffineTransform)

Example 17 with GraphPoint

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

the class LifecycleVertexOutlineCreator method setOutline.

@Override
public void setOutline(Vertex vertex) {
    GraphPoint centrePoint = vertex.getCentrePoint();
    GraphPoint[] outlinePoints = new GraphPoint[4];
    int vertexWidth = 0;
    int vertexHeight = 0;
    if (vertex instanceof Activity || vertex instanceof ActivitySlotDef || vertex instanceof ActivityDef) {
        vertexWidth = mActivityWidth;
        vertexHeight = mActivityHeight;
    } else {
        vertexWidth = mSplitJoinWidth;
        vertexHeight = mSplitJoinHeight;
    }
    outlinePoints[0] = new GraphPoint(centrePoint.x - vertexWidth / 2, centrePoint.y - vertexHeight / 2);
    outlinePoints[1] = new GraphPoint(centrePoint.x + vertexWidth / 2, centrePoint.y - vertexHeight / 2);
    outlinePoints[2] = new GraphPoint(centrePoint.x + vertexWidth / 2, centrePoint.y + vertexHeight / 2);
    outlinePoints[3] = new GraphPoint(centrePoint.x - vertexWidth / 2, centrePoint.y + vertexHeight / 2);
    vertex.setOutlinePoints(outlinePoints);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) Activity(org.cristalise.kernel.lifecycle.instance.Activity) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 18 with GraphPoint

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

the class DefaultVertexRenderer method drawOutline3DRect.

/**
 * Fills the outline as 3D rectangle. It draws the border of the outline if linePaint is not null
 *
 * @param g2d the canvas
 * @param vertex the vertex to be drawn
 * @param fillPaint the fill color
 * @param linePaint the color of the line, can be null
 */
public void drawOutline3DRect(Graphics2D g2d, Vertex vertex, Paint fillPaint, Paint linePaint) {
    GraphPoint centrePoint = vertex.getCentrePoint();
    g2d.setPaint(fillPaint);
    g2d.fill3DRect(centrePoint.x - vertex.getWidth() / 2, centrePoint.y - vertex.getHeight() / 2, vertex.getWidth(), vertex.getHeight(), true);
    if (linePaint != null) {
        g2d.setPaint(linePaint);
        g2d.draw3DRect(centrePoint.x - vertex.getWidth() / 2, centrePoint.y - vertex.getHeight() / 2, vertex.getWidth(), vertex.getHeight(), true);
    }
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 19 with GraphPoint

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

the class DefaultVertexRenderer method drawLinesOfTexts.

/**
 * Draw lines of text within the boundaries of the vertex
 *
 * @param g2d the canvas
 * @param vertex the vertex for which the text to be drawn
 * @param linesOfText lines of the text
 * @param textPaint the color of the text
 */
public void drawLinesOfTexts(Graphics2D g2d, Vertex vertex, ArrayList<String> linesOfText, Paint textPaint) {
    g2d.setPaint(textPaint);
    GraphPoint centrePoint = vertex.getCentrePoint();
    FontMetrics metrics = g2d.getFontMetrics();
    int lineHeight = metrics.getHeight();
    int linesHeight = lineHeight * linesOfText.size();
    int linesStartY = centrePoint.y - linesHeight / 2 + lineHeight * 2 / 3;
    int i = 0;
    for (String line : linesOfText) {
        if (line == null)
            line = "";
        int lineWidth = metrics.stringWidth(line);
        int x = centrePoint.x - lineWidth / 2;
        int y = linesStartY + i++ * lineHeight;
        g2d.drawString(line, x, y);
    }
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) FontMetrics(java.awt.FontMetrics) Paint(java.awt.Paint) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 20 with GraphPoint

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

the class DefaultVertexRenderer method drawText.

/**
 * Draw the text within the boundaries of the vertex
 *
 * @param g2d the canvas
 * @param vertex the vertex in which the text is drawn
 * @param text the text to draw
 * @param textPaint the color of the text
 */
public void drawText(Graphics2D g2d, Vertex vertex, String text, Paint textPaint) {
    GraphPoint centrePoint = vertex.getCentrePoint();
    FontMetrics metrics = g2d.getFontMetrics();
    int textWidth = metrics.stringWidth(text);
    int textHeight = metrics.getHeight();
    int textX = centrePoint.x - textWidth / 2;
    int textY = centrePoint.y + textHeight / 3;
    g2d.setPaint(textPaint);
    g2d.drawString(text, textX, textY);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) FontMetrics(java.awt.FontMetrics) Paint(java.awt.Paint) 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