Search this API

y.layout.orthogonal
Class CompactOrthogonalLayouter

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.PartitionLayouter
          extended by y.layout.orthogonal.CompactOrthogonalLayouter
All Implemented Interfaces:
Layouter, LayoutStage

public class CompactOrthogonalLayouter
extends PartitionLayouter

This layout algorithm arranges a graph in a compact, orthogonal fashion.

Layout Style

This layout algorithm is a variant of OrthogonalLayouter that tries to arrange nodes in a more compact way. It allows to specify a desired aspect ratio for the bounds of the calculated layout. Nodes of a given graph are arranged such that each edge is drawn as an alternating sequence of horizontal and vertical segments.

CompactOrthogonalLayouter is well suited for small and medium-sized sparse graphs and produces compact drawings with no overlapping nodes, few crossings and few bends. It is also especially suitable for printing the diagram on a paper of predefined size. As a disadvantage, this algorithm will usually produce less elegant edge routes than the ones of OrthogonalLayouter.

Application domains of orthogonal drawings are software engineering, project management, function call graphs and object-oriented class diagrams.


Sample output of the layout algorithm with aspect ratio 1.0

Concept

This algorithm is implemented as a PartitionLayouter and applies the following steps:

Each of these steps can be individually configured and/or replaced. To do so, use methods PartitionLayouter.setPartitionFinder(PartitionFinder), AbstractLayoutStage.setCoreLayouter(y.layout.Layouter), PartitionLayouter.setPartitionPlacer(PartitionPlacer) and PartitionLayouter.setInterEdgeRouter(InterEdgeRouter), respectively.

Features

The aspect ratio of the resulting layout bounds, i.e., the ratio of width/height of the layout, can be configured using setAspectRatio(double). CompactOrthogonalLayouter tries to reach this preferred value. However, depending on the actual graph structure, this may not always be possible.

Octilinear routing of edges can be supported by appending PolylineLayoutStage.

 

Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.PartitionLayouter
PartitionLayouter.ChannelInterEdgeRouter, PartitionLayouter.ComponentPartitionPlacer, PartitionLayouter.EdgeBetweennessPartitionFinder, PartitionLayouter.InterEdgeRouter, PartitionLayouter.OrthogonalInterEdgeRouter, PartitionLayouter.PartitionFinder, PartitionLayouter.PartitionPlacer, PartitionLayouter.PolylineInterEdgeRouter
 
Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
CompactOrthogonalLayouter()
          Creates a new CompactOrthogonalLayouter instance with default settings.
 
Method Summary
 double getAspectRatio()
          Returns the desired aspect ratio (that is the quotient width/height) of the resulting layout bounds.
 int getGridSpacing()
          Returns the equidistant spacing between the horizontal and vertical grid lines.
 void setAspectRatio(double aspectRatio)
          Specifies the desired aspect ratio (that is the quotient width/height) of the resulting layout bounds.
 void setGridSpacing(int gridSpacing)
          Specifies the equidistant spacing between the horizontal and vertical grid lines.
 
Methods inherited from class y.layout.PartitionLayouter
canLayout, doLayout, getInterEdgeRouter, getPartitionFinder, getPartitionPlacer, setInterEdgeRouter, setPartitionFinder, setPartitionPlacer
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompactOrthogonalLayouter

public CompactOrthogonalLayouter()
Creates a new CompactOrthogonalLayouter instance with default settings.

Method Detail

getGridSpacing

public int getGridSpacing()
Returns the equidistant spacing between the horizontal and vertical grid lines.

Each node will be placed on a grid point. Edges will be routed such that their segments lie on grid lines, if the endpoints of the edges allow to place the ports accordingly.

The grid spacing has to be greater than 0.

 
Setting the grid spacing will only have an effect if the configurable stages have not been replaced by other custom stage implementations.
Returns:
the grid spacing
See Also:
setGridSpacing(int)

setGridSpacing

public void setGridSpacing(int gridSpacing)
Specifies the equidistant spacing between the horizontal and vertical grid lines.

Each node will be placed on a grid point. Edges will be routed such that their segments lie on grid lines, if the endpoints of the edges allow to place the ports accordingly.

The grid spacing has to be greater than 0.

 
Setting the grid spacing will only have an effect if the configurable stages have not been replaced by other custom stage implementations.
Default Value:
The default value is 20.
Parameters:
gridSpacing - the grid spacing
Throws:
java.lang.IllegalArgumentException - if the grid spacing is negative or zero
Sample Graphs:

Grid spacing 20.

Grid spacing 40.

getAspectRatio

public double getAspectRatio()
Returns the desired aspect ratio (that is the quotient width/height) of the resulting layout bounds.

The aspect ratio needs to be greater than 0.

 
This setting will only have an effect if the partition placer is of type PartitionLayouter.ComponentPartitionPlacer.
Returns:
the desired aspect ratio
See Also:
setAspectRatio(double), PartitionLayouter.setPartitionPlacer(PartitionPlacer), PartitionLayouter.ComponentPartitionPlacer

setAspectRatio

public void setAspectRatio(double aspectRatio)
Specifies the desired aspect ratio (that is the quotient width/height) of the resulting layout bounds.

The aspect ratio needs to be greater than 0.

 
This setting will only have an effect if the partition placer is of type PartitionLayouter.ComponentPartitionPlacer.
Default Value:
The default value is 1.
Parameters:
aspectRatio - the desired aspect ratio
Throws:
java.lang.IllegalArgumentException - if the given aspect ratio is less than or equal to zero
See Also:
PartitionLayouter.setPartitionPlacer(PartitionPlacer), PartitionLayouter.ComponentPartitionPlacer
Sample Graphs:

Aspect ratio 1.0.

Aspect ratio 0.5.

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.