01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.workfloweditor.flowchart.shapes;
20:
21: import java.awt.BasicStroke;
22: import java.awt.Color;
23: import java.awt.Graphics2D;
24: import java.awt.geom.Rectangle2D;
25:
26: /**
27: * Shape representing a point on a workflow stage shape that can
28: * be the start or end of a connection line.
29: *
30: * @author Matthew Large
31: * @version $Revision: 1.1 $
32: *
33: */
34: public class ConnectionPoint extends AbstractWorkflowShape {
35:
36: /**
37: * Constructs a new connection point.
38: *
39: * @param x X co-ordinate
40: * @param y Y co-ordinate
41: */
42: public ConnectionPoint(float x, float y) {
43: super (x, y);
44: }
45:
46: /* (non-Javadoc)
47: * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#drawSelf(java.awt.Graphics2D)
48: */
49: public void drawSelf(Graphics2D g) {
50: g.setStroke(new BasicStroke(2));
51: g.setPaint(new Color(181, 12, 0));
52: g.draw(this .getRect());
53: }
54:
55: /**
56: * Returns a rectangle based on this shape.
57: *
58: * @return Rectangle
59: */
60: private Rectangle2D.Float getRect() {
61: return new Rectangle2D.Float(this .getX() - 5, this .getY() - 5,
62: 10, 10);
63: }
64:
65: /**
66: * Checks if this shape contains a given co-ordinate.
67: *
68: * @param x X co-ordinate to check
69: * @param y Y co-ordinate to check
70: * @return true if this shape contains the co-ordinate
71: */
72: public boolean contains(double x, double y) {
73: return this.getRect().contains(x, y);
74: }
75:
76: }
|