|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttemplates.diagram.DiagramElement
templates.diagram.Entity
public class Entity
Class to maintain the graphical representation of TemplateComponents.
| Nested Class Summary | |
|---|---|
protected class |
Entity.LabelBox
Class to maintain the graphical representation of the label of the entity. |
| Field Summary | |
|---|---|
protected TemplateComponent |
component
The TemplateComponent represented by the entity. |
static java.lang.String |
FLAG_MARK
Denotes if the FSA model for an entity has been modified after being assigned to the entity. |
protected static int |
LABEL_SPACING
Offset of the label box in pixels, to produce spacing around it. |
protected EntityLayout |
layout
The layout information of the entity. |
static int |
ON_ICON
Constant to say mouse cursor is over the icon of the entity. |
static int |
ON_LABEL
Constant to say mouse cursor is over the label of the entity. |
static int |
ON_NADA
Constant to say mouse cursor is not over any part of the entity. |
static int |
ON_PORT
Constant to say mouse cursor is over one of the connector handles of the entity. |
static int |
ON_SUP
Constant to say mouse cursor is over the "supervisor computation" shortcut icon (possible only if the entity is a channel). |
static int |
PORT_RADIUS
The radius of the connector handles on the sides the entity, in pixels. |
| 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 | |
|---|---|
Entity(TemplateComponent component)
Construct an entity for the layout of the given TemplateComponent
. |
|
Entity(TemplateComponent component,
EntityLayout layout)
Construct an entity for the given TemplateComponent with the
given EntityLayout. |
|
| Method Summary | |
|---|---|
protected void |
computeBounds()
Computes the bounds of the entity (smallest rectangle containing all elements of the entity) 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. |
void |
drawPlain(java.awt.Graphics2D g2d)
Renders only the icon and the label of the entity using the DiagramElement.COLOR_NORM color, in the given graphical context. |
java.awt.Rectangle |
getBounds()
Retrieve the bounds of the diagram element. |
TemplateComponent |
getComponent()
Retrieve the TemplateComponent represented by the entity. |
EntityIcon |
getIcon()
Retrieve the icon of the entity. |
java.lang.String |
getLabel()
Retrieve the label of the entity. |
java.awt.Point |
getLocation()
Retrieve the location of the entity. |
java.awt.Point[] |
getPorts()
Retrieve the center points of the connector handles. |
boolean |
intersects(java.awt.Rectangle r)
Checks if the given rectangle intersects the diagram element. |
void |
setIcon(EntityIcon icon)
Set the icon of the entity. |
void |
setLabel(java.lang.String label)
Set the label of the entity. |
void |
setLocation(java.awt.Point location)
Set the location of the entity. |
void |
translate(java.awt.Point delta)
NOTE: Do not use this method directly. |
void |
update()
Updates the entity to reflect any changes to the icon, label, location, type of entity, etc. |
int |
whereisPoint(java.awt.Point p)
Checks on which part of the entity 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 |
|---|
public static final java.lang.String FLAG_MARK
protected static final int LABEL_SPACING
public static final int PORT_RADIUS
public static final int ON_NADA
whereisPoint(Point),
Constant Field Valuespublic static final int ON_ICON
whereisPoint(Point),
Constant Field Valuespublic static final int ON_LABEL
whereisPoint(Point),
Constant Field Valuespublic static final int ON_PORT
whereisPoint(Point),
Constant Field Valuespublic static final int ON_SUP
whereisPoint(Point),
Constant Field Valuesprotected TemplateComponent component
TemplateComponent represented by the entity.
protected EntityLayout layout
| Constructor Detail |
|---|
public Entity(TemplateComponent component)
throws MissingLayoutException
TemplateComponent
.
component - the TemplateComponent which the entity will represent
MissingLayoutException - if the TemplateComponent has no annotation with an
EntityLayout (under the Annotable.LAYOUT key)
public Entity(TemplateComponent component,
EntityLayout layout)
TemplateComponent with the
given EntityLayout.
component - the TemplateComponent which the entity will representlayout - the layout information for the entity| Method Detail |
|---|
protected void computeBounds()
boundspublic TemplateComponent getComponent()
TemplateComponent represented by the entity.
TemplateComponent represented by the entitypublic 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 drawPlain(java.awt.Graphics2D g2d)
DiagramElement.COLOR_NORM color, in the given graphical context.
This method is to be used to render representations of the entity outside
of the drawing canvas, e.g., in dialog boxes.
g2d - the graphical context where the entity has to be renderedpublic java.awt.Point getLocation()
public void setLocation(java.awt.Point location)
NOTE: Do not use this method directly. Use
TemplateDiagram.translate(java.util.Collection, Point) instead.
location - the new location of the entitypublic void translate(java.awt.Point delta)
TemplateDiagram.translate(java.util.Collection, Point) instead.
translate in class DiagramElementdelta - the displacement in the x and y directionpublic void update()
public java.awt.Rectangle getBounds()
DiagramElement
getBounds in class DiagramElementpublic 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_ICON,
ON_LABEL, ON_PORT, ON_SUP or
ON_NADA)public java.lang.String getLabel()
public void setLabel(java.lang.String label)
NOTE: Do not use this method directly. Use
TemplateDiagram.labelEntity(Entity, String) instead.
label - the new label of the entitypublic java.awt.Point[] getPorts()
portspublic EntityIcon getIcon()
public void setIcon(EntityIcon icon)
NOTE: Do not use this method directly. Use
TemplateDiagram.setEntityIcon(Entity, EntityIcon) instead.
icon - the new icon of the entity
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||