1
14 package demo.view.flowchart.painters;
15
16 import y.view.NodeRealizer;
17 import y.view.GenericNodeRealizer;
18
19 import java.awt.geom.GeneralPath;
20
21
24 public class FlowchartDocumentPainter extends AbstractFlowchartPainter {
25
26
27 public FlowchartDocumentPainter() {
28 super();
29 outline = new GeneralPath();
30 }
31
32 protected void updateOutline(NodeRealizer context) {
33 GeneralPath shapePath = (GeneralPath) getOutline();
34 shapePath.reset();
35 double height = context.getHeight();
36 double width = context.getWidth();
37 double x = context.getX();
38 double y = context.getY();
39 double inflectionCoefficient;
40 GenericNodeRealizer cast_gnr = (GenericNodeRealizer) context;
41
42
43 if (cast_gnr.getStyleProperty(PROPERTY_RADIUS) != null) {
44 inflectionCoefficient = ((Double) cast_gnr.getStyleProperty(PROPERTY_RADIUS)).doubleValue();
45 inflectionCoefficient = Math.min(inflectionCoefficient, 0.5);
46 } else {
47 inflectionCoefficient = FLOWCHART_DEFAULT_DOCUMENT_RADIUS;
48 }
49
50 double borderDistance = inflectionCoefficient * Math.min(width, height);
51 shapePath.moveTo((float) x, (float) y);
52 shapePath.lineTo((float) (x + width), (float) y);
53 shapePath.lineTo((float) (x + width), (float) (y + height - borderDistance));
54 shapePath.quadTo((float) (x + 0.75 * width), (float) (y + height - 3 * borderDistance), (float) (x + 0.5 * width),
55 (float) (y + height - borderDistance));
56 shapePath.quadTo((float) (x + 0.25 * width), (float) (y + height + borderDistance), (float) x,
57 (float) (y + height - borderDistance));
58 shapePath.closePath();
59 }
60 }
61