net.sf.jguiraffe.gui.layout
Class ButtonLayout

java.lang.Object
  extended by net.sf.jguiraffe.gui.layout.PercentLayoutBase
      extended by net.sf.jguiraffe.gui.layout.ButtonLayout
All Implemented Interfaces:
java.io.Serializable

public class ButtonLayout
extends PercentLayoutBase

A layout manager that deals with button bars for dialogs.

With this layout manager typical horizontal button bars for dialogs can be created in an easy way. The button objects simply need to be added to the container, no constraints need to be passed. These button bars have the following properties:

This class is a special implementation of PercentLayoutBase. It implements the button layout on top of a percent layout. As its ancestor this class is platform neutral, i.e. it can work together with different GUI libraries for which a PercentLayoutPlatformAdapter implementation is available.

Version:
$Id: ButtonLayout.java 164 2009-08-01 15:14:51Z oheger $
Author:
Oliver Heger
See Also:
Serialized Form

Nested Class Summary
static class ButtonLayout.Alignment
          An enumeration class for the alignment of a ButtonLayout.
 
Constructor Summary
ButtonLayout()
          Creates a new instance of ButtonLayout.
 
Method Summary
 ButtonLayout.Alignment getAlignment()
          Returns the alignment of the button bar.
 NumberWithUnit getBottomMargin()
          Returns the bottom margin.
 NumberWithUnit getGap()
          Returns the width of the gap between the buttons.
 NumberWithUnit getLeftMargin()
          Returns the left margin.
 NumberWithUnit getRightMargin()
          Returns the right margin.
 NumberWithUnit getTopMargin()
          Returns the top margin.
protected  void initCells(PercentLayoutPlatformAdapter adapter)
          Initializes the whole layout.
protected  void initColumnConstraints(int lastIndex, int buttonCount)
          Initializes the column constraints.
protected  void initRowConstraints()
          Initializes the row constraints.
protected  void insertButtons(PercentLayoutPlatformAdapter adapter, int buttonCount)
          Inserts all buttons into the percent layout.
 void setAlignment(ButtonLayout.Alignment alignment)
          Sets the alignment of the button bar.
 void setBottomMargin(NumberWithUnit bottomMargin)
          Sets the bottom margin.
 void setGap(NumberWithUnit gap)
          Sets the width of the gap between the buttons.
 void setLeftMargin(NumberWithUnit leftMargin)
          Sets the left margin.
 void setRightMargin(NumberWithUnit rightMargin)
          Sets the right margin.
 void setTopMargin(NumberWithUnit topMargin)
          Sets the top margin.
 
Methods inherited from class net.sf.jguiraffe.gui.layout.PercentLayoutBase
addColumnGroup, addRowGroup, alignComponent, applyCellGroups, applyWeightFactors, applyWeightFactors, calcCellPositions, calcCellSize, calcCellSizes, calcCellSizesWithGroups, calcComponentSize, calcComponentSizes, calcLayoutSize, calcMinimumLayoutSize, calcTotalWeight, checkConstraints, clearCells, clearCells, constraintsFor, fetchPlatformAdapter, flushCache, getAllColumnConstraints, getAllRowConstraints, getColumnConstraints, getColumnCount, getColumnGroups, getComponent, getConstraintsBuilder, getMinimumComponentSize, getOrientationValue, getPercentData, getPlatformAdapter, getPreferredComponentSize, getRowConstraints, getRowCount, getRowGroups, getSizeHandler, getTotalWeightX, getTotalWeightY, handleMultiSpans, initCell, initDimensions, initFromCollections, performLayout, removeComponent, setColumnConstraints, setComponentBounds, setPlatformAdapter, setRowConstraints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ButtonLayout

public ButtonLayout()
Creates a new instance of ButtonLayout. All properties are set to default values.

Method Detail

getTopMargin

public NumberWithUnit getTopMargin()
Returns the top margin.

Returns:
the top margin

setTopMargin

public void setTopMargin(NumberWithUnit topMargin)
Sets the top margin. This is the space above the buttons.

Parameters:
topMargin - the top margin (a null reference is converted to a value of 0)

getBottomMargin

public NumberWithUnit getBottomMargin()
Returns the bottom margin.

Returns:
the bottom margin

setBottomMargin

public void setBottomMargin(NumberWithUnit bottomMargin)
Sets the bottom margin. This is the space below the buttons.

Parameters:
bottomMargin - the bottom margin

getLeftMargin

public NumberWithUnit getLeftMargin()
Returns the left margin.

Returns:
the left margin

setLeftMargin

public void setLeftMargin(NumberWithUnit leftMargin)
Sets the left margin. This is the space between the window's left edge and the first button. This value is fixed only if the button bar is left aligned; otherwise this space may grow.

Parameters:
leftMargin - the left margin (a null reference is converted to a value of 0)

getRightMargin

public NumberWithUnit getRightMargin()
Returns the right margin.

Returns:
the right margin

setRightMargin

public void setRightMargin(NumberWithUnit rightMargin)
Sets the right margin. This is the space between the window's right edge and the last button. This value is fixed only if the button bar is right aligned; otherwise this space may grow.

Parameters:
rightMargin - the right margin (a null reference is converted to a value of 0)

getGap

public NumberWithUnit getGap()
Returns the width of the gap between the buttons.

Returns:
the gap

setGap

public void setGap(NumberWithUnit gap)
Sets the width of the gap between the buttons.

Parameters:
gap - the gap's width (a null reference is converted to a value of 0)

getAlignment

public ButtonLayout.Alignment getAlignment()
Returns the alignment of the button bar.

Returns:
the alignment

setAlignment

public void setAlignment(ButtonLayout.Alignment alignment)
Sets the alignment of the button bar.

Parameters:
alignment - the new alignment (must not be null)
Throws:
java.lang.IllegalArgumentException - if the alignment is null

initCells

protected void initCells(PercentLayoutPlatformAdapter adapter)
Initializes the whole layout. Creates a percent layout based on the current property values and the contained buttons.

Specified by:
initCells in class PercentLayoutBase
Parameters:
adapter - the currently used platform adapter

initRowConstraints

protected void initRowConstraints()
Initializes the row constraints.


initColumnConstraints

protected void initColumnConstraints(int lastIndex,
                                     int buttonCount)
Initializes the column constraints.

Parameters:
lastIndex - the index of the last column
buttonCount - the number of buttons

insertButtons

protected void insertButtons(PercentLayoutPlatformAdapter adapter,
                             int buttonCount)
Inserts all buttons into the percent layout.

Parameters:
adapter - the platform adapter
buttonCount - the number of available buttons


Copyright © 2009 The JGUIraffe Team. All Rights Reserved.