pl.edu.agh.cast.schema.editor.layout.algorithm
Class AbstractLayoutAlgorithm

java.lang.Object
  extended by pl.edu.agh.cast.schema.editor.layout.algorithm.AbstractLayoutAlgorithm
All Implemented Interfaces:
ILayoutAlgorithm
Direct Known Subclasses:
AbstractGroupingLayoutAlgorithm, EnhancedCircleLayoutAlgorithm, RandomLayoutAlgorithm

public abstract class AbstractLayoutAlgorithm
extends Object
implements ILayoutAlgorithm

Abstract algorithm positioning nodes taking under consideration their original position.

Author:
AGH CAST Team

Constructor Summary
AbstractLayoutAlgorithm()
           
 
Method Summary
protected  org.eclipse.draw2d.geometry.Point getCenterOfGravity(Collection<ISchemaNode> nodes)
          Returns coordinates of the center of gravity of nodes
protected  org.eclipse.draw2d.geometry.Point getUpperLeftCorner(Collection<ISchemaNode> positionedNodes)
          Returns coordinates of the upper left and bottom right corner of area occupied by nodes.
protected abstract  int getWorkUnits(int nodesCount)
          Queries for number of planned work units in the algorithm
 void layoutNodes(Collection<ISchemaNode> nodes, org.eclipse.core.runtime.IProgressMonitor monitor)
          Lays out nodes, preserving their center of gravity.
protected abstract  void setNodesPositions(Collection<ISchemaNode> positionNodes, org.eclipse.core.runtime.IProgressMonitor monitor)
          Sets positions of given nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLayoutAlgorithm

public AbstractLayoutAlgorithm()
Method Detail

setNodesPositions

protected abstract void setNodesPositions(Collection<ISchemaNode> positionNodes,
                                          org.eclipse.core.runtime.IProgressMonitor monitor)
Sets positions of given nodes.

Parameters:
positionNodes - nodes to layout
monitor - non-null progress monitor

layoutNodes

public void layoutNodes(Collection<ISchemaNode> nodes,
                        org.eclipse.core.runtime.IProgressMonitor monitor)
Lays out nodes, preserving their center of gravity. Calls ILayoutAlgorithm#setNodesPositions(Collection) to perform the actual layout. Ensures that the new layout preserves the center of gravity of the old one, and that no node is moved behind the left and top borders of the diagram Method executed to layout a collection of visual nodes.

Specified by:
layoutNodes in interface ILayoutAlgorithm
Parameters:
nodes - nodes on which layout will be performed
monitor - progress monitor used to report progress of layout operation; MUST NOT be null

getCenterOfGravity

protected org.eclipse.draw2d.geometry.Point getCenterOfGravity(Collection<ISchemaNode> nodes)
Returns coordinates of the center of gravity of nodes

Parameters:
nodes - collection of nodes whose center will be calculated
Returns:
center of gravity

getUpperLeftCorner

protected org.eclipse.draw2d.geometry.Point getUpperLeftCorner(Collection<ISchemaNode> positionedNodes)
Returns coordinates of the upper left and bottom right corner of area occupied by nodes. There is no node positioned above or left of this point.

Parameters:
positionedNodes - collection of visual schema nodes nodes
Returns:
table containing two points: first index: upper left point, second index: bottom right point

getWorkUnits

protected abstract int getWorkUnits(int nodesCount)
Queries for number of planned work units in the algorithm

Parameters:
nodesCount - number of nodes to layout
Returns:
number of units that will be added to progress monitor's maximum range


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.