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  
17  import y.view.NodeRealizer;
18  
19  import java.awt.geom.GeneralPath;
20  
21  /**
22  * This class is an implementation of {@link y.view.GenericNodeRealizer.Painter} that draws the data base symbol of flowchart diagrams.
23   **/
24  public class FlowchartDataBasePainter extends AbstractFlowchartPainter {
25  
26    double X_OFFSET_1 = 0.03;
27    double Y_OFFSET_1 = 0.2;
28  
29    public FlowchartDataBasePainter() {
30      super();
31      this.outline = new GeneralPath();
32      this.innerShape = new GeneralPath();
33    }
34  
35  
36    protected void updateOutline(NodeRealizer context) {
37  
38      GeneralPath shapePath = (GeneralPath) getOutline();
39      shapePath.reset();
40  
41      double x = context.getX();
42      double y = context.getY();
43      double height = context.getHeight();
44      double width = context.getWidth();
45      
46      shapePath.moveTo((float)x, (float)(y + Y_OFFSET_1 *height));
47      shapePath.curveTo((float)(x+ X_OFFSET_1 *width), (float)y, (float)(x+width- X_OFFSET_1 *width), (float)y, (float) (x+width), (float)(y + Y_OFFSET_1 *height));
48      shapePath.lineTo((float)(x + width), (float)(y + height - Y_OFFSET_1 *height));
49      shapePath.curveTo((float)(x + width - X_OFFSET_1 *width), (float)(y+height), (float)(x + X_OFFSET_1 *width), (float) (y+height), (float)x, (float)(y + height - Y_OFFSET_1 *height));
50      shapePath.closePath();
51    }
52  
53    public void updateInsideShape(NodeRealizer context) {
54      GeneralPath shapePath = (GeneralPath) getInnerShape();
55      shapePath.reset();
56      double x = context.getX();
57      double y = context.getY();
58      double height = context.getHeight();
59      double width = context.getWidth();
60      
61      shapePath.moveTo((float) (x+width), (float)(y + Y_OFFSET_1 *height));
62      shapePath.curveTo((float)(x + width- X_OFFSET_1 *width), (float) (y+2* Y_OFFSET_1 *height), (float)(x + X_OFFSET_1 *width), (float) (y+2* Y_OFFSET_1 *height), (float)x, (float)(y + Y_OFFSET_1 *height));
63    }
64  
65  }