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 off page reference symbol of flowchart diagrams.
22   **/
23  public class FlowchartOffPageReferencePainter extends AbstractFlowchartPainter {
24    public FlowchartOffPageReferencePainter() {
25      super();
26      outline = new GeneralPath();
27    }
28  
29    protected void updateOutline(NodeRealizer context) {
30      GeneralPath shape = (GeneralPath) getOutline();
31      shape.reset();
32      double height = context.getHeight();
33      double width = context.getWidth();
34      double x = context.getX();
35      double y = context.getY();
36      double minLength = Math.min(height, width);
37      
38      double borderDistanceX = Math.max((width - minLength)/2, 0);
39      double borderDistanceY = Math.max((height - minLength)/2, 0);
40      shape.moveTo((float)(x + borderDistanceX), (float)(y + borderDistanceY));
41      shape.lineTo((float)(x + minLength + borderDistanceX), (float)(y + borderDistanceY));
42      shape.lineTo((float)(x + minLength + borderDistanceX), (float)(y + minLength/2 + borderDistanceY));
43      shape.lineTo((float)(x + minLength/2 + borderDistanceX), (float)(y + minLength + borderDistanceY));
44      shape.lineTo((float)(x + borderDistanceX), (float)(y + minLength/2 + borderDistanceY));
45      shape.closePath();
46    }
47  }
48