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.*;
022: import java.awt.geom.*;
023:
024: /**
025: * Represents the delete control on a connection line.
026: *
027: * @author Matthew Large
028: * @version $Revision: 1.1 $
029: *
030: */
031: public class LineSelectionPoint extends AbstractWorkflowShape {
032:
033: /**
034: * Construcs a new line selection point.
035: *
036: * @param control Location
037: */
038: public LineSelectionPoint(Point2D.Double control) {
039: super (new Double(control.x).floatValue(), new Double(control.y)
040: .floatValue());
041: }
042:
043: /* (non-Javadoc)
044: * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#drawSelf(java.awt.Graphics2D)
045: */
046: public void drawSelf(Graphics2D g) {
047: g.setPaint(Color.GRAY);
048: g.setStroke(new BasicStroke(2));
049:
050: Rectangle2D.Float rect = new Rectangle2D.Float(this .getX() - 6,
051: this .getY() - 6, 12, 12);
052: g.setPaint(Color.LIGHT_GRAY);
053: g.fill(rect);
054: g.setPaint(Color.BLACK);
055: g.draw(rect);
056:
057: Line2D.Float line = new Line2D.Float(this .getX() - 2, this
058: .getY() - 2, this .getX() + 2, this .getY() + 2);
059: g.draw(line);
060:
061: line = new Line2D.Float(this .getX() - 2, this .getY() + 2, this
062: .getX() + 2, this .getY() - 2);
063: g.draw(line);
064: }
065:
066: /**
067: * Returns the location of the line selection point.
068: *
069: * @return Location
070: */
071: public Point2D.Double getControl() {
072: return new Point2D.Double(this .getX(), this .getY());
073: }
074:
075: /**
076: * Checks if the selection point contains a given co-ordinate.
077: *
078: * @param x X co-ordinate to check
079: * @param y Y co-ordinate to check
080: * @return true if the selction point contains the co-ordinate
081: */
082: public boolean contains(double x, double y) {
083: return new Rectangle2D.Float(this .getX() - 6, this .getY() - 6,
084: 12, 12).contains(x, y);
085: }
086:
087: /* (non-Javadoc)
088: * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setX(float)
089: */
090: public void setX(float x) {
091: super .setX(x);
092: }
093:
094: /* (non-Javadoc)
095: * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setY(float)
096: */
097: public void setY(float y) {
098: super.setY(y);
099: }
100:
101: }
|