1
14 package demo.view.flowchart.painters;
15
16 import y.view.NodeRealizer;
17
18 import java.awt.geom.GeneralPath;
19
20
23 public class FlowchartLoopLimitPainter extends AbstractFlowchartPainter {
24
25 private final boolean isLoopStart;
26
27 public FlowchartLoopLimitPainter() {
28 this(true);
29 }
30
31 public FlowchartLoopLimitPainter(boolean isStart){
32 this.isLoopStart = isStart;
33 outline = new GeneralPath();
34 }
35
36 protected void updateOutline(NodeRealizer context) {
37 GeneralPath shape = (GeneralPath) getOutline();
38 shape.reset();
39 double height = context.getHeight();
40 double width = context.getWidth();
41 double x = context.getX();
42 double y = context.getY();
43 double borderDistance = Math.min(Math.min(10, width/2), height/2);
44 if (isLoopStart) {
45 shape.moveTo((float)(x + borderDistance), (float)y);
46 shape.lineTo((float)(x + width - borderDistance), (float)y);
47 shape.lineTo((float)(x+ width), (float)(y + borderDistance));
48 shape.lineTo((float)(x + width), (float)(y + height));
49 shape.lineTo((float)x, (float)(y + height));
50 shape.lineTo((float)x, (float)(y + borderDistance));
51 shape.closePath();
52 } else { shape.moveTo((float) x, (float) y);
54 shape.lineTo((float)(x + width), (float) y);
55 shape.lineTo((float)(x + width), (float)(y + height - borderDistance));
56 shape.lineTo((float)(x + width - borderDistance), (float)(y + height));
57 shape.lineTo((float)(x + borderDistance), (float)(y + height));
58 shape.lineTo((float) x, (float)(y + height -borderDistance));
59 shape.closePath();
60 }
61 }
62
63 }
64