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