Eclipse Draw2d
2.1

org.eclipse.draw2d
Class ToolbarLayout

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

public class ToolbarLayout
extends AbstractHintLayout

Arranges figures in a single row or column. Orientation can be set to produce either a row or column layout. This layout try to fit all children within the parent's client area. To do this, it compresses the children by some amount, but will not compress them smaller than their minimum size. If a child's preferred size is smaller than the row's or column's minor dimension, the layout can be configured to stretch the child.


Field Summary
static int ALIGN_BOTTOMRIGHT
           
static int ALIGN_CENTER
           
static int ALIGN_TOPLEFT
           
protected  boolean horizontal
           
static boolean HORIZONTAL
           
protected  boolean matchWidth
           
protected  int minorAlignment
           
protected  int spacing
           
protected  Transposer transposer
           
static boolean VERTICAL
           
 
Fields inherited from class org.eclipse.draw2d.AbstractLayout
preferredSize
 
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 container, int wHint, int hHint)
          Calculates the minimum size of the container based on the given hints.
protected  Dimension calculatePreferredSize(IFigure container, int wHint, int hHint)
          Calculates the preferred size of the container based on the given hints.
 boolean isHorizontal()
          Returns whether the orientation of the layout is horizontal.
protected  boolean isSensitiveHorizontally(IFigure parent)
          Returns whether this layout manager is sensitive to changes in the horizontal hint.
protected  boolean isSensitiveVertically(IFigure parent)
          Returns whether this layout manager is sensitive to changes in the vertical hint.
 void layout(IFigure parent)
          Lays out the given figure.
 void setMatchWidth(boolean match)
          Deprecated. use setStretchMinorAxis
 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 setStretchMinorAxis(boolean stretch)
          Causes children that are smaller in the dimension of the minor axis to be stretched to fill the minor axis.
 void setVertical(boolean flag)
          Sets the orientation of the children in the ToolbarLayout.
 
Methods inherited from class org.eclipse.draw2d.AbstractHintLayout
getMinimumSize, getPreferredSize, invalidate
 
Methods inherited from class org.eclipse.draw2d.AbstractLayout
calculatePreferredSize, getBorderPreferredSize, getConstraint, getMinimumSize, getPreferredSize, invalidate, remove, setConstraint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spacing

protected int spacing

matchWidth

protected boolean matchWidth

horizontal

protected boolean horizontal

minorAlignment

protected int minorAlignment

ALIGN_CENTER

public static final int ALIGN_CENTER
See Also:
Constant Field Values

ALIGN_TOPLEFT

public static final int ALIGN_TOPLEFT
See Also:
Constant Field Values

ALIGN_BOTTOMRIGHT

public static final int ALIGN_BOTTOMRIGHT
See Also:
Constant Field Values

HORIZONTAL

public static final boolean HORIZONTAL
See Also:
Constant Field Values

VERTICAL

public static final boolean VERTICAL
See Also:
Constant Field Values

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:
isHorizontal - false(VERTICAL) will orient children vertically; true(HORIZONTAL) will orient children horizontally.
Since:
2.0
Method Detail

calculateMinimumSize

public Dimension calculateMinimumSize(IFigure container,
                                      int wHint,
                                      int hHint)
Calculates the minimum size of the container based on the given hints. If this is a vertically-oriented Toolbar Layout, then only the widthHint is respected (which means that the children can be as tall as they desire). In this case, the minimum width is that of the widest child, and the minimum height is the sum of the minimum heights of all children, plus the spacing between them. The border and insets of the container figure are also accounted for.

Overrides:
calculateMinimumSize in class AbstractHintLayout
Parameters:
container - The IFigure whose minimum size has to be calculated
wHint - The width hint (the desired width of the container)
hHint - The height hint (the desired height of the container)
Returns:
The minimum size of the container
Since:
2.1
See Also:
AbstractHintLayout.getMinimumSize(IFigure, int, int)

calculatePreferredSize

protected Dimension calculatePreferredSize(IFigure container,
                                           int wHint,
                                           int hHint)
Calculates the preferred size of the container based on the given hints. If this is a vertically-oriented Toolbar Layout, then only the widthHint is respected (which means that the children can be as tall as they desire). In this case, the preferred width is that of the widest child, and the preferred height is the sum of the preferred heights of all children, plus the spacing between them. The border and insets of the container figure are also accounted for.

Specified by:
calculatePreferredSize in class AbstractLayout
Parameters:
container - The IFigure whose preferred size has to be calculated
wHint - The width hint (the desired width of the container)
hHint - The height hint (the desired height of the container)
Returns:
The preferred size of the container
Since:
2.0
See Also:
AbstractHintLayout.getPreferredSize(IFigure, int, int)

isHorizontal

public boolean isHorizontal()
Returns whether the orientation of the layout is horizontal.

Returns:
true if the orientation is horizontal
Since:
2.0

isSensitiveHorizontally

protected boolean isSensitiveHorizontally(IFigure parent)
Description copied from class: AbstractHintLayout
Returns whether this layout manager is sensitive to changes in the horizontal hint. By default, this method returns true.

Overrides:
isSensitiveHorizontally in class AbstractHintLayout
Parameters:
parent - the layout's container
Returns:
true if this layout is sensite to horizontal hint changes
See Also:
org.eclipse.draw2d.AbstractHintLayout#isSensitiveHorizontally()

isSensitiveVertically

protected boolean isSensitiveVertically(IFigure parent)
Description copied from class: AbstractHintLayout
Returns whether this layout manager is sensitive to changes in the vertical hint. By default, this method returns true.

Overrides:
isSensitiveVertically in class AbstractHintLayout
Parameters:
parent - the layout's container
Returns:
true if this layout is sensite to vertical hint changes
See Also:
org.eclipse.draw2d.AbstractHintLayout#isSensitiveVertically()

layout

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

Parameters:
parent - The figure
See Also:
LayoutManager.layout(IFigure)

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)
Deprecated. use setStretchMinorAxis

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

setStretchMinorAxis

public void setStretchMinorAxis(boolean stretch)
Causes children that are smaller in the dimension of the minor axis to be stretched to fill the minor axis. The minor axis is the opposite of the orientation.

Parameters:
stretch - whether to stretch children
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

Eclipse Draw2d
2.1

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