KickJava   Java API By Example, From Geeks To Geeks.

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


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.Graphics2D JavaDoc;
22 import java.awt.geom.Point2D JavaDoc;
23
24 /**
25  * The base class for all shapes that can be drag moved on a workflow
26  * diagram.
27  *
28  * @author Matthew Large
29  * @version $Revision: 1.1 $
30  *
31  */

32 public abstract class AbstractMoveableShape extends AbstractWorkflowShape {
33
34     /**
35      * Control point for drag move.
36      */

37     private ControlPoint m_control = null;
38
39     /**
40      * Constructs a new moveable shape.
41      *
42      * @param x X co-ordinate of shape
43      * @param y Y co-ordinate of shape
44      */

45     public AbstractMoveableShape(float x, float y) {
46         super(x, y);
47     }
48     
49     /**
50      * Sets the position and size of the control point for this moveable
51      * shape.
52      *
53      * @param control 2D position of control point
54      * @param nWidth Width
55      * @param nHeight Height
56      */

57     protected void setMoveControl(Point2D.Double JavaDoc control, int nWidth, int nHeight) {
58         m_control = new ControlPoint(control, nWidth, nHeight);
59     }
60
61     /* (non-Javadoc)
62      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#draw(java.awt.Graphics2D)
63      */

64     public void draw(Graphics2D JavaDoc g) {
65         super.draw(g);
66         if(this.m_control!=null) {
67             this.m_control.draw(g);
68         }
69     }
70     
71     /**
72      * Checks if a co-ordinate is within the control point for this
73      * moveable shape.
74      *
75      * @param x X co-ordinate to check
76      * @param y Y co-ordinate to check
77      * @return true if the co-ordinate is within the control point
78      */

79     public boolean controlPointContains(double x, double y) {
80         return this.m_control.contains(x, y);
81     }
82
83     /* (non-Javadoc)
84      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setX(float)
85      */

86     public void setX(float x) {
87         super.setX(x);
88         this.m_control.setX(x);
89     }
90
91     /* (non-Javadoc)
92      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setY(float)
93      */

94     public void setY(float y) {
95         super.setY(y);
96         this.m_control.setY(y);
97     }
98
99 }
100
Popular Tags