public class KielerLayout extends AbstractGlobalLayout
See http://www.informatik.uni-kiel.de/rtsys/kieler/ for more information about KIELER.
KIELER - Kiel Integrated Environment for Layout for the Eclipse RichClientPlatform
The KIELER project tries to enhance graphical modeling pragmatics. Next to higher level solutions (meta layout, view management, structure-based editing, etc.) developed for Eclipse models, it also implements custom layout algorithms.
This class interfaces a standalone KIELER layout algorithm for actor oriented port based graphical diagrams with a Ptolemy diagram.
While KIELER is mainly developed for an Eclipse environment, most algorithms are also available standalone and can be used in a non-Eclipse environment. This class is an approach to leverage this by employing the algorithms within Ptolemy. Two standalone external libraries are required, one containing KIELER classes and a small subset of the Eclipse Modeling Framework (EMF), the other containing the Google Guava library, which is used as utility.
Calling the layout() method will create a new KIELER graph data structure, run KIELER layout algorithms on it and augment it with resulting layout information (locations and sizes of nodes, bend points of connections). Then this layout is applied to the Ptolemy model. Moving of nodes in Ptolemy is done via adding or changing location attributes.
Setting bend points was not supported in Ptolemy. Ptolemy's built-in
connection routing does not consider obstacle avoidance, hence overlaps
with other nodes and connections might appear. In order to gap this problem,
the actual drawing of the connections is performed by KielerLayoutConnector
instead of the standard Manhattan connector.
This KielerLayout stores bend points of connections
persistently in a Ptolemy model via LayoutHint
attributes
attached to relations. The KielerLayoutConnector then reads these
attributes and routes the edges accordingly. If the bend points are not
valid anymore, the attribute is removed and layout has to be performed again.
Constructor and Description |
---|
KielerLayout(LayoutTarget target)
Construct an instance taking a LayoutTarget for specifying some methods
for layout handling as given by the standard Ptolemy
AbstractGlobalLayout.
|
KielerLayout(LayoutTarget target,
CompositeActor ptolemyContainer)
Construct an instance setting the LayoutTarget as requested by the
AbstractGlobalLayout and the containing Ptolemy model.
|
Modifier and Type | Method and Description |
---|---|
protected static de.cau.cs.kieler.core.alg.InstancePool<de.cau.cs.kieler.kiml.AbstractLayoutProvider> |
_getLayouterPool()
Return a pool for layout provider instances that can be reused in subsequent layout
runs.
|
protected static de.cau.cs.kieler.core.math.KVector |
_getMultiportOffsets(Port port,
de.cau.cs.kieler.kiml.klayoutdata.KShapeLayout kportlayout,
int index,
int maxIndex,
boolean outer)
For a given Ptolemy port, its channel index in a multiport, and the
maximum index in that multiport, calculate its offset in X and Y
coordinates.
|
void |
layout(java.lang.Object composite)
Layout the given composite.
|
void |
setModel(CompositeEntity model)
Set the Ptolemy Model that contains the graph that is to be layouted.
|
void |
setTop(Top top)
Set the Top window to enable status reports on the status bar.
|
getLayoutTarget, setLayoutTarget
public KielerLayout(LayoutTarget target)
target
- The LayoutTarget on which layout will be performedpublic KielerLayout(LayoutTarget target, CompositeActor ptolemyContainer)
target
- The LayoutTarget on which layout will be performedptolemyContainer
- The composite actor that contains all elements to
be layoutedpublic void layout(java.lang.Object composite)
LayoutHint
s.layout
in interface GlobalLayout
layout
in class AbstractGlobalLayout
composite
- the container of the diagram in terms of a GraphModel.public void setModel(CompositeEntity model)
model
- The parent composite entity which internal diagram shall be layouted.public void setTop(Top top)
top
- The Top windowprotected static de.cau.cs.kieler.core.alg.InstancePool<de.cau.cs.kieler.kiml.AbstractLayoutProvider> _getLayouterPool()
protected static de.cau.cs.kieler.core.math.KVector _getMultiportOffsets(Port port, de.cau.cs.kieler.kiml.klayoutdata.KShapeLayout kportlayout, int index, int maxIndex, boolean outer)
port
- the Ptolemy portkportlayout
- the corresponding KPort KShapeLayoutindex
- index of the channelmaxIndex
- maximum available channelouter
- True if the direction of the ports is obtained by calling
IOPortController.getDirection(). Otherwise, the direction is obtained
by calling PtolemyModelUtil._getExternalPortDirection().