Zest
1.5.0.201308190730

org.eclipse.zest.layouts.algorithms
Class GridLayoutAlgorithm

java.lang.Object
  extended by org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
      extended by org.eclipse.zest.layouts.algorithms.GridLayoutAlgorithm
All Implemented Interfaces:
LayoutAlgorithm, Stoppable
Direct Known Subclasses:
HorizontalLayoutAlgorithm, VerticalLayoutAlgorithm

public class GridLayoutAlgorithm
extends AbstractLayoutAlgorithm


Field Summary
protected  int rowPadding
           
 
Fields inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
comparator, filter, internalAsynchronous, internalContinuous, layout_styles, layoutStopped, MIN_ENTITY_SIZE, resizeEntitiesAfterLayout
 
Constructor Summary
GridLayoutAlgorithm()
          Inititalizes the grid layout with no style.
GridLayoutAlgorithm(int styles)
          Initializes the grid layout.
 
Method Summary
protected  void applyLayoutInternal(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout, org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider, double boundsX, double boundsY, double boundsWidth, double boundsHeight)
          Use this algorithm to layout the given entities, using the given relationships and bounds.
protected  double[] calculateNodeSize(double colWidth, double rowHeight)
           
protected  int[] calculateNumberOfRowsAndCols_rectangular(int numChildren)
           
protected  int[] calculateNumberOfRowsAndCols_square(int numChildren, double boundX, double boundY, double boundWidth, double boundHeight)
           
protected  int[] calculateNumberOfRowsAndCols(int numChildren, double boundX, double boundY, double boundWidth, double boundHeight)
          Calculates and returns an array containing the number of columns, followed by the number of rows
protected  int getCurrentLayoutStep()
          Gets the current layout step
protected  int getTotalNumberOfLayoutSteps()
          Gets the total number of steps in this layout
protected  boolean isValidConfiguration(boolean asynchronous, boolean continueous)
          Determines if the configuration is valid for this layout
protected  void postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout, org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
          Code called after the layout algorithm ends
protected  void preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout, org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height)
          Code called before the layout algorithm starts
 void setLayoutArea(double x, double y, double width, double height)
           
 void setRowPadding(int rowPadding)
          Increases the padding between rows in the grid
 
Methods inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
addEntity, addProgressListener, addRelationship, applyLayout, defaultFitWithinBounds, defaultFitWithinBounds, fireProgressEnded, fireProgressEvent, fireProgressStarted, getEntityAspectRatio, getLayoutBounds, getLocalLocation, getNumberOfProgressListeners, getStyle, isRunning, removeEntity, removeProgressListener, removeRelationship, removeRelationships, removeRelationships, setComparator, setEntityAspectRatio, setFilter, setStyle, stop, updateBendPoints, updateEntities, updateLayoutLocations, updateRelationships, verifyInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rowPadding

protected int rowPadding
Constructor Detail

GridLayoutAlgorithm

public GridLayoutAlgorithm(int styles)
Initializes the grid layout.

Parameters:
styles -
See Also:
LayoutStyles

GridLayoutAlgorithm

public GridLayoutAlgorithm()
Inititalizes the grid layout with no style.

Method Detail

setLayoutArea

public void setLayoutArea(double x,
                          double y,
                          double width,
                          double height)
Specified by:
setLayoutArea in class AbstractLayoutAlgorithm

getCurrentLayoutStep

protected int getCurrentLayoutStep()
Description copied from class: AbstractLayoutAlgorithm
Gets the current layout step

Specified by:
getCurrentLayoutStep in class AbstractLayoutAlgorithm
Returns:

getTotalNumberOfLayoutSteps

protected int getTotalNumberOfLayoutSteps()
Description copied from class: AbstractLayoutAlgorithm
Gets the total number of steps in this layout

Specified by:
getTotalNumberOfLayoutSteps in class AbstractLayoutAlgorithm

preLayoutAlgorithm

protected void preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
                                  org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
                                  double x,
                                  double y,
                                  double width,
                                  double height)
Description copied from class: AbstractLayoutAlgorithm
Code called before the layout algorithm starts

Specified by:
preLayoutAlgorithm in class AbstractLayoutAlgorithm

applyLayoutInternal

protected void applyLayoutInternal(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
                                   org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
                                   double boundsX,
                                   double boundsY,
                                   double boundsWidth,
                                   double boundsHeight)
Use this algorithm to layout the given entities, using the given relationships and bounds. The entities will be placed in the same order as they are passed in, unless a comparator is supplied.

Specified by:
applyLayoutInternal in class AbstractLayoutAlgorithm
Parameters:
entitiesToLayout - Apply the algorithm to these entities
relationshipsToConsider - Only consider these relationships when applying the algorithm.
boundsX - The left side of the bounds in which the layout can place the entities.
boundsY - The top side of the bounds in which the layout can place the entities.
boundsWidth - The width of the bounds in which the layout can place the entities.
boundsHeight - The height of the bounds in which the layout can place the entities.
Throws:
java.lang.RuntimeException - Thrown if entitiesToLayout doesn't contain all of the endpoints for each relationship in relationshipsToConsider

postLayoutAlgorithm

protected void postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
                                   org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
Description copied from class: AbstractLayoutAlgorithm
Code called after the layout algorithm ends

Specified by:
postLayoutAlgorithm in class AbstractLayoutAlgorithm

calculateNumberOfRowsAndCols

protected int[] calculateNumberOfRowsAndCols(int numChildren,
                                             double boundX,
                                             double boundY,
                                             double boundWidth,
                                             double boundHeight)
Calculates and returns an array containing the number of columns, followed by the number of rows


calculateNumberOfRowsAndCols_square

protected int[] calculateNumberOfRowsAndCols_square(int numChildren,
                                                    double boundX,
                                                    double boundY,
                                                    double boundWidth,
                                                    double boundHeight)

calculateNumberOfRowsAndCols_rectangular

protected int[] calculateNumberOfRowsAndCols_rectangular(int numChildren)

calculateNodeSize

protected double[] calculateNodeSize(double colWidth,
                                     double rowHeight)

setRowPadding

public void setRowPadding(int rowPadding)
Increases the padding between rows in the grid

Parameters:
rowPadding - Value will not be set if less than 0.

isValidConfiguration

protected boolean isValidConfiguration(boolean asynchronous,
                                       boolean continueous)
Description copied from class: AbstractLayoutAlgorithm
Determines if the configuration is valid for this layout

Specified by:
isValidConfiguration in class AbstractLayoutAlgorithm

Zest
1.5.0.201308190730

Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.