Search this API

y.layout.random
Class RandomLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.random.RandomLayouter
All Implemented Interfaces:
Layouter

public class RandomLayouter
extends CanonicMultiStageLayouter

This layout algorithm arranges the graph in a random fashion.

Layout Style

The nodes are placed at random positions. Edges connect the nodes with a straight line, anchored in the center of the nodes.


A random arrangement

Concept

The layout algorithm iterates over all nodes and places them at random locations. All bends are removed from the edges and their ports move to the center of the incident nodes.

Features

It is possible to specify a rectangular area in which all nodes are placed.

To get the same random layout in several runs, a constant seed can be set.

 

Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
RandomLayouter()
          Creates a new instance of RandomLayouter with default settings.
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Accepts all general graphs without exception.
 void doLayoutCore(LayoutGraph graph)
          Places the nodes at random positions.
 java.awt.Rectangle getLayoutBounds()
          Returns a rectangular area that confines the layout.
 long getSeed()
          Returns the seed for the randomization of the node locations.
 void setLayoutBounds(java.awt.Rectangle r)
          Specifies a rectangular area that confines the layout.
 void setSeed(long seed)
          Specifies the seed for the randomization of the node locations.
 
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

RandomLayouter

public RandomLayouter()
Creates a new instance of RandomLayouter with default settings.

Method Detail

setLayoutBounds

public void setLayoutBounds(java.awt.Rectangle r)
Specifies a rectangular area that confines the layout. Nodes will only be placed inside this area.

Default Value:
The default value is Rectangle. A square located at (0,0) whose width and height are 500.
Parameters:
r - the rectangle that defines the layout space
Throws:
java.lang.IllegalArgumentException - if the specified rectangle is null
Sample Graphs:

Rectangle with width 500 and height 500

Rectangle with width 600 and height 200

getLayoutBounds

public java.awt.Rectangle getLayoutBounds()
Returns a rectangular area that confines the layout. Nodes will only be placed inside this area.

Returns:
the rectangle that defines the layout space
See Also:
setLayoutBounds(Rectangle)

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Accepts all general graphs without exception.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter
Parameters:
graph - the input graph
Returns:
true for all graphs

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Places the nodes at random positions.

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

getSeed

public long getSeed()
Returns the seed for the randomization of the node locations.

Returns:
the randomization seed
See Also:
setSeed(long)

setSeed

public void setSeed(long seed)
Specifies the seed for the randomization of the node locations.

Default Value:
The default value is System.currentTimeMillis().
Parameters:
seed - the randomization seed

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