Class LayeredArrangement
- All Implemented Interfaces:
GraphArrangement
An arrangement for flows: every edge points the same way, from one layer to the next, with as few crossings as it can find.
This is the method of Sugiyama, Tagawa and Toda in four passes. Cycles are broken by reversing the edges a depth first search finds going back; nodes are put on layers by their longest path from a source; an edge that spans several layers gets a hidden point on each so it bends around the nodes between; the order inside each layer is improved by sweeping down and up, moving each node to the median of its neighbours; and each node is then pulled towards its neighbours without overlapping the next one.
The edges get routes through their hidden points. Pinned nodes are placed like any other: a layered picture has no room for a node that stays put.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLayers run across the screen and edges point right.static final intLayers run down the screen and edges point down. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarrange(GraphModel model) Computes a position for every node, and a route for edges the arrangement bends.intTOP_TO_BOTTOM, the default, orLEFT_TO_RIGHT.doubleThe space between layers in world units.doubleThe space between nodes on one layer in world units.booleanTrue when a node stays inside the band of its lane.voidsetDirection(int direction) Sets the direction edges point.voidsetLayerGap(double layerGap) Sets the space between layers.voidsetNodeGap(double nodeGap) Sets the space between nodes on one layer.voidsetRespectLanes(boolean respectLanes) Keeps each node inside the band of the lane it belongs to.
-
Field Details
-
TOP_TO_BOTTOM
public static final int TOP_TO_BOTTOMLayers run down the screen and edges point down.- See Also:
-
LEFT_TO_RIGHT
public static final int LEFT_TO_RIGHTLayers run across the screen and edges point right.- See Also:
-
-
Constructor Details
-
LayeredArrangement
public LayeredArrangement()
-
-
Method Details
-
getDirection
public int getDirection()TOP_TO_BOTTOM, the default, orLEFT_TO_RIGHT. -
setDirection
public void setDirection(int direction) Sets the direction edges point. -
getLayerGap
public double getLayerGap()The space between layers in world units. -
setLayerGap
public void setLayerGap(double layerGap) Sets the space between layers. -
getNodeGap
public double getNodeGap()The space between nodes on one layer in world units. -
setNodeGap
public void setNodeGap(double nodeGap) Sets the space between nodes on one layer. -
isRespectLanes
public boolean isRespectLanes()True when a node stays inside the band of its lane. -
setRespectLanes
public void setRespectLanes(boolean respectLanes) Keeps each node inside the band of the lane it belongs to. The layers still say how far along the lanes a node goes; across them, the nodes of one lane on one layer are spread over that lane's band in the order the arrangement gave them, and the picture starts where the lanes do.
It applies to lanes that run along the direction: horizontal lanes with
LEFT_TO_RIGHT, vertical ones withTOP_TO_BOTTOM. A lane lying the other way is treated as no lane. The nodes in no lane keep the arrangement they had among themselves, placed past the last lane. An edge gets no route through hidden points then, since a node moved into its band is no longer where the route went around it. Off by default.The lanes are taken as they are, and none is resized: make a lane as wide as the nodes it has to hold side by side, or they spill over its edge. The first layer starts
getNodeGapfrom the start of the lanes, which is the room a lane's title needs. -
arrange
Description copied from interface:GraphArrangementComputes a position for every node, and a route for edges the arrangement bends.- Specified by:
arrangein interfaceGraphArrangement
-