|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.vergil.basic.layout.kieler.PtolemyModelUtil
public class PtolemyModelUtil
Class containing methods for manipulating Ptolemy models for the purpose of layout a graphical Ptolemy diagram. Methods for positioning Actors and creating vertices are available. The changes are performed by MoMLChangeRequests where as long as possible those requests get buffered in order to perform multiple changes at once for performance.
Red (cxh) |
Red (cxh) |
Field Summary | |
---|---|
private boolean |
_anyRequestsSoFar
Flag indicating whether there have been any MoMLChangeRequests processed so far or not. |
private static boolean |
_hide
Toggle variable to set the hidden status of unnecessary relation vertices. |
private java.lang.StringBuffer |
_momlChangeRequest
StringBuffer for Requests of Model changes. |
private java.util.Set<java.lang.String> |
_nameSet
Local cache of used names. |
private static int |
_uniqueCounter
A unique number that is used to determine unique String names for relations. |
Constructor Summary | |
---|---|
PtolemyModelUtil()
Construct an instance and initialize the internal request buffer. |
Method Summary | |
---|---|
protected java.lang.String |
_createRelation(java.lang.String relationName)
Create a new MoMLChangeRequest to add a new Relation. |
protected java.lang.String |
_createRelationWithVertex(java.lang.String relationName,
double x,
double y)
Create a new MoMLChangeRequest to add a new Relation with a Vertex at a given position. |
protected static double[] |
_getLocation(NamedObj namedObj)
Get the location given by the location attribute of the given input object. |
protected static java.util.Set<java.util.List<Relation>> |
_getRelationGroups(java.util.Set<Relation> relations)
For a set of relations get a set of relation groups, i.e. for each relation construct a list of relations that are all interconnected, either directly or indirectly. |
protected int |
_getUniqueNumber()
Get a unique number. |
protected java.lang.String |
_getUniqueString(CompositeActor actor,
java.lang.String prefix)
Get a unique String in the namespace of the given composite actor with the prefix that is also given. |
protected void |
_hideVertex(java.lang.String relationName,
java.lang.String vertexName,
boolean hide)
Hide a specific relation vertex. |
protected static boolean |
_isConnected(NamedObj namedObj)
Check whether the given Ptolemy model object has any connections, i.e. is connected to any other components via some link. |
protected static boolean |
_isInput(Port port)
Determine whether a given Port is an input port. |
protected void |
_link(java.lang.String type1,
java.lang.String name1,
java.lang.String type2,
java.lang.String name2)
Create a new MoMLChangeRequest to add a new link between arbitrary objects. |
protected void |
_linkPort(java.lang.String portName,
java.lang.String type2,
java.lang.String name2,
int index)
Link a port with something else (port or relation) at a specific index. |
protected void |
_linkPortInside(java.lang.String portName,
java.lang.String type2,
java.lang.String name2,
int insideIndex)
Link a port with something else (port or relation) at a specific inside index. |
protected void |
_performChangeRequest(CompositeActor actor)
Flush all buffered change requests to the given Actor. |
protected void |
_removeRelation(Relation relation,
CompositeActor actor)
Remove a single relation. |
protected void |
_removeRelations(java.util.Set<Relation> relationSet)
Create a MoMLChangeRequest to remove a set of relations in a Ptolemy model object. |
protected void |
_removeRelationVertex(Relation relation)
Remove a vertex from a relation. |
static void |
_removeUnnecessaryRelations(CompositeActor parent)
Remove all unnecessary relations within a composite actor. |
protected void |
_setLocation(NamedObj obj,
double x,
double y)
Create a MoMLChangeRequest to move a Ptolemy model object and schedule it immediately. |
protected void |
_setLocation(Vertex vertex,
Relation relation,
double x,
double y)
Create a MoMLChangeRequest to move a Ptolemy model object and schedule it immediately. |
protected static void |
_showUnnecessaryRelations(CompositeActor parent,
boolean show)
Show or hide unnecessary relation vertices. |
static void |
_showUnnecessaryRelationsToggle(CompositeActor parent)
Toggle show or hide status of unnecessary relation vertices. |
protected static java.lang.String |
_stripNumericSuffix(java.lang.String string)
Return a string that is identical to the specified string except any trailing digits are removed. |
protected void |
_unlinkPort(java.lang.String portName,
int index)
Unlink a port at the given channel index. |
protected void |
_unlinkPortInside(java.lang.String portName,
int insideIndex)
Unlink a port at the given channel inside index. |
protected void |
_unlinkRelations(java.lang.String relation1,
java.lang.String relation2)
Unlink two relations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean _anyRequestsSoFar
private java.lang.StringBuffer _momlChangeRequest
private static boolean _hide
private java.util.Set<java.lang.String> _nameSet
private static int _uniqueCounter
Constructor Detail |
---|
public PtolemyModelUtil()
Method Detail |
---|
protected java.lang.String _createRelation(java.lang.String relationName)
_performChangeRequest(CompositeActor)
must be called.
relationName
- Name of the new relation which needs to be unique
protected java.lang.String _createRelationWithVertex(java.lang.String relationName, double x, double y)
_performChangeRequest(CompositeActor)
must be called.
relationName
- Name of the new relation which needs to be uniquex
- coordinate of new vertexy
- coordinate of new vertex
protected void _hideVertex(java.lang.String relationName, java.lang.String vertexName, boolean hide)
relationName
- Name of the relation that contains the vertex.vertexName
- Name of the vertex.hide
- True iff the hide attribute should be set. Otherwise if it
should be unset.protected void _link(java.lang.String type1, java.lang.String name1, java.lang.String type2, java.lang.String name2)
_performChangeRequest(CompositeActor)
must be called.
type1
- type of the first item to be linked, e.g. port, relation,
relation1, relation2name1
- name of the first item to be linkedtype2
- type of the second item to be linked, e.g. port, relation,
relation1, relation2name2
- name of the second item to be linkedprotected void _linkPort(java.lang.String portName, java.lang.String type2, java.lang.String name2, int index)
portName
- Name of the port to be linked.type2
- Type of the second object, i.e. port or relation.name2
- Name of the second object to be linked.index
- Index of the relation in the channel list of the first port.protected void _linkPortInside(java.lang.String portName, java.lang.String type2, java.lang.String name2, int insideIndex)
portName
- Name of the port to be linked.type2
- Type of the second object, i.e. port or relation.name2
- Name of the second object to be linked.insideIndex
- Index of the relation in the channel list of the first port.protected void _removeRelation(Relation relation, CompositeActor actor)
relation
- Relation to be removed.actor
- Parent actor of the relation.protected void _removeRelations(java.util.Set<Relation> relationSet)
relationSet
- Set of relation to be removed from the Ptolemy modelpublic static void _removeUnnecessaryRelations(CompositeActor parent)
parent
- The composite actor in which to look for unnecessary relations.protected void _removeRelationVertex(Relation relation)
relation
- The relation to remove the vertex from.protected static double[] _getLocation(NamedObj namedObj)
namedObj
- The Ptolemy object for which the location should be
retrieved.
protected static java.util.Set<java.util.List<Relation>> _getRelationGroups(java.util.Set<Relation> relations)
relations
- Set of relations
protected int _getUniqueNumber()
protected java.lang.String _getUniqueString(CompositeActor actor, java.lang.String prefix)
CompositeEntity.uniqueName(String)
method of any
CompositeEntity. However, build a
local cache of used names and add the names that get created
by subsequent calls. I.e. multiple subsequent calls won't return
the same name even when the name of a former call is not used yet
in the composite actor.
The rationale is that for MoMLChangeRequests it is desireable to collect multiple changes (e.g. multiple object creations that all require a unique name).
actor
- CompositeActor in which to search for the names.prefix
- Given prefix that shall be suffixed to get a unique name.
protected static boolean _isConnected(NamedObj namedObj)
namedObj
- The Ptolemy model object which is to be analyzed
protected static boolean _isInput(Port port)
port
- The port to be analyzed
protected void _performChangeRequest(CompositeActor actor)
actor
- The target of the change request, e.g. the composite actor
containing the objects for which changes are requested.protected void _setLocation(NamedObj obj, double x, double y)
obj
- Ptolemy node to be movedx
- new coordinatey
- new coordinateprotected void _setLocation(Vertex vertex, Relation relation, double x, double y)
vertex
- Ptolemy node to be movedrelation
- Ptolemy Relation to be movedx
- new coordinatey
- new coordinateprotected static void _showUnnecessaryRelations(CompositeActor parent, boolean show)
parent
- Composite actor that should be searched for unnecessary vertices.show
- True iff the vertices should be shown, false if hidden.public static void _showUnnecessaryRelationsToggle(CompositeActor parent)
parent
- Composite actor that should be searched for unnecessary vertices.protected static java.lang.String _stripNumericSuffix(java.lang.String string)
string
- The string to strip of its numeric suffix.
protected void _unlinkPort(java.lang.String portName, int index)
portName
- Name of the Port.index
- Index of the channel to be unlinked.protected void _unlinkPortInside(java.lang.String portName, int insideIndex)
portName
- Name of the Port.insideIndex
- Index of the channel to be unlinked.protected void _unlinkRelations(java.lang.String relation1, java.lang.String relation2)
relation1
- Name of first relation to unlink.relation2
- Name of second relation to unlink.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |