|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttemplates.diagram.TemplateDiagram
public class TemplateDiagram
The class describing and maintaining the graphical representation of a
TemplateModel.
| Field Summary | |
|---|---|
protected java.util.Map<TemplateComponent,Entity> |
component2Entity
The Entitys in the temlpate diagram, indexed by their
corresponding TemplateComponents. |
protected java.util.Map<TemplateComponent,ides.api.model.fsa.FSAModel> |
component2FSA
Keep track of the FSAModel associated with each
TemplateComponent in the template diagram. |
protected java.util.Set<Connector> |
connectors
Collection of all the Connectors in the template diagram. |
static int |
DESIRED_DIAGRAM_INSET
The inset of the diagram (how much empty space to leave from the border of the canvas). |
protected java.util.Set<Entity> |
entities
Collection of all the Entitys in the template diagram. |
protected java.util.Map<ides.api.model.fsa.FSAModel,TemplateComponent> |
FSA2component
The TemplateComponents in the template diagram, indexed by the
FSAModels they contain. |
protected java.util.Map<TemplateLink,Connector> |
link2Connector
The Connectors in the template diagram, indexed by the
TemplateLinks they represent. |
protected TemplateModel |
model
The TemplateModel represented by this template diagram. |
protected java.util.Collection<DiagramElement> |
selection
Collection of the currently selected elements in the template diagram. |
| Constructor Summary | |
|---|---|
TemplateDiagram(TemplateModel m)
Construct a template diagram for the given TemplateModel. |
|
| Method Summary | |
|---|---|
void |
add(Connector c)
Add a Connector to the template diagram. |
void |
add(Entity entity)
Add an Entity to the template design. |
void |
addLink(Connector c,
TemplateLink link)
Add a given TemplateLink to a given Connector. |
void |
addSubscriber(TemplateDiagramSubscriber subscriber)
Attaches the given subscriber to this template diagram. |
void |
clearSelection()
Deselect all DiagramElements in the template diagram. |
void |
commitTranslation(java.util.Collection<DiagramElement> elements,
java.awt.Point delta)
Notifies listeners for changes to this template diagram that the given DiagramElements were translated, and adds the
UndoableEdit for the translation to the undo stack. |
Connector |
createConnector(Entity left,
Entity right)
Create a Connector between the given Entitys and add it
to the template diagram. |
Entity |
createEntity(java.awt.Point location)
Create an Entity (and the underlying TemplateComponent)
at the given location and add it to the template diagram. |
protected EntityLayout |
createLayout(TemplateComponent component)
Create new layout information for the given TemplateComponent. |
TemplateLink |
createLink(Connector c,
java.lang.String leftEvent,
java.lang.String rightEvent)
Create a new TemplateLink within a given Connector,
linking the given events from the "left" and "right"
TemplateComponents, correspondingly. |
void |
draw(java.awt.Graphics2D g2d)
Render the template diagram 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. |
protected void |
fireDiagramChanged(TemplateDiagramMessage message)
Notifies all subscribers that there has been a change to an element of this template diagram. |
protected void |
fireDiagramSelectionChanged(TemplateDiagramMessage message)
Notifies all subscribers that there has been a change to the set of selected elements in this template diagram. |
protected void |
flagModel(ides.api.model.fsa.FSAModel model)
Flags the TemplateComponent associated with the given
FSAModel. |
void |
fsaEventSetChanged(ides.api.model.fsa.FSAMessage arg0)
Flags the TemplateComponent associated with the FSAModel
(since the FSAModel has been modified). |
void |
fsaStructureChanged(ides.api.model.fsa.FSAMessage arg0)
Flags the TemplateComponent associated with the FSAModel
(since the FSAModel has been modified). |
java.util.Collection<Connector> |
getAdjacentConnectors(Entity entity)
Retrieve a collection of all the Connectors linking the given
Entity to other Entitys. |
protected DiagramElement |
getAnyElement()
Returns an arbitrary element from the template diagram, if one exists. |
java.awt.Rectangle |
getBounds()
Retrieve the bounds of the template diagram (the smallest rectangle which contains all elements in the template diagram). |
java.util.Collection<Entity> |
getChannels()
Retrieve a collection of all the channel Entitys in the
template diagram. |
Connector |
getConnector(Entity left,
Entity right)
Retrieve the Connector between the given Entitys. |
Connector |
getConnectorAt(java.awt.Point location)
Retrieve the Connector which contains the given point. |
Connector |
getConnectorFor(TemplateLink link)
Retrieve the Connector which contains the given
TemplateLink. |
java.util.Collection<Connector> |
getConnectors()
Retrieve a collection of all Connectors in the template diagram. |
TemplateDiagramSubscriber[] |
getDiagramSubscribers()
Returns all current subscribers to this template diagram. |
java.util.Collection<Entity> |
getEntities()
Retrieve a collection of all the Entitys in the template diagram. |
Entity |
getEntityAt(java.awt.Point location)
Retrieve the Entity which contains the given point. |
Entity |
getEntityFor(TemplateComponent component)
Retrieve the Entity which represents the given
TemplateComponent. |
Entity |
getEntityWithFSA(ides.api.model.fsa.FSAModel fsa)
Retrieve the Entity which represents a TemplateComponent
associated with the given FSAModel. |
TemplateModel |
getModel()
Retrieve the TemplateModel represented by this template diagram. |
java.util.Collection<Entity> |
getModules()
Retrieve a collection of all the module Entitys in the
template diagram. |
java.util.Collection<DiagramElement> |
getSelection()
Retrieve the collection of currently selected DiagramElements. |
boolean |
hasEntitiesAt(java.awt.Rectangle area)
Check if there are Entitys in the given area. |
void |
labelEntity(Entity entity,
java.lang.String label)
Label the given Entity with the given label. |
protected void |
recoverLayout()
Retrieve the layout annotations from the underlying TemplateModel
elements (under the Annotable.LAYOUT key) and build the
corresponding diagram elements. |
void |
release()
Unsubscribe this template diagram from the underlying TemplateModel and stop listening to notifications of changes to
the TemplateModel. |
void |
remove(Connector c)
Remove a Connector from the template diagram (and the associated
TemplateLinks from the underlying TemplateModel). |
void |
remove(Entity entity)
Remove an Entity from the template design (and the corresponding
TemplateComponent from the underlying TemplateModel). |
void |
removeLink(Connector c,
TemplateLink link)
Remove a given TemplateLink from a given Connector. |
void |
removeSubscriber(TemplateDiagramSubscriber subscriber)
Removes the given subscriber to this template diagram. |
void |
setEntityIcon(Entity entity,
EntityIcon icon)
Set the icon of the given Entity. |
void |
setSelection(java.util.Collection<DiagramElement> selection)
Set which DiagramElements are selected. |
void |
templateModelStructureChanged(TemplateModelMessage message)
Called when there has been a change to the structure of the TemplateModel to whose TemplateModelPublisher this
listener subscribes. |
void |
translate(java.util.Collection<DiagramElement> elements,
java.awt.Point delta)
Translates the given diagram elements with the given displacement and updates the rest of the diagram elements to reflect the change. |
void |
translate(java.awt.Point delta)
Translates all elements in the diagram with the given displacement. |
protected void |
updateEmptyConnectorList()
Update the list of empty connectors in the template diagram (i.e., Connectors which do not contain any TemplateLinks), and
add the information to the underlying TemplateModel as a layout
annotation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DESIRED_DIAGRAM_INSET
protected java.util.Set<Entity> entities
Entitys in the template diagram.
protected java.util.Map<TemplateComponent,Entity> component2Entity
Entitys in the temlpate diagram, indexed by their
corresponding TemplateComponents.
protected java.util.Set<Connector> connectors
Connectors in the template diagram.
protected java.util.Map<TemplateLink,Connector> link2Connector
Connectors in the template diagram, indexed by the
TemplateLinks they represent.
protected java.util.Map<TemplateComponent,ides.api.model.fsa.FSAModel> component2FSA
FSAModel associated with each
TemplateComponent in the template diagram. This is necessary in
order to be able to unsubscribe from an FSAModel if it gets
replaced (and thus no longer accessible through the
TemplateComponent).
protected java.util.Map<ides.api.model.fsa.FSAModel,TemplateComponent> FSA2component
TemplateComponents in the template diagram, indexed by the
FSAModels they contain.
protected TemplateModel model
TemplateModel represented by this template diagram.
protected java.util.Collection<DiagramElement> selection
| Constructor Detail |
|---|
public TemplateDiagram(TemplateModel m)
TemplateModel.
m - the TemplateModel to be represented by the template
diagram| Method Detail |
|---|
public void addSubscriber(TemplateDiagramSubscriber subscriber)
subscriber - the subscriber to addpublic void removeSubscriber(TemplateDiagramSubscriber subscriber)
subscriber - the subscriber to removepublic TemplateDiagramSubscriber[] getDiagramSubscribers()
protected void fireDiagramChanged(TemplateDiagramMessage message)
TemplateModel
that layout information has changed.
message - the description of the changeprotected void fireDiagramSelectionChanged(TemplateDiagramMessage message)
message - the description of the new set of selected elementsprotected void recoverLayout()
TemplateModel
elements (under the Annotable.LAYOUT key) and build the
corresponding diagram elements. In essence, computes how to render the
underlying TemplateModel.
protected EntityLayout createLayout(TemplateComponent component)
TemplateComponent.
Called internally when the layout annotation of the
TemplateComponent is missing.
component - the TemplateComponent whose layout has to be generated
TemplateComponentpublic void templateModelStructureChanged(TemplateModelMessage message)
TemplateModelSubscriberTemplateModel to whose TemplateModelPublisher this
listener subscribes.
templateModelStructureChanged in interface TemplateModelSubscribermessage - the description of the changepublic TemplateModel getModel()
TemplateModel represented by this template diagram.
TemplateModel represented by this template diagrampublic void release()
TemplateModel and stop listening to notifications of changes to
the TemplateModel.
This method should be called only just before disposing of this template diagram.
public Entity createEntity(java.awt.Point location)
Entity (and the underlying TemplateComponent)
at the given location and add it to the template diagram. The new
TemplateComponent will be of type module.
location - the location for the new Entity
Entitypublic void add(Entity entity)
Entity to the template design.
entity - the Entity to addpublic void remove(Entity entity)
Entity from the template design (and the corresponding
TemplateComponent from the underlying TemplateModel). All
Connectors linked to the Entity (and the corresponding
TemplateLinks) are removed as well. If the Entity is not
a part of the template design, the method does nothing.
entity - the Entity to remove
public void labelEntity(Entity entity,
java.lang.String label)
Entity with the given label.
entity - the Entity to be labelledlabel - the new label for the Entity
public void setEntityIcon(Entity entity,
EntityIcon icon)
Entity.
entity - the Entity whose icon has to be seticon - the new icon for the Entitypublic Entity getEntityAt(java.awt.Point location)
Entity which contains the given point. If there is
more than one Entity which contains the point, returns one of
these Entitys arbitrarily. If there is no Entity which
contains the point, returns null.
location - the point to be used to locate the Entity
Entitys which contain the point;
null if no Entity contains the pointpublic boolean hasEntitiesAt(java.awt.Rectangle area)
Entitys in the given area. An Entity
is considered to be in the area if a part of it intersects the area.
area - the area to examine for Entitys
true if a part of at least one Entity
intersects the given area; false otherwisepublic java.util.Collection<Entity> getEntities()
Entitys in the template diagram.
Entitys in the template diagrampublic java.util.Collection<Entity> getModules()
Entitys in the
template diagram.
Entitys in the
template diagrampublic java.util.Collection<Entity> getChannels()
Entitys in the
template diagram.
Entitys in the
template diagrampublic java.util.Collection<Connector> getAdjacentConnectors(Entity entity)
Connectors linking the given
Entity to other Entitys.
entity - the Entity whose Connectors should be
retrieved
Connectors linking the given
Entity to other Entitys
public Connector getConnector(Entity left,
Entity right)
Connector between the given Entitys. If
there is more than one Connector between the given Entity
s, return one of these Connectors arbitrarily (note that this
situation can happen only in inconsistent template diagrams). If there is
no Connector between the given Entitys, return
null.
A connector is symmetric. "Left" and "right" are used only to distinguish between the linked entities.
left - the first Entityright - the second Entity
Connector between the given Entitys;
null if no such Connector exists
public Connector createConnector(Entity left,
Entity right)
Connector between the given Entitys and add it
to the template diagram. If a Connector between the given
Entitys already exists, do nothing.
A connector is symmetric. "Left" and "right" are used only to distinguish between the linked entities.
left - the first Entity to be linkedright - the second Entity to be linked
Connector, or the existing
Connector if a Connector between the given
Entitys already exists
InconsistentModificationException - if one or both of the given Entitys are not part of
the template diagrampublic void add(Connector c)
Connector to the template diagram.
c - the Connector to be added
InconsistentModificationException - if one or both of the Entitys linked by the
Connector are not part of the template diagram, or if
there is already a Connector between the
Entitys linked by the given Connectorpublic void remove(Connector c)
Connector from the template diagram (and the associated
TemplateLinks from the underlying TemplateModel). If the
given Connector is not a part of the diagram, the method does
nothing.
c - the Connector to remove
public TemplateLink createLink(Connector c,
java.lang.String leftEvent,
java.lang.String rightEvent)
TemplateLink within a given Connector,
linking the given events from the "left" and "right"
TemplateComponents, correspondingly. If the given
Connector is not a part of the template diagram, the method does
nothing and returns null.
A connector is symmetric. "Left" and "right" are used only to distinguish between the linked components.
c - the connector to include the new TemplateLinkleftEvent - the event (from the "left" TemplateComponent) to be
linkedrightEvent - the event (from the "right" TemplateComponent) to be
linked
TemplateLink, or null if
the given connector is not a part of the template diagram
public void addLink(Connector c,
TemplateLink link)
TemplateLink to a given Connector. If the
given Connector is not a part of the template diagram, the method
does nothing.
c - the Connector to which to add the TemplateLinklink - the TemplateLink to be added to the Connector
InconsistentModificationException - if the TemplateLink to be added does not link the
same TemplateComponents linked by the
Connector
public void removeLink(Connector c,
TemplateLink link)
TemplateLink from a given Connector. If
the given Connector is not a part of the template diagram, or if
the TemplateLink is not contained in the Connector, the
method does nothing.
c - the Connector from which to remove the
TemplateLinklink - the TemplateLink to remove from the Connectorpublic java.util.Collection<Connector> getConnectors()
Connectors in the template diagram.
Connectors in the template diagrampublic Connector getConnectorAt(java.awt.Point location)
Connector which contains the given point. If there
is more than one Connector which contains the point, returns one
of these Connectors arbitrarily. If there is no Connector
which contains the point, returns null.
location - the point to be used to locate the Connector
Connectors which contain the point;
null if no Connector contains the pointpublic java.awt.Rectangle getBounds()
protected DiagramElement getAnyElement()
null.
null if the template diagram is emptypublic void translate(java.awt.Point delta)
delta - the displacement to be used for the translation
public void translate(java.util.Collection<DiagramElement> elements,
java.awt.Point delta)
elements - the diagram elements to be translateddelta - the displacement to be used for the translation
public void commitTranslation(java.util.Collection<DiagramElement> elements,
java.awt.Point delta)
DiagramElements were translated, and adds the
UndoableEdit for the translation to the undo stack.
This method is to be called only if diagram elements are translated
without invoking the translate(Point) and
translate(Collection, Point) methods (e.g., when dragging
elements with the mouse), once after all related translations are
complete (e.g., at the end of mouse dragging).
elements - the translated DiagramElementsdelta - the displacement of the translationpublic void draw(java.awt.Graphics2D g2d)
g2d - the graphical context where the diagram element has to be
rendered
public void draw(java.awt.Graphics2D g2d,
boolean showInconsistency)
g2d - 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 setSelection(java.util.Collection<DiagramElement> selection)
DiagramElements are selected.
selection - the new collection of selected DiagramElements (can be
empty)public java.util.Collection<DiagramElement> getSelection()
DiagramElements.
DiagramElementspublic void clearSelection()
DiagramElements in the template diagram.
public Connector getConnectorFor(TemplateLink link)
Connector which contains the given
TemplateLink.
link - the TemplateLink whose Connector is to be
retrieved
Connector which contains the given
TemplateLink, or null if no
Connector in the template diagram contains the given
TemplateLinkpublic Entity getEntityFor(TemplateComponent component)
Entity which represents the given
TemplateComponent.
component - the TemplateComponent whose Entity has to be
retrieved
Entity which represents the given
TemplateComponent, or null if no
Entity in the template diagram represents the given
TemplateComponentpublic Entity getEntityWithFSA(ides.api.model.fsa.FSAModel fsa)
Entity which represents a TemplateComponent
associated with the given FSAModel.
fsa - the FSAModel to be used to retrieve the Entity
Entity which represents a TemplateComponent
associated with the given FSAModel, or null
if no Entity in the template diagram represents a
TemplateComponent which is associated with the given
FSAModelprotected void updateEmptyConnectorList()
Connectors which do not contain any TemplateLinks), and
add the information to the underlying TemplateModel as a layout
annotation. Such an additional annotation is necessary as no
TemplateLinks will carry the information about the empty
connectors.
public void fsaEventSetChanged(ides.api.model.fsa.FSAMessage arg0)
TemplateComponent associated with the FSAModel
(since the FSAModel has been modified).
fsaEventSetChanged in interface ides.api.model.fsa.FSASubscriberpublic void fsaStructureChanged(ides.api.model.fsa.FSAMessage arg0)
TemplateComponent associated with the FSAModel
(since the FSAModel has been modified).
fsaStructureChanged in interface ides.api.model.fsa.FSASubscriberprotected void flagModel(ides.api.model.fsa.FSAModel model)
TemplateComponent associated with the given
FSAModel. If no TemplateComponent is associated with the
given FSAModel, the method does nothing.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||