Search in sources :

Example 11 with GraphPoint

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

the class CastorXMLTest method testGraphMultiPointEdge.

@Test
public void testGraphMultiPointEdge() throws Exception {
    CastorXMLUtility marshaller = Gateway.getMarshaller();
    GraphableEdge edge = new Next();
    edge.getMultiPoints().put(1, new GraphPoint(0, 0));
    edge.getMultiPoints().put(2, new GraphPoint(100, 100));
    edge.getMultiPoints().put(3, new GraphPoint(200, 100));
    GraphableEdge edgePrime = (GraphableEdge) marshaller.unmarshall(marshaller.marshall(edge));
    assertThat(edge).isEqualToComparingFieldByField(edgePrime);
    Logger.msg(marshaller.marshall(edge));
    Logger.msg(marshaller.marshall(edgePrime));
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) Next(org.cristalise.kernel.lifecycle.instance.Next) CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility) GraphableEdge(org.cristalise.kernel.graph.model.GraphableEdge) MainTest(org.cristalise.kernel.test.process.MainTest) Test(org.junit.Test)

Example 12 with GraphPoint

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

the class AggregationVertexOutlineCreator method setOutline.

@Override
public void setOutline(Vertex vertex) {
    GraphPoint centre = vertex.getCentrePoint();
    int height = vertex.getHeight();
    int width = vertex.getWidth();
    if (height == 0 || width == 0)
        vertex.setOutlinePoints(new GraphPoint[] { new GraphPoint(centre.x - 20, centre.y - 20), new GraphPoint(centre.x + 20, centre.y - 20), new GraphPoint(centre.x + 20, centre.y + 20), new GraphPoint(centre.x - 20, centre.y + 20) });
    else
        vertex.setOutlinePoints(new GraphPoint[] { new GraphPoint(centre.x - width / 2, centre.y - height / 2), new GraphPoint(centre.x + width / 2, centre.y - height / 2), new GraphPoint(centre.x + width / 2, centre.y + height / 2), new GraphPoint(centre.x - width / 2, centre.y + height / 2) });
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 13 with GraphPoint

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

the class ReplaceDomainWorkflow method runActivityLogic.

@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, PersistencyException {
    Workflow lifeCycle = getWf();
    String[] params = getDataList(requestData);
    if (Logger.doLog(3))
        Logger.msg(3, "ReplaceDomainWorkflow: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
    if (params.length != 1)
        throw new InvalidDataException("ReplaceDomainWorkflow: Invalid parameters " + Arrays.toString(params));
    lifeCycle.getChildrenGraphModel().removeVertex(lifeCycle.search("workflow/domain"));
    CompositeActivity domain;
    try {
        domain = (CompositeActivity) Gateway.getMarshaller().unmarshall(params[0]);
    } catch (Exception e) {
        Logger.error(e);
        throw new InvalidDataException("ReplaceDomainWorkflow: Could not unmarshall new workflow: " + e.getMessage());
    }
    domain.setName("domain");
    lifeCycle.initChild(domain, true, new GraphPoint(150, 100));
    // if new workflow, activate it, otherwise refresh the jobs
    if (!domain.active)
        lifeCycle.run(agent, item, locker);
    else
        lifeCycle.refreshJobs(item);
    // store new wf
    try {
        Gateway.getStorage().put(item, lifeCycle, locker);
    } catch (PersistencyException e) {
        throw new PersistencyException("ReplaceDomainWorkflow: Could not write new workflow to storage: " + e.getMessage());
    }
    return requestData;
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Workflow(org.cristalise.kernel.lifecycle.instance.Workflow) PersistencyException(org.cristalise.kernel.common.PersistencyException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 14 with GraphPoint

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

the class DefaultDirectedEdgeRenderer method drawBrokenPlusWithArrow.

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

Example 15 with GraphPoint

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

the class DefaultDirectedEdgeRenderer method drawBrokenMinusWithArrow.

/**
 * Draw a line of 2 segments (horizontal, vertical) between origin and terminus point
 *
 * @param g2d the canvas
 * @param directedEdge edge to be drawn
 */
private void drawBrokenMinusWithArrow(Graphics2D g2d, DirectedEdge directedEdge) {
    GraphPoint originPoint = directedEdge.getOriginPoint();
    GraphPoint terminusPoint = directedEdge.getTerminusPoint();
    g2d.drawLine(originPoint.x, originPoint.y, terminusPoint.x, originPoint.y);
    g2d.drawLine(terminusPoint.x, originPoint.y, terminusPoint.x, terminusPoint.y);
    boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
    GraphPoint midPoint = new GraphPoint();
    midPoint.x = arrowOnY ? terminusPoint.x : (originPoint.x + terminusPoint.x) / 2;
    midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : originPoint.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)

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