KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
22 import java.awt.geom.*;
23
24 /**
25  * Represents the move handler for workflow stage shapes.
26  *
27  * @author Matthew Large
28  * @version $Revision: 1.1 $
29  *
30  */

31 public class ControlPoint extends AbstractWorkflowShape {
32
33     /**
34      * Rectangle shape for the handler.
35      */

36     private Rectangle2D.Float m_rect;
37     
38     /**
39      * Constructs a new control point.
40      *
41      * @param control 2D location of control point
42      * @param nWidth Width
43      * @param nHeight Height
44      */

45     public ControlPoint(Point2D.Double control, int nWidth, int nHeight) {
46         super(new Double JavaDoc(control.x).floatValue(), new Double JavaDoc(control.y).floatValue());
47         
48         this.m_rect = new Rectangle2D.Float( new Double JavaDoc(control.x).intValue(), new Double JavaDoc(control.y).intValue(), nWidth, nHeight);
49         
50     }
51
52     /* (non-Javadoc)
53      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#drawSelf(java.awt.Graphics2D)
54      */

55     public void drawSelf(Graphics2D g) {
56
57     }
58     
59     /**
60      * Returns the location of the control point.
61      *
62      * @return Location
63      */

64     public Point2D.Double getControl() {
65         return new Point2D.Double(this.getX(), this.getY());
66     }
67     
68     /**
69      * Checks if the control point contains a given co-ordinate.
70      *
71      * @param x X co-ordinate to check
72      * @param y Y co-ordinate to check
73      * @return true if the control point contains the co-ordinate
74      */

75     public boolean contains(double x, double y) {
76         return this.m_rect.contains(x, y);
77     }
78
79     /* (non-Javadoc)
80      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setX(float)
81      */

82     public void setX(float x) {
83         super.setX(x);
84         this.m_rect.x=x;
85     }
86
87     /* (non-Javadoc)
88      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setY(float)
89      */

90     public void setY(float y) {
91         super.setY(y);
92         this.m_rect.y=y;
93     }
94
95 }
96
Popular Tags