Cytoscape 2.2 (c) 2004 ISB, MSKCC, UCSD

cytoscape.layout
Class AbstractLayout

java.lang.Object
  extended bycytoscape.layout.AbstractLayout
All Implemented Interfaces:
LayoutAlgorithm, MonitoredTask
Direct Known Subclasses:
SpringEmbeddedLayouter

public abstract class AbstractLayout
extends Object
implements LayoutAlgorithm

The AbstractLayout provides nice starting point for Layouts written for Cytoscape.


Constructor Summary
AbstractLayout(CyNetworkView networkView)
          The Constructor is null
 
Method Summary
 void advancePositions()
          Implementors must override this method in order to create a Layout.
 void cancel()
          Gets called when the user clicks on the Cancel button of the progress monitor.
abstract  Object construct()
           
 void doLayout()
           
 boolean done()
          Returns true if the task is done.
 boolean dontMove(NodeView nv)
           
 void forceMove(NodeView picked, double x, double y)
          Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location.
 int getCurrent()
          Returns the currentProgress parameter.
 Dimension getCurrentSize()
          Returns the current size of the visualization space, accoring to the last call to resize().
 int getLengthOfTask()
          Returns the lenghtOfTask parameter.
 String getMessage()
          Returns a String, possibly the message to be printed on a dialog.
 String getName()
           
 NodeView getNodeView(double x, double y)
           
 String getStatus()
          {@inheritDoc} By default, an AbstractLayout returns null for its status.
 String getTaskName()
          Returns a String, possibly the message that describes the task being performed.
 void go(boolean wait)
          Initializes currentProgress (generally to zero) and then spawns a SwingWorker to start doing the work.
 void incrementProgress()
          Increments the progress by one
 void initialize()
          Initializer, calls intialize_local and initializeLocations to start construction process.
 void lockNode(NodeView v)
          Adds the NodeView to the DontMove list
 void lockNodes(NodeView[] nodes)
           
 void move(double x, double y)
           
 void resize(Dimension size)
          When a visualizetion is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.
 void restart()
          Restarts the visualization entirely, as if the the user had pressed the "scramble" button.
 void setSingle(double x, double y)
           
 void stop()
          Stops the task by simply setting currentProgress to lengthOfTask, or if a boolean "done" variable is used, setting it to true.
 void unlockNode(NodeView v)
          Removes the NodeView from the DontMove list
 boolean wasCanceled()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLayout

public AbstractLayout(CyNetworkView networkView)
The Constructor is null

Method Detail

construct

public abstract Object construct()

getMessage

public String getMessage()
Description copied from interface: MonitoredTask
Returns a String, possibly the message to be printed on a dialog. Example: "Completed 12%"

Specified by:
getMessage in interface MonitoredTask

getTaskName

public String getTaskName()
Description copied from interface: MonitoredTask
Returns a String, possibly the message that describes the task being performed. Example: "Calculating connecting paths."

Specified by:
getTaskName in interface MonitoredTask

getName

public String getName()

done

public boolean done()
Description copied from interface: MonitoredTask
Returns true if the task is done. Otherwise false. This can be done by either returning (currentProgress == lengthOfTask) or having a boolean "done" variable that is set to true in the code whenever the task is done, and returning it here.

Specified by:
done in interface MonitoredTask

cancel

public void cancel()
Gets called when the user clicks on the Cancel button of the progress monitor.

Specified by:
cancel in interface MonitoredTask

wasCanceled

public boolean wasCanceled()
Specified by:
wasCanceled in interface MonitoredTask
Returns:
whether the task was canceled while running or not.

stop

public void stop()
Description copied from interface: MonitoredTask
Stops the task by simply setting currentProgress to lengthOfTask, or if a boolean "done" variable is used, setting it to true.

Specified by:
stop in interface MonitoredTask

incrementProgress

public void incrementProgress()
Description copied from interface: MonitoredTask
Increments the progress by one

Specified by:
incrementProgress in interface MonitoredTask

getCurrent

public int getCurrent()
Description copied from interface: MonitoredTask
Returns the currentProgress parameter.

Specified by:
getCurrent in interface MonitoredTask

getLengthOfTask

public int getLengthOfTask()
Description copied from interface: MonitoredTask
Returns the lenghtOfTask parameter.

Specified by:
getLengthOfTask in interface MonitoredTask

go

public void go(boolean wait)
Initializes currentProgress (generally to zero) and then spawns a SwingWorker to start doing the work.

Specified by:
go in interface MonitoredTask
Parameters:
wait - whether or not the method should wait for the task to be done before returning if true, should call SwingWorker.get() before returning

doLayout

public void doLayout()
Specified by:
doLayout in interface LayoutAlgorithm

dontMove

public boolean dontMove(NodeView nv)
Returns:
if the given NodeView is static

initialize

public void initialize()
Initializer, calls intialize_local and initializeLocations to start construction process.


getStatus

public String getStatus()
{@inheritDoc} By default, an AbstractLayout returns null for its status.


advancePositions

public void advancePositions()
Implementors must override this method in order to create a Layout. If the Layout is the sort that only calculates locations once, this method may be overridden with an empty method.

Note that "locked" vertices are not to be moved; however, it is the policy of the visualization to decide how to handle them, and what to do with the vertices around them. Prototypical code might include a clipping like

 		for (Iterator i = getVertices().iterator(); i.hasNext() ) {
 			Vertex v = (Vertex) i.next();
 			if (! dontmove.contains( v ) ) {
 				... // handle the node
 			} else { // ignore the node
 			}
 		}
 

See Also:
Layout#advancePositions()

getCurrentSize

public Dimension getCurrentSize()
Returns the current size of the visualization space, accoring to the last call to resize().

Returns:
the current size of the screen

move

public void move(double x,
                 double y)

setSingle

public void setSingle(double x,
                      double y)

resize

public void resize(Dimension size)
When a visualizetion is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data. The current method calls initializeLocations followed by initialize_local. TODO: A better implementation wouldn't destroy the current information, but would either scale the current visualization, or move the nodes toward the new center.


restart

public void restart()
Restarts the visualization entirely, as if the the user had pressed the "scramble" button. Calls initializeLocation for each vertex. TODO: Is this enough? Should it call the whole initialization process? Why does resize do more?


getNodeView

public NodeView getNodeView(double x,
                            double y)
Returns:
the closest NodeView to these coords.

forceMove

public void forceMove(NodeView picked,
                      double x,
                      double y)
Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location. Does not add the vertex to the "dontmove" list, and (in the default implementation) does not make any adjustments to the rest of the graph.


lockNodes

public void lockNodes(NodeView[] nodes)
Specified by:
lockNodes in interface LayoutAlgorithm

lockNode

public void lockNode(NodeView v)
Adds the NodeView to the DontMove list

Specified by:
lockNode in interface LayoutAlgorithm

unlockNode

public void unlockNode(NodeView v)
Removes the NodeView from the DontMove list

Specified by:
unlockNode in interface LayoutAlgorithm

www.cytoscape.org