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 java.awt.geom.GeneralPath;
18  
19  /**
20   * This class is an implementation of {@link y.view.GenericNodeRealizer.Painter} that draws the preparation symbol of flowchart diagrams.
21   */
22  public class FlowchartPreparationPainter extends AbstractFlowchartPainter{
23    public FlowchartPreparationPainter() {
24      super();
25      outline = new GeneralPath();
26    }
27  
28    protected void updateOutline(NodeRealizer context) {
29      GeneralPath shapePath = (GeneralPath) getOutline();
30      shapePath.reset();
31  
32      double x = context.getX();
33      double y = context.getY();
34      double height = context.getHeight();
35      double width = context.getWidth();
36      double borderDistance = Math.min(FLOWCHART_DEFAULT_PREPARATION_INCLINATION * height, FLOWCHART_DEFAULT_PREPARATION_INCLINATION * width);
37  
38      shapePath.moveTo((float)(x + borderDistance), (float)y);
39      shapePath.lineTo((float)(x + width - borderDistance), (float)y);
40      shapePath.lineTo((float)(x + width), (float)(y + height/2));
41      shapePath.lineTo((float)(x + width - borderDistance), (float)(y + height));
42      shapePath.lineTo((float)(x + borderDistance), (float)(y + height));
43      shapePath.lineTo((float)x, (float)(y + height/2));
44      shapePath.closePath();
45    }
46  }
47