| FlowchartStart2Painter.java |
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
20 /**
21 * This class is an implementation of {@link y.view.GenericNodeRealizer.Painter} that draws the "start2" symbol of flowchart diagrams.
22 **/
23 public class FlowchartStart2Painter extends AbstractFlowchartPainter{
24 public FlowchartStart2Painter() {
25 super();
26 outline = new Ellipse2D.Double();
27 }
28
29 protected void updateOutline(NodeRealizer context) {
30 Ellipse2D shape = (Ellipse2D) getOutline();
31
32 double height = context.getHeight();
33 double width = context.getWidth();
34 double x = context.getX();
35 double y = context.getY();
36 double diameter = Math.min(height, width);
37 double borderDistanceX = Math.max((width - diameter)/2, 0);
38 double borderDistanceY = Math.max((height - diameter)/2, 0);
39 shape.setFrame(x + borderDistanceX, y + borderDistanceY, diameter, diameter);
40
41 }
42 }
43