Draw transitions names in diagram generator

Description

Add to ProcessDiagramCanvas

public void drawSequenceflow(String title, int srcX, int srcY, int targetX, int targetY, boolean conditional) {
int shift = 5;

Line2D.Double line = new Line2D.Double(srcX, srcY, targetX, targetY);
g.draw(line);
drawArrowHead(line);

if (title != null && !title.isEmpty()) {
drawRotatedString(title, g, new Float(srcX + shift), new Float(srcY - shift),
new Double(Math.atan2(targetY - srcY, targetX - srcX)).floatValue(), new Float(srcX + shift),
new Float(srcY - shift));
}

if (conditional) {
drawConditionalSequenceFlowIndicator(line);
}
}

/**

  • A utility method for drawing rotated text.

  • A common rotation is -Math.PI/2 which draws text 'vertically'

  • (with the top of the characters on the left).

  • @param text

  • the text.

  • @param g2

  • the graphics device.

  • @param textX

  • the x-coordinate for the text (before rotation).

  • @param textY

  • the y-coordinate for the text (before rotation).

  • @param angle

  • the angle of the (clockwise) rotation (in radians).

  • @param rotateX

  • the point about which the text is rotated.

  • @param rotateY

  • the point about which the text is rotated.
    */
    public static void drawRotatedString(final String text, final Graphics2D g2, final float textX, final float textY,
    final double angle, final float rotateX, final float rotateY) {

final AffineTransform saved = g2.getTransform();

final AffineTransform rotate = AffineTransform.getRotateInstance(angle, rotateX, rotateY);
g2.transform(rotate);

final TextLayout tl = new TextLayout(text, g2.getFont(), g2.getFontRenderContext());
tl.draw(g2, textX, textY);
g2.setTransform(saved);

}

and modify call of drawSequenceFlow in ProcessDiagramGenerator near line 286

Assignee

saeid mirzaei

Reporter

Denis Ryabkov

Labels

None

Components

Fix versions

Priority

Minor
Configure