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  
18  import java.awt.geom.GeneralPath;
19  
20  /**
21  * This class is an implementation of {@link y.view.GenericNodeRealizer.Painter} that draws the cloud symbol of flowchart diagrams.
22   **/
23  public class FlowchartCloudPainter extends AbstractFlowchartPainter {
24  
25  
26  
27    public FlowchartCloudPainter() {
28      super();
29      outline = new GeneralPath();
30    }
31  
32    protected void updateOutline(NodeRealizer context) {
33  
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 asymetrConstY = 0.03 * height;
42      double asymetrConstX = 0.05 * width;
43      double xOffset1 = 0.125;
44      double yOffset1 = 0.250;
45      double yOffset2 = 0.18;
46      shapePath.moveTo((float) (x+ xOffset1 *width), (float)(y+0.5*height+asymetrConstY));
47      shapePath.curveTo((float) x, (float) (y+ yOffset1 *height), (float) (x+ 0.125 *width), (float) y, (float) (x + 0.33*width), (float) (y + yOffset2 *height));
48      shapePath.curveTo((float) (x + 0.33*width), (float) y, (float) (x+width-0.33*width), (float) y, (float) (x+width-0.33*width), (float) (y + yOffset2 *height));
49      shapePath.curveTo((float) (x + width- 0.125 *width), (float) y, (float) (x+width), (float) (y+ yOffset1 *height), (float) (x+width- xOffset1 *width), (float) (y + 0.5*height - asymetrConstY));
50  
51      shapePath.curveTo((float) (x+width), (float) (y+height- yOffset1 *height), (float) (x + width- 0.125 *width), (float) (y+height), (float) (x+width-0.33*width+asymetrConstX), (float) (y + height - yOffset2 *height));
52      shapePath.curveTo((float) (x+width-0.33*width), (float) (y+height), (float) (x + 0.33*width), (float) (y+height), (float) (x + 0.33*width+asymetrConstX), (float) (y + height- yOffset2 *height));
53      shapePath.curveTo((float) (x+ 0.125 *width), (float) (y+height), (float)x, (float) (y+height- yOffset1 *height), (float) (x+ xOffset1 *width), (float)(y+0.5*height+asymetrConstY));
54      shapePath.closePath();
55  
56    }
57  }