|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttemplates.diagram.DiagramElement
templates.diagram.Connector
public class Connector
Class to maintain the graphical representation of TemplateLinks.
| Nested Class Summary | |
|---|---|
protected class |
Connector.EventBox
Encapsulation of a graphical element which displays the events linked through a Connector. |
| Field Summary | |
|---|---|
protected static java.awt.Color |
BACKGROUND_COLOR
Background color for the event boxes at the ends of the connector. |
protected Connector.EventBox |
centerEventBox
The event box in the center of the connector, displaying the event pairs linked by the connector. |
protected static int |
LABEL_SPACING
Offset of the event boxes in pixels, to produce spacing around the event boxes. |
protected Entity |
left
The "left" component linked by the connector. |
protected Connector.EventBox |
leftEventBox
The event box listing the events of the "left" component which are linked by the connector. |
protected java.awt.geom.Line2D |
line
The line that represents the connector. |
protected java.util.Collection<TemplateLink> |
links
The TemplateLinks visualized by this connector. |
static int |
ON_LABEL
Constant to say mouse cursor is over the event box in the center of the connector. |
static int |
ON_LINE
Constant to say mouse cursor is over the line of the connector. |
static int |
ON_NADA
Constant to say mouse cursor is not over any part of the connector. |
protected Entity |
right
The "right" component linked by the connector. |
protected Connector.EventBox |
rightEventBox
The event box listing the events of the "right" component which are linked by the connector. |
| Fields inherited from class templates.diagram.DiagramElement |
|---|
COLOR_INCONSIST, COLOR_NORM, COLOR_SELECT, COLOR_SELECT_INCONSIST, FAT_LINE_STROKE, globalFont, globalFontRenderer, highlight, inconsistent, LINE_STROKE, MARKER_STROKE, selected |
| Constructor Summary | |
|---|---|
Connector(Entity left,
Entity right,
java.util.Collection<TemplateLink> links)
Construct a connector with the given parameters. |
|
| Method Summary | |
|---|---|
void |
addLink(TemplateLink link)
Add a TemplateLink to the collection of links represented by the
connector. |
protected void |
computeBounds()
Computes the bounds of the connector (smallest rectangle containing all elements of the connector) and caches the result. |
boolean |
contains(java.awt.Point p)
Checks if the diagram element contains the given point. |
void |
draw(java.awt.Graphics2D g2d)
Render the diagram element in the given graphical context, disregarding the inconsistency setting. |
void |
draw(java.awt.Graphics2D g2d,
boolean showInconsistency)
Render the diagram element in the given graphical context, according to the choice of differentiating or not inconsistent diagram elements. |
java.awt.Rectangle |
getBounds()
Retrieve the bounds of the diagram element. |
Entity[] |
getEntities()
Retrieve the two Entitys linked by the connector. |
Entity |
getLeftEntity()
Retrieve the "left" Entity linked by the connector. |
java.util.Collection<TemplateLink> |
getLinks()
Retrieve the TemplateLinks encapsulated by the connector. |
Entity |
getRightEntity()
Retrieve the "right" Entity linked by the connector. |
boolean |
intersects(java.awt.Rectangle r)
Checks if the given rectangle intersects the diagram element. |
void |
removeLink(TemplateLink link)
Remove a TemplateLink from the collection of links represented by
this connector. |
void |
translate(java.awt.Point delta)
NOTE: Do not use this method directly. |
void |
update()
Updates the connector to reflect any changes to the location of the linked Entitys and/or the events being linked. |
int |
whereisPoint(java.awt.Point p)
Checks on which part of the connector a given point lies. |
| Methods inherited from class templates.diagram.DiagramElement |
|---|
getGlobalFont, getGlobalFontMetrics, getGlobalFontRenderer, setGlobalFont, setGlobalFontRenderer, setHighlight, setInconsistent, setSelected |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static java.awt.Color BACKGROUND_COLOR
protected static final int LABEL_SPACING
public static final int ON_NADA
whereisPoint(Point),
Constant Field Valuespublic static final int ON_LINE
whereisPoint(Point),
Constant Field Valuespublic static final int ON_LABEL
whereisPoint(Point),
Constant Field Valuesprotected java.util.Collection<TemplateLink> links
TemplateLinks visualized by this connector.
protected Entity left
A connector is symmetric. "Left" and "right" are used only to enable addressing the two linked components separately.
protected Entity right
A connector is symmetric. "Left" and "right" are used only to enable addressing the two linked components separately.
protected java.awt.geom.Line2D line
protected Connector.EventBox leftEventBox
A connector is symmetric. "Left" and "right" are used only to enable addressing the two linked components separately.
protected Connector.EventBox rightEventBox
A connector is symmetric. "Left" and "right" are used only to enable addressing the two linked components separately.
protected Connector.EventBox centerEventBox
| Constructor Detail |
|---|
public Connector(Entity left,
Entity right,
java.util.Collection<TemplateLink> links)
left - the "left" component to be linked by the connectorright - the "right" component to be linked by the connectorlinks - a collection of the TemplateLinks to be encapsulated
by the connector (can be empty)
A connector is symmetric. "Left" and "right" are used only to enable addressing the two linked components separately.
| Method Detail |
|---|
public java.util.Collection<TemplateLink> getLinks()
TemplateLinks encapsulated by the connector. If
there are no links associated with this connector, the returned
collection is empty.
TemplateLinks encapsulated by the connectorpublic Entity getLeftEntity()
Entity linked by the connector.
A connector is symmetric. "Left" and "right" are used only to enable addressing the two linked components separately.
Entity linked by the connectorpublic Entity getRightEntity()
Entity linked by the connector.
A connector is symmetric. "Left" and "right" are used only to enable addressing the two linked components separately.
Entity linked by the connectorpublic Entity[] getEntities()
Entitys linked by the connector.
Entitys linked by the connectorpublic void addLink(TemplateLink link)
TemplateLink to the collection of links represented by the
connector. The link must be between the two TemplateComponents
already linked by the connector.
NOTE: Do not use this method directly. Use
TemplateDiagram.addLink(Connector, TemplateLink) instead.
link - the TemplateLink to be added to the collection of
links represented by the connector
InconsistentModificationException - if the TemplateLink to be added does not link the
same TemplateComponents linked by the connectorpublic void removeLink(TemplateLink link)
TemplateLink from the collection of links represented by
this connector. If the link is not part of the collection, the method
does nothing.
NOTE: Do not use this method directly. Use
TemplateDiagram.removeLink(Connector, TemplateLink) instead.
link - the TemplateLink to remove from the collection of
links represented by this connectorpublic void draw(java.awt.Graphics2D g2d)
DiagramElement
draw in class DiagramElementg2d - the graphical context where the diagram element has to be
rendered
public void draw(java.awt.Graphics2D g2d,
boolean showInconsistency)
DiagramElement
draw in class DiagramElementg2d - the graphical context where the diagram element has to be
renderedshowInconsistency - choice for rendering inconsistent diagram elements differently
or not; if true, inconsistent diagram elements
have to be rendered differently; iffalse,
inconsistent diagram elements should be rendered as if they
were consistentpublic void translate(java.awt.Point delta)
TemplateDiagram.translate(Collection, Point) instead.
translate in class DiagramElementdelta - the displacement in the x and y directionpublic java.awt.Rectangle getBounds()
DiagramElement
getBounds in class DiagramElementprotected void computeBounds()
boundspublic void update()
Entitys and/or the events being linked. In essence,
recomputes how the connector should be rendered. The layout of connectors
is computed in its entirety, no layout information needs to be preserved
between sessions.
public boolean contains(java.awt.Point p)
DiagramElement
With non-rectangular diagram elements, this is different from checking if
the point is contained within the bounds of the element. More
specifically, a point may be contained within the bounds, but this method
may still return false.
contains in class DiagramElementp - the point to be checked
true if the diagram element contains the point;
false otherwisepublic boolean intersects(java.awt.Rectangle r)
DiagramElement
With non-rectangular diagram elements, this is different from checking if
the rectangle intersects the bounds of the element. More specifically, a
rectangle may intersect the bounds, but this method may still return
false.
intersects in class DiagramElementr - the rectangle to be checked
true if the rectangle intersects the diagram
element; false otherwisepublic int whereisPoint(java.awt.Point p)
p - the point to be checked
ON_LINE,
ON_LABEL or ON_NADA)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||