Mercurial > hg > ccmieditor
comparison java/src/uk/ac/qmul/eecs/ccmi/gui/GraphElement.java @ 3:9e67171477bc
PHANTOM Omni Heptic device release
author | Fiore Martin <fiore@eecs.qmul.ac.uk> |
---|---|
date | Wed, 25 Apr 2012 17:09:09 +0100 |
parents | 9418ab7b7f3f |
children | d66dd5880081 |
comparison
equal
deleted
inserted
replaced
2:4b2f975e35fa | 3:9e67171477bc |
---|---|
22 import java.awt.geom.Point2D; | 22 import java.awt.geom.Point2D; |
23 import java.awt.geom.Rectangle2D; | 23 import java.awt.geom.Rectangle2D; |
24 | 24 |
25 | 25 |
26 /** | 26 /** |
27 * An interface implemented by {@link Node} and {@link Edge} and it defines methods that | 27 * An interface implemented by {@code Node}, {@code Edge} and {@code Edge.InnerPoint}. It defines methods that |
28 * both the classes implements as they're object painted on a graph. The interface is used mainly | 28 * all objects painted on a graph share. The interface is used mainly |
29 * for convenience in treating the two types of object in a unified way. | 29 * for convenience in treating the different types of object in a uniformly. |
30 * | 30 * |
31 */ | 31 */ |
32 public interface GraphElement { | 32 public interface GraphElement { |
33 /** | |
34 * Draw the graphic element on a canvas | |
35 * | |
36 * @param g2 the graphics object. Use {@code g2.draw()} to get things painted on the graph. | |
37 */ | |
33 public void draw(Graphics2D g2); | 38 public void draw(Graphics2D g2); |
34 | 39 |
35 public void translate(Point2D p, double dx, double dy); | 40 /** |
41 * Translates this graphic element on the graph | |
42 * | |
43 * @param p the starting point where the translation starts (normally where the user clicks | |
44 * with their mouse) | |
45 * @param dx the distance to translate along the x-axis | |
46 * @param dy the distance to translate along the y-axis | |
47 * @param source the source of the translate action | |
48 */ | |
49 public void translate(Point2D p, double dx, double dy, Object source); | |
36 | 50 |
37 public void stopMove(); | 51 /** |
52 * This method is to be called before translation or any other operation that changes the | |
53 * position of the graph element or any of its parts. | |
54 * | |
55 * @param p the starting point of the motion | |
56 * @param source the source of the motion action | |
57 */ | |
58 public void startMove(Point2D p, Object source); | |
59 | |
60 /** | |
61 * This method is to be called when the motion (e.g. a translation) is over. | |
62 * Note that for instance a translation might be composed on several calls to {@code translate} | |
63 * | |
64 * @param source | |
65 */ | |
66 public void stopMove(Object source); | |
38 | 67 |
39 public void startMove(Point2D p); | 68 /** |
40 | 69 * Gets the bounding {@code Rectangle} of this graph element. |
70 * | |
71 * @return a new {@code Rectangle} equals to the bounding {@code Rectangle} of this graph element | |
72 */ | |
41 public Rectangle2D getBounds(); | 73 public Rectangle2D getBounds(); |
42 | 74 |
75 /** | |
76 * Returns the point where an line, with a specified direction, would come in contact with the outline of this | |
77 * graph element. | |
78 * | |
79 * @param d the direction of the line | |
80 * @return a new point on the outline if this graph element where the line comes in contact with it | |
81 */ | |
43 public Point2D getConnectionPoint(Direction d); | 82 public Point2D getConnectionPoint(Direction d); |
44 | 83 |
84 /** | |
85 * Tests if a specified {@code Point2D} is inside the boundary of this graph element. | |
86 * | |
87 * @param p the point to be tested | |
88 * @return {@code true} if the point is inside the boundary, {@code false} otherwise | |
89 */ | |
45 public boolean contains(Point2D p); | 90 public boolean contains(Point2D p); |
46 | 91 |
47 } | 92 } |