public class GridLayoutAlgorithm extends java.lang.Object implements ILayoutAlgorithm
Modifier and Type | Field and Description |
---|---|
protected double |
aspectRatio |
protected double |
childrenHeight |
protected double |
childrenWidth |
protected int |
cols |
protected double |
colWidth |
protected int |
numChildren |
protected double |
offsetX |
protected double |
offsetY |
protected double |
rowHeight |
protected int |
rowPadding |
protected int |
rows |
Constructor and Description |
---|
GridLayoutAlgorithm() |
Modifier and Type | Method and Description |
---|---|
void |
applyLayout(boolean clean)
Makes this algorithm perform layout computation and apply it to its
context.
|
protected void |
applyLayoutInternal(IEntityLayout[] entitiesToLayout,
Rectangle bounds)
Use this algorithm to layout the given entities and bounds.
|
protected void |
calculateGrid(Rectangle bounds)
Calculates all the dimensions of grid that layout entities will be fit
in.
|
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
|
ILayoutContext |
getLayoutContext()
Returns the previously set
ILayoutContext . |
boolean |
isResizing() |
void |
setAspectRatio(double aspectRatio)
Sets the preferred aspect ratio for layout entities.
|
void |
setLayoutContext(ILayoutContext context)
Sets the layout context for this algorithm.
|
void |
setResizing(boolean resizing) |
void |
setRowPadding(int rowPadding)
Sets the padding between rows in the grid
|
protected double aspectRatio
protected int rowPadding
protected int rows
protected int cols
protected int numChildren
protected double colWidth
protected double rowHeight
protected double offsetX
protected double offsetY
protected double childrenHeight
protected double childrenWidth
public void setLayoutContext(ILayoutContext context)
ILayoutAlgorithm
setLayoutContext
in interface ILayoutAlgorithm
context
- a new layout context or null if this algorithm should not
perform any layoutpublic void applyLayout(boolean clean)
ILayoutAlgorithm
applyLayout
in interface ILayoutAlgorithm
clean
- if true the receiver should assume that the layout context has
changed significantly and recompute the whole layout even if
it keeps track of changes with listeners. False can be used
after dynamic layout in a context is turned back on so that
layout algorithm working in background can apply accumulated
changes. Static layout algorithm can ignore this call entirely
if clean is false.protected void calculateGrid(Rectangle bounds)
numChildren
,
rows
, cols
, colWidth
, rowHeight
,
offsetX
, offsetY
bounds
- protected void applyLayoutInternal(IEntityLayout[] entitiesToLayout, Rectangle bounds)
entitiesToLayout
- apply the algorithm to these entitiesbounds
- the bounds in which the layout can place the entities.protected int[] calculateNumberOfRowsAndCols(int numChildren, double boundX, double boundY, double boundWidth, double boundHeight)
protected int[] calculateNumberOfRowsAndCols_square(int numChildren, double boundX, double boundY, double boundWidth, double boundHeight)
protected int[] calculateNumberOfRowsAndCols_rectangular(int numChildren)
protected double[] calculateNodeSize(double colWidth, double rowHeight)
public void setRowPadding(int rowPadding)
rowPadding
- padding - should be greater than or equal to 0public void setAspectRatio(double aspectRatio)
aspectRatio
- aspect ratio - should be greater than 0public boolean isResizing()
public void setResizing(boolean resizing)
resizing
- true if this algorithm should resize elements (default is
false)public ILayoutContext getLayoutContext()
ILayoutAlgorithm
ILayoutContext
.getLayoutContext
in interface ILayoutAlgorithm
ILayoutContext
Copyright (c) 2014 itemis AG and others. All rights reserved.