Search in sources :

Example 6 with GraphPoint

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

the class Next method containsPoint.

@Override
public boolean containsPoint(GraphPoint p) {
    GraphPoint originPoint = getOriginPoint();
    GraphPoint terminusPoint = getTerminusPoint();
    GraphPoint midPoint = new GraphPoint();
    if (("Broken +".equals(getBuiltInProperty(TYPE)))) {
        midPoint.x = (originPoint.x + terminusPoint.x) / 2;
        midPoint.y = (originPoint.y + terminusPoint.y) / 2;
    } else if (("Broken -".equals(getBuiltInProperty(TYPE)))) {
        boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
        midPoint.x = arrowOnY ? terminusPoint.x : (originPoint.x + terminusPoint.x) / 2;
        midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : originPoint.y;
    } else if (("Broken |".equals(getBuiltInProperty(TYPE)))) {
        boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
        midPoint.x = arrowOnY ? originPoint.x : (originPoint.x + terminusPoint.x) / 2;
        midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : terminusPoint.y;
    } else {
        midPoint.x = originPoint.x + (terminusPoint.x - originPoint.x) / 2;
        midPoint.y = originPoint.y + (terminusPoint.y - originPoint.y) / 2;
    }
    int minX = midPoint.x - 10;
    int minY = midPoint.y - 10;
    int maxX = midPoint.x + 10;
    int maxY = midPoint.y + 10;
    return (p.x >= minX) && (p.x <= maxX) && (p.y >= minY) && (p.y <= maxY);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 7 with GraphPoint

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

the class DefaultDirectedEdgeRenderer method draw.

/**
 * Draws an edge using different calculations, coloring and label
 *
 * @param g2d the canvas
 * @param directedEdge edge to be drawn
 * @param label the label to put on the line
 * @param type the type of the line
 * @param hasError if the edge is in an erroneous state
 */
public void draw(Graphics2D g2d, DirectedEdge directedEdge, String label, String type, boolean hasError) {
    g2d.setPaint(hasError ? ERROR_PAINT : LINE_PAINT);
    switch(EdgeRouting.getValue(type)) {
        case STRAIGHT:
            drawStraightWithArrow(g2d, directedEdge);
            break;
        case BROKEN_PLUS:
            drawBrokenPlusWithArrow(g2d, directedEdge);
            break;
        case BROKEN_MINUS:
            drawBrokenMinusWithArrow(g2d, directedEdge);
            break;
        case BROKEN_PIPE:
            drawBrokenPipeWithArrow(g2d, directedEdge);
            break;
        default:
            Logger.warning("DefaultDirectedEdgeRenderer.draw() - unknow edge type:%s - drawing straight line", type);
            drawStraightWithArrow(g2d, directedEdge);
            break;
    }
    GraphPoint originPoint = directedEdge.getOriginPoint();
    GraphPoint terminusPoint = directedEdge.getTerminusPoint();
    GraphPoint midPoint = new GraphPoint();
    midPoint.x = (originPoint.x + terminusPoint.x) / 2;
    midPoint.y = (originPoint.y + terminusPoint.y) / 2;
    if (StringUtils.isNotBlank(label))
        g2d.drawString(label, midPoint.x + 10, midPoint.y);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 8 with GraphPoint

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

the class DefaultDirectedEdgeRenderer method drawStraightWithArrow.

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

Example 9 with GraphPoint

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

the class NextDef method containsPoint.

@Override
public boolean containsPoint(GraphPoint p) {
    GraphPoint originPoint = getOriginPoint();
    GraphPoint terminusPoint = getTerminusPoint();
    GraphPoint midPoint = new GraphPoint();
    if (("Broken +".equals(getBuiltInProperty(TYPE)))) {
        midPoint.x = (originPoint.x + terminusPoint.x) / 2;
        midPoint.y = (originPoint.y + terminusPoint.y) / 2;
    } else if (("Broken -".equals(getBuiltInProperty(TYPE)))) {
        boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
        midPoint.x = arrowOnY ? terminusPoint.x : (originPoint.x + terminusPoint.x) / 2;
        midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : originPoint.y;
    } else if (("Broken |".equals(getBuiltInProperty(TYPE)))) {
        boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
        midPoint.x = arrowOnY ? originPoint.x : (originPoint.x + terminusPoint.x) / 2;
        midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : terminusPoint.y;
    } else {
        midPoint.x = originPoint.x + (terminusPoint.x - originPoint.x) / 2;
        midPoint.y = originPoint.y + (terminusPoint.y - originPoint.y) / 2;
    }
    int minX = midPoint.x - 10;
    int minY = midPoint.y - 10;
    int maxX = midPoint.x + 10;
    int maxY = midPoint.y + 10;
    return (p.x >= minX) && (p.x <= maxX) && (p.y >= minY) && (p.y <= maxY);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 10 with GraphPoint

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

the class PredefinedStepContainer method predInit.

public void predInit(String alias, String Description, PredefinedStep act) {
    act.setName(alias);
    act.setType(alias);
    act.getProperties().put("Description", Description);
    act.setCentrePoint(new GraphPoint());
    act.setIsPredefined(true);
    addChild(act, new GraphPoint(100, 75 * ++num));
}
Also used : 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