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 FlowchartPaperTapePainter extends AbstractFlowchartPainter {
25
26 public FlowchartPaperTapePainter() {
27 super();
28 outline = new GeneralPath();
29 }
30
31 protected void updateOutline(NodeRealizer context) {
32
33 GeneralPath shapePath = (GeneralPath) getOutline();
34 shapePath.reset();
35
36 double x = context.getX();
37 double y = context.getY();
38 double height = context.getHeight();
39 double width = context.getWidth();
40 double capRadiusHighDependency;
41 GenericNodeRealizer cast_gnr = (GenericNodeRealizer) context;
42 if (cast_gnr.getStyleProperty(PROPERTY_RADIUS) != null) {
43 capRadiusHighDependency = ((Double) cast_gnr.getStyleProperty(PROPERTY_RADIUS)).doubleValue();
44 capRadiusHighDependency = Math.min(capRadiusHighDependency, 0.5);
45 } else {
46 capRadiusHighDependency = FLOWCHART_DEFAULT_PAPER_TAPE_RADIUS;
47 }
48 double borderDistance = capRadiusHighDependency * Math.min(width, height);
49
50 shapePath.moveTo((float)x, (float)(y + borderDistance));
51 shapePath.quadTo((float)(x + 0.25 * width), (float)(y + 3*borderDistance), (float)(x + 0.5 * width), (float)(y + borderDistance));
52 shapePath.quadTo((float)(x + 0.75 * width), (float)(y - borderDistance), (float)(x + width), (float)(y + borderDistance));
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), (float)(y + height - borderDistance));
55 shapePath.quadTo((float)(x + 0.25 * width), (float)(y + height + borderDistance), (float)x, (float)(y + height - borderDistance));
56 shapePath.closePath();
57
58 }
59 }
60