001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.workfloweditor.flowchart.shapes;
020:
021: import java.awt.Graphics2D;
022: import java.awt.geom.Point2D;
023:
024: /**
025: * The base class for all shapes that can be drag moved on a workflow
026: * diagram.
027: *
028: * @author Matthew Large
029: * @version $Revision: 1.1 $
030: *
031: */
032: public abstract class AbstractMoveableShape extends
033: AbstractWorkflowShape {
034:
035: /**
036: * Control point for drag move.
037: */
038: private ControlPoint m_control = null;
039:
040: /**
041: * Constructs a new moveable shape.
042: *
043: * @param x X co-ordinate of shape
044: * @param y Y co-ordinate of shape
045: */
046: public AbstractMoveableShape(float x, float y) {
047: super (x, y);
048: }
049:
050: /**
051: * Sets the position and size of the control point for this moveable
052: * shape.
053: *
054: * @param control 2D position of control point
055: * @param nWidth Width
056: * @param nHeight Height
057: */
058: protected void setMoveControl(Point2D.Double control, int nWidth,
059: int nHeight) {
060: m_control = new ControlPoint(control, nWidth, nHeight);
061: }
062:
063: /* (non-Javadoc)
064: * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#draw(java.awt.Graphics2D)
065: */
066: public void draw(Graphics2D g) {
067: super .draw(g);
068: if (this .m_control != null) {
069: this .m_control.draw(g);
070: }
071: }
072:
073: /**
074: * Checks if a co-ordinate is within the control point for this
075: * moveable shape.
076: *
077: * @param x X co-ordinate to check
078: * @param y Y co-ordinate to check
079: * @return true if the co-ordinate is within the control point
080: */
081: public boolean controlPointContains(double x, double y) {
082: return this .m_control.contains(x, y);
083: }
084:
085: /* (non-Javadoc)
086: * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setX(float)
087: */
088: public void setX(float x) {
089: super .setX(x);
090: this .m_control.setX(x);
091: }
092:
093: /* (non-Javadoc)
094: * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setY(float)
095: */
096: public void setY(float y) {
097: super.setY(y);
098: this.m_control.setY(y);
099: }
100:
101: }
|