org.jgraph.layout
Class JGraphLayoutAlgorithm

java.lang.Object
  extended byorg.jgraph.layout.JGraphLayoutAlgorithm
Direct Known Subclasses:
AnnealingLayoutAlgorithm, CircleGraphLayout, GEMLayoutAlgorithm, MoenLayoutAlgorithm, RadialTreeLayoutAlgorithm, SpringEmbeddedLayoutAlgorithm, SugiyamaLayoutAlgorithm, TreeLayoutAlgorithm

public abstract class JGraphLayoutAlgorithm
extends java.lang.Object


Field Summary
protected static java.util.Set LAYOUT_ATTRIBUTES
           
 
Constructor Summary
JGraphLayoutAlgorithm()
           
 
Method Summary
static void applyLayout(JGraph sourceGraph, JGraphLayoutAlgorithm layout, java.lang.Object[] cells)
          Calls applyLayout() with null static_cells
static void applyLayout(JGraph sourceGraph, JGraphLayoutAlgorithm layout, java.lang.Object[] dynamic_cells, java.lang.Object[] static_cells)
          Takes a local clone of the JGraph and calls the run() method on the specified layout algorithm on the local JGraph.
static javax.swing.JDialog createDialog(JGraphLayoutSettings settings, javax.swing.JDialog parent, java.lang.String title, java.lang.String close, java.lang.String apply)
          A utility method to create a simple dialog with close and apply button.
static javax.swing.JDialog createDialog(JGraphLayoutSettings settings, javax.swing.JFrame parent, java.lang.String title, java.lang.String close, java.lang.String apply)
          A utility method to create a simple dialog with close and apply button.
 JGraphLayoutSettings createSettings()
          Subclassers may return a new JComponent that allows to configure the layout.
 java.lang.String getHint()
          Get a human readable hint for using this layout.
 int getMaximumProgress()
          Returns the maximum progress
 int getProgress()
          Returns the current progress
 boolean isAllowedToRun()
           
static javax.swing.JDialog populateDialog(JGraphLayoutSettings settings, javax.swing.JDialog dialog, java.lang.String close, java.lang.String apply)
          A utility method to create a simple dialog with close and apply button.
 void run(JGraph graph, java.lang.Object[] cells)
          Executes the layout algorithm with the given cells to be moved
abstract  void run(JGraph jgraph, java.lang.Object[] dynamic_cells, java.lang.Object[] static_cells)
          Executes the layout algorithm specifying which cells are to remain in place after the layout is applied.
 void setAllowedToRun(boolean isAllowedToRun)
           
 void setMaximumProgress(int maximumProgress)
          Sets the maximum progress.
 void setProgress(int progress)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT_ATTRIBUTES

protected static java.util.Set LAYOUT_ATTRIBUTES
Constructor Detail

JGraphLayoutAlgorithm

public JGraphLayoutAlgorithm()
Method Detail

createSettings

public JGraphLayoutSettings createSettings()
Subclassers may return a new JComponent that allows to configure the layout. The default implementation returns null.
Note: Settings creation may be expensive so the UI should cache the values returned by this method.


getHint

public java.lang.String getHint()
Get a human readable hint for using this layout.


run

public void run(JGraph graph,
                java.lang.Object[] cells)
Executes the layout algorithm with the given cells to be moved

Parameters:
graph - JGraph to be altered by layout
cells - Array of cells to be moved by the layout

run

public abstract void run(JGraph jgraph,
                         java.lang.Object[] dynamic_cells,
                         java.lang.Object[] static_cells)
Executes the layout algorithm specifying which cells are to remain in place after the layout is applied.

Parameters:
jgraph - JGraph to be altered by layout
dynamic_cells - Cells that are to be moved by the layout
static_cells - Cells that are not to be moved, but allowed for by the layout

isAllowedToRun

public boolean isAllowedToRun()
Returns:
Returns the isAllowedToRun.

setAllowedToRun

public void setAllowedToRun(boolean isAllowedToRun)
Parameters:
isAllowedToRun - The isAllowedToRun to set.

getMaximumProgress

public int getMaximumProgress()
Returns the maximum progress


setMaximumProgress

public void setMaximumProgress(int maximumProgress)
Sets the maximum progress.


getProgress

public int getProgress()
Returns the current progress


setProgress

public void setProgress(int progress)
Parameters:
progress - The progress complete amount

createDialog

public static javax.swing.JDialog createDialog(JGraphLayoutSettings settings,
                                               javax.swing.JFrame parent,
                                               java.lang.String title,
                                               java.lang.String close,
                                               java.lang.String apply)
A utility method to create a simple dialog with close and apply button.

Parameters:
settings - Layout settings instance
parent - Parent JFrame
title - Title of dialog box
close - Text for cancel button
apply - Text for apply button
Returns:
JDialog dialog to be displayed

createDialog

public static javax.swing.JDialog createDialog(JGraphLayoutSettings settings,
                                               javax.swing.JDialog parent,
                                               java.lang.String title,
                                               java.lang.String close,
                                               java.lang.String apply)
A utility method to create a simple dialog with close and apply button.

Parameters:
settings - Layout settings instance
parent - Parent JDialog
title - Title of dialog box
close - Text for cancel button
apply - Text for apply button
Returns:
JDialog dialog to be displayed

populateDialog

public static javax.swing.JDialog populateDialog(JGraphLayoutSettings settings,
                                                 javax.swing.JDialog dialog,
                                                 java.lang.String close,
                                                 java.lang.String apply)
A utility method to create a simple dialog with close and apply button.

Parameters:
settings - Layout settings instance
dialog - JDialog to be used
close - Text for cancel button
apply - Text for apply button
Returns:
JDialog showing the settings for the layout

applyLayout

public static void applyLayout(JGraph sourceGraph,
                               JGraphLayoutAlgorithm layout,
                               java.lang.Object[] cells)
Calls applyLayout() with null static_cells

Parameters:
sourceGraph - The JGraph to have the layout applied
layout - The layout algorithm to be applied
cells - Cells that are to be moved by the layout

applyLayout

public static void applyLayout(JGraph sourceGraph,
                               JGraphLayoutAlgorithm layout,
                               java.lang.Object[] dynamic_cells,
                               java.lang.Object[] static_cells)
Takes a local clone of the JGraph and calls the run() method on the specified layout algorithm on the local JGraph. After the layout has been applied, the changed attributes on the local JGraph are extracted and applied to the JGraph instance passed in, creating one undoable edit.

Parameters:
sourceGraph - The JGraph to have the layout applied
layout - The layout algorithm to be applied
dynamic_cells - Cells that are to be moved by the layout
static_cells - Cells that are not to be moved, but allowed for by the layout