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