| FlowchartSequentialDataPainter.java |
1 /****************************************************************************
2 * This demo file is part of yFiles for Java 2.14.
3 * Copyright (c) 2000-2017 by yWorks GmbH, Vor dem Kreuzberg 28,
4 * 72070 Tuebingen, Germany. All rights reserved.
5 *
6 * yFiles demo files exhibit yFiles for Java functionalities. Any redistribution
7 * of demo files in source code or binary form, with or without
8 * modification, is not permitted.
9 *
10 * Owners of a valid software license for a yFiles for Java version that this
11 * demo is shipped with are allowed to use the demo source code as basis
12 * for their own yFiles for Java powered applications. Use of such programs is
13 * governed by the rights and conditions as set out in the yFiles for Java
14 * license agreement.
15 *
16 * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 * NO EVENT SHALL yWorks BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 ***************************************************************************/
28 package demo.view.flowchart.painters;
29
30 import y.view.NodeRealizer;
31
32 import java.awt.Shape;
33 import java.awt.geom.Ellipse2D;
34 import java.awt.geom.Line2D;
35
36 /**
37 * Draws the sequential data symbol of flowchart diagrams.
38 */
39 public class FlowchartSequentialDataPainter extends AbstractFlowchartPainter {
40 protected Shape newShape( NodeRealizer context ) {
41 double height = context.getHeight();
42 double width = context.getWidth();
43 double x = context.getX();
44 double y = context.getY();
45 double diameter = Math.min(height, width);
46 double borderDistanceX = Math.max((width - diameter)/2, 0);
47 double borderDistanceY = Math.max((height - diameter)/2, 0);
48 return new Ellipse2D.Double(x + borderDistanceX, y + borderDistanceY, diameter, diameter);
49 }
50
51 public Shape newDecoration( NodeRealizer context ) {
52 double height = context.getHeight();
53 double width = context.getWidth();
54 double x = context.getX();
55 double y = context.getY();
56 double diameter = Math.min(height, width);
57 double borderDistanceX = Math.max((width - diameter)/2, 0);
58 double borderDistanceY = Math.max((height - diameter)/2, 0);
59 return new Line2D.Double(x + borderDistanceX + diameter/2, y + borderDistanceY + diameter, x + width - borderDistanceX, y + borderDistanceY + diameter);
60 }
61 }
62