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