KickJava   Java API By Example, From Geeks To Geeks.

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


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 delete control on a connection line.
26  *
27  * @author Matthew Large
28  * @version $Revision: 1.1 $
29  *
30  */

31 public class LineSelectionPoint extends AbstractWorkflowShape {
32
33     
34     /**
35      * Construcs a new line selection point.
36      *
37      * @param control Location
38      */

39     public LineSelectionPoint(Point2D.Double control) {
40         super(new Double JavaDoc(control.x).floatValue(), new Double JavaDoc(control.y).floatValue());
41     }
42
43     /* (non-Javadoc)
44      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#drawSelf(java.awt.Graphics2D)
45      */

46     public void drawSelf(Graphics2D g) {
47         g.setPaint(Color.GRAY);
48         g.setStroke(new BasicStroke(2));
49         
50         Rectangle2D.Float rect = new Rectangle2D.Float(this.getX()-6, this.getY()-6, 12, 12);
51         g.setPaint(Color.LIGHT_GRAY);
52         g.fill(rect);
53         g.setPaint(Color.BLACK);
54         g.draw(rect);
55         
56         Line2D.Float line = new Line2D.Float(this.getX()-2, this.getY()-2, this.getX()+2, this.getY()+2);
57         g.draw(line);
58         
59         line = new Line2D.Float(this.getX()-2, this.getY()+2, this.getX()+2, this.getY()-2);
60         g.draw(line);
61     }
62     
63     /**
64      * Returns the location of the line selection point.
65      *
66      * @return Location
67      */

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

79     public boolean contains(double x, double y) {
80         return new Rectangle2D.Float(this.getX()-6, this.getY()-6, 12, 12).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     }
89
90     /* (non-Javadoc)
91      * @see com.simulacramedia.workfloweditor.flowchart.shapes.AbstractWorkflowShape#setY(float)
92      */

93     public void setY(float y) {
94         super.setY(y);
95     }
96
97 }
98
Popular Tags