Class SmileEdge
- java.lang.Object
-
- Edge
-
- uk.ac.qmul.eecs.ccmi.examples.framework.SmileEdge
-
public class SmileEdge extends Edge
An example of how CCmI Diagram Editor edges can be extended, in order to create your own graphic palette.
Subclasses of
Edge
can define their own appearance in the diagram graph by overridingdraw()
and a few other abstract methods. They must also define their own sound in the editor tree by providing their own implementation ofgetSound()
.The
draw()
method is called by the framework when the graph needs to be rendered, and ajava.awt.Graphics2D
object is passed as argument. Therefore, Java 2D API can be used to draw your own edge: from graphic primitives and arbitrary shapes to images. In order to maintain the graphic representation consistent with the haptic representation, the edge line stroke should be picked from: solid, dashed and dotted (seeLineStyle.getStroke()
). However, the user can freely define their own arrow heads and tails to represent edge directionality.Instances of
SmileEdge
draw themselves as a straight line with a semi-ellipse shaped arrow head and a circle shaped arrow tail. In the editor tree aSmileEdge
will sound like a bell.
-
-
Constructor Summary
Constructors Constructor and Description SmileEdge()
Creates a new instance ofSmileEdge
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.Object
clone()
void
draw(java.awt.Graphics2D g2)
Draws this edge on the graph.void
drawEdgeEnd(GraphElement start, Node end, java.awt.Graphics2D g2)
Draws an arrow head/tail on the end of this edge where the node passed as argument is.java.awt.geom.Rectangle2D
getBounds()
Calculates the bounding rectangle of this edge.java.io.InputStream
getSound()
Returns a stream to a bell sound file.
-
-
-
Constructor Detail
-
SmileEdge
public SmileEdge()
Creates a new instance of
SmileEdge
. The edge has a solid line style and two maximum and minimum attached nodes.The available end descriptions are "from" and "two", describing whether the end is the tail or the head of the edge. When an end's end description is set to "to" will appear at that end on the graph (see
drawArrowHead
).The type is "Smile Edge".
-
-
Method Detail
-
draw
public void draw(java.awt.Graphics2D g2)
Draws this edge on the graph. If there are no inner points (the points on the edge, where the user "breaks" the edge when they bend it) one straight line from one node to another is drawn, else the line is broken into several lines from one node to the other, via the inner points.
When the user changes the arrow head of an edge, the edge is redrawn and this method is called. If the user selects "to" as an end description a semi-ellipse shaped arrow head is drawn at that end, conversely if the user selects "from" as the end description a black circle is drawn at that end.
- Parameters:
g2
- the graphics object where to drawn on- See Also:
#drawEdgeEnd(GraphElement, Node, Graphics2D)
-
drawEdgeEnd
public void drawEdgeEnd(GraphElement start, Node end, java.awt.Graphics2D g2)
Draws an arrow head/tail on the end of this edge where the node passed as argument is. The arrow head is painted like a semi-ellipse, the tail is painted as a black circle.
The arrow head is painted only if the end description for
end
is set to "to", whereas the tail is painted only if the end description forend
is set to "from".- Parameters:
start
- an inner node or a node the line is starting fromend
- the node where the line is ending and where the arrow head will point tog2
- the Graphics where to draw on
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Calculates the bounding rectangle of this edge. The bounding rectangle is the smallest rectangle including the nodes connected by this edge and its inner points.- Returns:
- the bounding rectangle of the edge
-
getSound
public java.io.InputStream getSound()
Returns a stream to a bell sound file. The sound is loaded in a static block defined in this class.- Returns:
- returns the
InputStream
to the sound of this node.
-
clone
public java.lang.Object clone()
-
-