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.Ellipse2D;
19  import java.awt.geom.Line2D;
20  
21  /**
22   * This class is an implementation of {@link y.view.GenericNodeRealizer.Painter} that draws the sequential data symbol of flowchart diagrams.
23   */
24  public class FlowchartSequentialDataPainter extends AbstractFlowchartPainter{
25    public FlowchartSequentialDataPainter() {
26      super();
27      outline = new Ellipse2D.Double();
28      innerShape = new Line2D.Double();
29    }
30  
31    protected void updateOutline(NodeRealizer context) {
32      Ellipse2D shape = (Ellipse2D) getOutline();
33      double height = context.getHeight();
34      double width = context.getWidth();
35      double x = context.getX();
36      double y = context.getY();
37      double diameter = Math.min(height, width);
38      double borderDistanceX = Math.max((width - diameter)/2, 0);
39      double borderDistanceY = Math.max((height - diameter)/2, 0);
40      shape.setFrame(x + borderDistanceX, y + borderDistanceY, diameter, diameter);
41    }
42  
43    public void updateInsideShape(NodeRealizer context) {
44      Line2D shape = (Line2D) getInnerShape();
45      double height = context.getHeight();
46      double width = context.getWidth();
47      double x = context.getX();
48      double y = context.getY();
49      double diameter = Math.min(height, width);
50      double borderDistanceX = Math.max((width - diameter)/2, 0);
51      double borderDistanceY = Math.max((height - diameter)/2, 0);
52      shape.setLine(x + borderDistanceX + diameter/2, y + borderDistanceY + diameter, x + width - borderDistanceX, y + borderDistanceY + diameter);
53    }
54  }
55