1   /****************************************************************************
2    **
3    ** This file is part of yFiles-2.9. 
4    ** 
5    ** yWorks proprietary/confidential. Use is subject to license terms.
6    **
7    ** Redistribution of this file or of an unauthorized byte-code version
8    ** of this file is strictly forbidden.
9    **
10   ** Copyright (c) 2000-2011 by yWorks GmbH, Vor dem Kreuzberg 28, 
11   ** 72070 Tuebingen, Germany. All rights reserved.
12   **
13   ***************************************************************************/
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  /**
22  * This class is an implementation of {@link y.view.GenericNodeRealizer.Painter} that draws the delay symbol of flowchart diagrams.
23   **/
24  public class FlowchartDelayPainter extends AbstractFlowchartPainter {
25  
26  
27    public FlowchartDelayPainter() {
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 x = context.getX();
37      double y = context.getY();
38      double width = context.getWidth();
39      GenericNodeRealizer cast_gnr = (GenericNodeRealizer) context;
40      double capRadiusHighDependency;
41      if (cast_gnr.getStyleProperty(PROPERTY_RADIUS) != null) {
42        capRadiusHighDependency = ((Double) cast_gnr.getStyleProperty(PROPERTY_RADIUS)).doubleValue();
43        capRadiusHighDependency = Math.min(capRadiusHighDependency, 0.5);
44      } else {
45        capRadiusHighDependency = FLOWCHART_DEFAULT_DELAY_RADIUS;
46      }
47      double borderDistance = capRadiusHighDependency * Math.min(width, height);
48  
49      shapePath.moveTo((float) x, (float) y);
50      shapePath.lineTo((float) (x + width - borderDistance), (float) y);
51      shapePath.quadTo((float) (x + width + borderDistance), (float) (y + height / 2),
52          (float) (x + width - borderDistance), (float) (y + height));
53      shapePath.lineTo((float) x, (float) (y + height));
54      shapePath.closePath();
55    }
56  }
57