Search this API

y.layout.circular
Class CompactDiskLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.circular.CompactDiskLayouter
All Implemented Interfaces:
Layouter

public class CompactDiskLayouter
extends CanonicMultiStageLayouter

This layout algorithm arranges a graph on a disk packing the nodes as dense as possible.

Layout Style

The nodes are arranged on a disk such that the disk's radius is minimized. The layout mostly optimizes the dense placement of the nodes, while edges play a minor role. Hence, the compact disk layout is mostly suitable for graphs with small components whose loosely connected nodes should be grouped and packed in a small area.



Concept

The CompactDiskLayouter arranges the nodes on a disk from the inside out packing them as dense as possible. During this iterative process it avoids node overlaps and label overlaps (if activated; see setIntegratedNodeLabelingEnabled(boolean) and setConsiderNodeLabelsEnabled(boolean)). In particular, to keep the layout compact the CompactDiskLayouter may decide to place a single node or multiple nodes in the center of the disk.

Features

Connected Components

By default, the CompactDiskLayouter takes the connected components for the placement of the nodes into account. In that case the nodes of the same component are placed sequentially in the iterative placement process ensuring that they form a visual component.

Input graph consisting of multiple components.

Compact disk layout.

Node Types

If node types are defined, the CompactDiskLayouter takes these into account instead of the connected components. In particular, nodes of the same type are placed closely together forming a visual component.

Input graph with node types 'A', 'B' and 'C'.

Compact disk layout taking the node types for the placement of the nodes into account.

From Sketch

Use setFromSketchModeEnabled(boolean) to take the coordinates of the input diagram into account when arranging the nodes on the disk.

Input graph where the nodes are roughly placed on circles.

Compact disk layout taking the coordinates of the input diagram into account.

Node Labeling

The CompactDiskLayouter allows for integrated node labeling. Node labels are placed automatically without generating overlaps with other labels or graph elements. There are different ways to place node labels.

 
This layout is mostly suitable for (sub-)graphs with few edges or small components, as edges may easily cross the center of the disk producing a cluttered appearance. In particular, it is suitable for winding paths around a center.
 
The layout is optimized for nodes whose shapes are circles (preferably of unit size). In case that the shapes of the nodes are not circles, add a node halo (possibly of size 0) to the nodes in order to avoid node overlaps: this lets the layout algorithm consider the circumcircle of the halo.

Rectangular nodes without halos may partly overlap.

Circular nodes cannot overlap.
 

Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
CompactDiskLayouter()
          Creates a new CompactDiskLayouter instance with the default settings.
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Checks whether or not the core layout algorithm can layout the input graph.
 void doLayoutCore(LayoutGraph graph)
          Invokes the core layout algorithm.
 double getMinimumNodeDistance()
          Returns the minimum node distance that this algorithm should enforce between all pairs of nodes.
 byte getNodeLabelingPolicy()
          Returns the policy defining how node labels are placed by the integrated node labeling mechanism (for example, the desired label orientation).
 double getNodeLabelSpacing()
          Returns the spacing used for node labels when integrated node labeling is enabled.
 boolean isConsiderNodeLabelsEnabled()
          Returns whether or not to reserve space for node labels during layout calculation.
 boolean isFromSketchModeEnabled()
          Returns whether or not to take the coordinates of the input diagram into account when arranging the nodes on the disk.
 boolean isIntegratedNodeLabelingEnabled()
          Returns whether or not the layout algorithm automatically places node labels.
 void setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
          Specifies whether or not to reserve space for node labels during layout calculation.
 void setFromSketchModeEnabled(boolean fromSketchModeEnabled)
          Specifies whether or not to take the coordinates of the input diagram into account when arranging the nodes on the disk.
 void setIntegratedNodeLabelingEnabled(boolean integratedNodeLabelingEnabled)
          Specifies whether or not the layout algorithm automatically places node labels.
 void setMinimumNodeDistance(double minimumNodeDistance)
          Specifies the minimum node distance this algorithm should enforce between all pairs of nodes.
 void setNodeLabelingPolicy(byte nodeLabelingPolicy)
          Specifies the policy defining how node labels are placed by the integrated node labeling mechanism (for example, the desired label orientation).
 void setNodeLabelSpacing(double nodeLabelSpacing)
          Specifies the spacing used for node labels when integrated node labeling is enabled.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, checkGroupNodeSize, checkNodeSize, doLayout, doLayout, enableOnlyCore, getComponentLayouter, getGroupNodeHider, getLabelLayouter, getLayoutOrientation, getOrientationLayouter, getParallelEdgeLayouter, getSelfLoopLayouter, getSubgraphLayouter, isComponentLayouterEnabled, isGroupNodeHidingEnabled, isLabelLayouterEnabled, isOrientationLayouterEnabled, isParallelEdgeLayouterEnabled, isSelfLoopLayouterEnabled, isSubgraphLayouterEnabled, prependStage, removeStage, setComponentLayouter, setComponentLayouterEnabled, setGroupNodeHider, setGroupNodeHidingEnabled, setLabelLayouter, setLabelLayouterEnabled, setLayoutOrientation, setOrientationLayouter, setOrientationLayouterEnabled, setParallelEdgeLayouter, setParallelEdgeLayouterEnabled, setSelfLoopLayouter, setSelfLoopLayouterEnabled, setSubgraphLayouter, setSubgraphLayouterEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompactDiskLayouter

public CompactDiskLayouter()
Creates a new CompactDiskLayouter instance with the default settings.

Method Detail

setNodeLabelSpacing

public void setNodeLabelSpacing(double nodeLabelSpacing)
Specifies the spacing used for node labels when integrated node labeling is enabled.

This spacing specifies the distance between labels associated with the same node (if there are multiple labels). In addition, for ray-like labels of outermost nodes, the spacing also defines the distance between the labels and the node they belong to (e.g. for ray-like label placement).

The spacing must have a non-negative value.

 
The spacing value has an effect only if integrated node labeling is enabled.
Default Value:
The default value is 4.0.
Parameters:
nodeLabelSpacing - the non-negative node label spacing
Throws:
java.lang.IllegalArgumentException - if the given spacing value is negative
See Also:
setIntegratedNodeLabelingEnabled(boolean)
Sample Graphs:

Node label spacing set to 5.0

Node label spacing set to 25.0

getNodeLabelSpacing

public double getNodeLabelSpacing()
Returns the spacing used for node labels when integrated node labeling is enabled.

This spacing specifies the distance between labels associated with the same node (if there are multiple labels). In addition, for ray-like labels of outermost nodes, the spacing also defines the distance between the labels and the node they belong to (e.g. for ray-like label placement).

The spacing must have a non-negative value.

 
The spacing value has an effect only if integrated node labeling is enabled.
Returns:
the non-negative node label spacing
See Also:
setIntegratedNodeLabelingEnabled(boolean), setNodeLabelSpacing(double)

isConsiderNodeLabelsEnabled

public boolean isConsiderNodeLabelsEnabled()
Returns whether or not to reserve space for node labels during layout calculation.

Returns:
true if the labels of nodes are taken into account, false otherwise
See Also:
setConsiderNodeLabelsEnabled(boolean)

setConsiderNodeLabelsEnabled

public void setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
Specifies whether or not to reserve space for node labels during layout calculation.

Default Value:
The default value is false. Node labels are not considered.
Parameters:
considerNodeLabelsEnabled - true if the labels of nodes should be taken into account, false otherwise
Sample Graphs:

false

true

isIntegratedNodeLabelingEnabled

public boolean isIntegratedNodeLabelingEnabled()
Returns whether or not the layout algorithm automatically places node labels.

If enabled, this layout algorithm will calculate the positions for the node labels assuring that no overlaps occur.

Different labeling strategies may be selected using setNodeLabelingPolicy(byte).

 
Optimal label placement with integrated labeling can be achieved using FreeNodeLabelModel as the NodeLabelModel for the nodes.
 
If integrated labeling is enabled, then the simple consideration mechanism has no more effect.
Returns:
true if integrated node labeling is enabled, false otherwise.
See Also:
setIntegratedNodeLabelingEnabled(boolean), setNodeLabelingPolicy(byte)

setIntegratedNodeLabelingEnabled

public void setIntegratedNodeLabelingEnabled(boolean integratedNodeLabelingEnabled)
Specifies whether or not the layout algorithm automatically places node labels.

If enabled, this layout algorithm will calculate the positions for the node labels assuring that no overlaps occur.

Different labeling strategies may be selected using setNodeLabelingPolicy(byte).

 
Optimal label placement with integrated labeling can be achieved using FreeNodeLabelModel as the NodeLabelModel for the nodes.
 
If integrated labeling is enabled, then the simple consideration mechanism has no more effect.
Default Value:
The default value is false. Node labels are not placed by this algorithm.
Parameters:
integratedNodeLabelingEnabled - true if integrated node labeling should be enabled, false otherwise.
See Also:
setNodeLabelingPolicy(byte)

getNodeLabelingPolicy

public byte getNodeLabelingPolicy()
Returns the policy defining how node labels are placed by the integrated node labeling mechanism (for example, the desired label orientation).

 
The policy only has an effect if integrated node labeling is enabled.
Returns:
one of the predefined node labeling policies
See Also:
setNodeLabelingPolicy(byte), setIntegratedNodeLabelingEnabled(boolean)

setNodeLabelingPolicy

public void setNodeLabelingPolicy(byte nodeLabelingPolicy)
Specifies the policy defining how node labels are placed by the integrated node labeling mechanism (for example, the desired label orientation).

 
The policy only has an effect if integrated node labeling is enabled.
Default Value:
The default value is NodeLabelingPolicy.NODE_LABELING_MIXED
Parameters:
nodeLabelingPolicy - one of the predefined node labeling policies
Throws:
java.lang.IllegalArgumentException - if an unknown labeling policy is given
See Also:
setIntegratedNodeLabelingEnabled(boolean)
Sample Graphs:

NodeLabelingPolicy.NODE_LABELING_MIXED

NodeLabelingPolicy.NODE_LABELING_HORIZONTAL

NodeLabelingPolicy.NODE_LABELING_RAYLIKE

setFromSketchModeEnabled

public void setFromSketchModeEnabled(boolean fromSketchModeEnabled)
Specifies whether or not to take the coordinates of the input diagram into account when arranging the nodes on the disk.

If enabled: The layout algorithm tries to find a placement of the nodes on concentric circles such that it reflects the radial ordering as well as the distances of the nodes to the center of the input layout as good as possible.

Default Value:
The default value is false. The layout algorithm does not consider the initial coordinates of the nodes.
Parameters:
fromSketchModeEnabled - true if the initial coordinates of the nodes should be used, false otherwise
Sample Graphs:

Input graph where are roughly placed on circles.

Compact disk layout taking the coordinates of the input diagram into account.

isFromSketchModeEnabled

public boolean isFromSketchModeEnabled()
Returns whether or not to take the coordinates of the input diagram into account when arranging the nodes on the disk.

If enabled: The layout algorithm tries to find a placement of the nodes on concentric circles such that it reflects the radial ordering as well as the distances of the nodes to the center of the input layout as good as possible.

Returns:
true if the initial coordinates of the nodes are used, false otherwise
See Also:
setFromSketchModeEnabled(boolean)

getMinimumNodeDistance

public double getMinimumNodeDistance()
Returns the minimum node distance that this algorithm should enforce between all pairs of nodes.

Returns:
a non-negative minimum distance between nodes
See Also:
setMinimumNodeDistance(double)

setMinimumNodeDistance

public void setMinimumNodeDistance(double minimumNodeDistance)
Specifies the minimum node distance this algorithm should enforce between all pairs of nodes.

The minimum node distance needs to be non-negative.

Default Value:
The default value is 0.
Parameters:
minimumNodeDistance - a non-negative minimum distance between nodes
Throws:
java.lang.IllegalArgumentException - if the specified minimum node distance is negative
Sample Graphs:

node distance 0

node distance 10

node distance 50

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Description copied from class: CanonicMultiStageLayouter
Checks whether or not the core layout algorithm can layout the input graph.

This method should be implemented by subclasses such that it determines whether or not the core layout algorithm accepts the input graph.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter
Parameters:
graph - the input graph
Returns:
true if the core layout algorithm can handle the input graph, false otherwise

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Description copied from class: CanonicMultiStageLayouter
Invokes the core layout algorithm.

This method should be implemented by subclasses in order to perform the layout routine of the layout algorithm.

Specified by:
doLayoutCore in class CanonicMultiStageLayouter
Parameters:
graph - the input graph

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