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));
}
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) });
}
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;
}
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));
}
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));
}
Aggregations