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