Draw2D v2.0

org.eclipse.draw2d
Class ToolbarLayout

java.lang.Object
  |
  +--org.eclipse.draw2d.AbstractLayout
        |
        +--org.eclipse.draw2d.ToolbarLayout
All Implemented Interfaces:
LayoutManager

public class ToolbarLayout
extends AbstractLayout

Layout manager that provides toolbar-like behavior. When horizontally oriented, children will be placed horizontally adjacent to each other. When vertically oriented, children will be placed vertically adjacent to each other. In each case, children will be separated by the number of pixels specified with the setSpacing(int) method. If the field matchWidth is set to true, horizontally oriented children will stretch themselves vertically to fit available height. Vertically oriented children will stretch themselves horizontally to fit available width. Children will be stretched (or shrunk) in both horizontal and vertical directions upon resize until maximum or minimum sizes are reached.


Field Summary
static int ALIGN_BOTTOMRIGHT
           
static int ALIGN_CENTER
           
static int ALIGN_TOPLEFT
           
protected  boolean horizontal
           
static boolean HORIZONTAL
           
protected  int minorAlignment
           
protected  Transposer transposer
           
static boolean VERTICAL
           
 
Constructor Summary
ToolbarLayout()
          Constructs a vertically oriented ToolbarLayout with child spacing of 0 pixels, matchWidth true, and ALIGN_TOPLEFT alignment.
ToolbarLayout(boolean isHorizontal)
          Constructs a ToolbarLayout with a specified orientation.
 
Method Summary
 Dimension calculateMinimumSize(IFigure parent)
          Calculates and returns the minimum size of the container given as input.
protected  Dimension calculatePreferredSize(IFigure parent)
          Calculates and returns the preferred size of the container given as input.
 Dimension getMinimumSize(IFigure container)
          Returns the minimum size of the given figure.
 void invalidate()
          Removes all cached information for all figures this LayoutManager is responsible for.
 boolean isHorizontal()
          Returns whether the orientation of the layout is horizontal or not.
 void layout(IFigure parent)
          Lays out the given figure.
 void setMatchWidth(boolean match)
          Sets children's width (if vertically oriented) or height (if horizontally oriented) to stretch with their container
 void setMinorAlignment(int align)
          Sets the alignment of the children contained in the layout.
 void setSpacing(int space)
          Sets the amount of space between children
 void setVertical(boolean flag)
          Sets the orientation of the children in the ToolbarLayout.
 
Methods inherited from class org.eclipse.draw2d.AbstractLayout
calculatePreferredSize, getBorderPreferredSize, getConstraint, getPreferredSize, getPreferredSize, invalidate, remove, setConstraint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

horizontal

protected boolean horizontal

minorAlignment

protected int minorAlignment

ALIGN_CENTER

public static final int ALIGN_CENTER

ALIGN_TOPLEFT

public static final int ALIGN_TOPLEFT

ALIGN_BOTTOMRIGHT

public static final int ALIGN_BOTTOMRIGHT

HORIZONTAL

public static final boolean HORIZONTAL

VERTICAL

public static final boolean VERTICAL

transposer

protected Transposer transposer
Constructor Detail

ToolbarLayout

public ToolbarLayout()
Constructs a vertically oriented ToolbarLayout with child spacing of 0 pixels, matchWidth true, and ALIGN_TOPLEFT alignment.
Since:
2.0

ToolbarLayout

public ToolbarLayout(boolean isHorizontal)
Constructs a ToolbarLayout with a specified orientation. Default values are: child spacing 0 pixels, matchWidth false, and ALIGN_TOPLEFT alignment.
Parameters:
isHorizonal - false(VERTICAL) will orient children vertically true(HORIZONTAL) will orient children horizontally.
Since:
2.0
Method Detail

calculateMinimumSize

public Dimension calculateMinimumSize(IFigure parent)
Calculates and returns the minimum size of the container given as input. In the case of the vertically oriented ToolbarLayout, this is the width of the largest minimum width of figure's children and the height of the sum of the minimum heights of figure's children. Values are transposed to calculate minimum size of a horizontally oriented ToolbarLayout.
Parameters:
figure - Figure whose preferred size is required.
Returns:
The minimum size of the figure input.
Since:
2.0

getMinimumSize

public Dimension getMinimumSize(IFigure container)
Description copied from class: AbstractLayout
Returns the minimum size of the given figure.
Overrides:
getMinimumSize in class AbstractLayout

invalidate

public void invalidate()
Description copied from class: AbstractLayout
Removes all cached information for all figures this LayoutManager is responsible for.
Overrides:
invalidate in class AbstractLayout

calculatePreferredSize

protected Dimension calculatePreferredSize(IFigure parent)
Calculates and returns the preferred size of the container given as input. In the case of the vertically oriented ToolbarLayout, this is the width of the largest preferred width of figure's children and the height of the sum of the preferred heights of figure's children. Values are transposed to calculate preferred size of a horizontally oriented ToolbarLayout.
Overrides:
calculatePreferredSize in class AbstractLayout
Parameters:
figure - Figure whose preferred size is required.
Returns:
The minimum size of the figure input.
Since:
2.0

isHorizontal

public boolean isHorizontal()
Returns whether the orientation of the layout is horizontal or not.
Returns:
Orientation of the layout.
Since:
2.0

layout

public void layout(IFigure parent)
Description copied from interface: LayoutManager
Lays out the given figure.

setMinorAlignment

public void setMinorAlignment(int align)
Sets the alignment of the children contained in the layout.
Parameters:
align - 0 (ALIGN_CENTER), 1 (ALIGN_TOPLEFT) 2 (ALIGN_BOTTOMRIGHT)
Since:
2.0

setSpacing

public void setSpacing(int space)
Sets the amount of space between children
Parameters:
space - The amount of space between children.
Since:
2.0

setMatchWidth

public void setMatchWidth(boolean match)
Sets children's width (if vertically oriented) or height (if horizontally oriented) to stretch with their container
Parameters:
match - true will stretch the children, false will not
Since:
2.0

setVertical

public void setVertical(boolean flag)
Sets the orientation of the children in the ToolbarLayout.
Parameters:
flag - true sets orientation to vertical false sets oreintation to horizontal
Since:
2.0

Draw2D v2.0