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