KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > workfloweditor > flowchart > shapes > ConnectionPoint


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * 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 JavaDoc;
22 import java.awt.Color JavaDoc;
23 import java.awt.Graphics2D JavaDoc;
24 import java.awt.geom.Rectangle2D JavaDoc;
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 JavaDoc g) {
50         g.setStroke(new BasicStroke JavaDoc(2));
51         g.setPaint(new Color JavaDoc(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 JavaDoc getRect() {
61         return new Rectangle2D.Float JavaDoc(this.getX()-5, this.getY()-5, 10, 10);
62     }
63     
64     /**
65      * Checks if this shape contains a given co-ordinate.
66      *
67      * @param x X co-ordinate to check
68      * @param y Y co-ordinate to check
69      * @return true if this shape contains the co-ordinate
70      */

71     public boolean contains(double x, double y) {
72         return this.getRect().contains(x, y);
73     }
74
75 }
76
Popular Tags