|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.izforge.izpack.gui.TwoColumnLayout
This class implements a layout manager that generally lays out components in two columns.
The design goal for this layout manager was to lay out forms for data entry, where there are
several rows of entry fields with associated labels. The goal was to have the beginning off all
labels line up, as well as the left edge of all the data entry fields. This leads to a situation
where all components are essentially laid out in two columns. The columns adjust to accommodate
components of various sizes. This means that components that are added are laid out top to
bottom, either in the left column, in the right column or straddling both columns. In addition to
this general behavior, the following additional layout capabilities are supported:
TwoColumnConstraints
Field Summary | |
private int |
alignment
|
static int |
CENTER
|
private int |
centerRule
|
private java.util.Vector[] |
components
holds all the components and layout constraints. |
private int |
gap
the gap between the two columns |
private int |
indent
the indent setting in % of the conteiner's width |
static int |
LEFT
|
private int |
leftRule
|
private int |
margin
the margin setting in % of the container's width |
static int |
RIGHT
|
private int |
rightRule
|
private TwoColumnConstraints |
title
holds the component to be placed in the title region, including layout constraints. |
private int |
titleHeight
|
private int |
topBuffer
the setting for the buffer area on top of hte comonent cluster in % of the left over height. |
Constructor Summary | |
TwoColumnLayout(int margin,
int gap,
int indent,
int topBuffer,
int alignment)
Constructs a TwoColumnLayout layout manager. |
Method Summary | |
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object constraints)
Sets the constraints for the specified component in this layout. |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
Adds the specified component with the specified name to the layout. |
float |
getLayoutAlignmentX(java.awt.Container parent)
Returns the alignment along the x axis. |
float |
getLayoutAlignmentY(java.awt.Container parent)
Returns the alignment along the y axis. |
private int |
height(int row,
int column)
Measures and returns the minimum height required to render the component in the indicated row and column. |
void |
invalidateLayout(java.awt.Container parent)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. |
void |
layoutContainer(java.awt.Container parent)
Lays out the container in the specified panel. |
private int |
margin(java.awt.Container parent)
Computes the margin value based on the container width and the margin setting. |
java.awt.Dimension |
maximumLayoutSize(java.awt.Container parent)
Calculates the maximum size dimensions for the specified panel given the components in the specified parent container. |
private int |
minimumBothColumnsWidth(java.awt.Container parent)
Retrunds the minimum width both columns together should have based on the minimum widths of all the components that straddle both columns and the minimum width of the title component. |
private int |
minimumClusterHeight()
|
private int |
minimumColumnWidth(int column,
java.awt.Container parent)
Returns the minimum width of the column requested. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container. |
private void |
positionComponent(int y,
int row,
int column,
java.awt.Container parent)
Positiones one component as instructed. |
private void |
positionComponents(java.awt.Container parent)
Positions all components in the container. |
private void |
positionRules(java.awt.Container parent)
Positions the three rules in preparation for layout. |
private void |
positionTitle(java.awt.Container parent)
Positions the title component and sets the variable titleHeight . |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container. |
void |
removeLayoutComponent(java.awt.Component comp)
This functionality is not supported |
private int |
rowHeight(int row)
Measures and returns the minimum height required to render the components in the indicated row. |
private int |
rows()
Returns the number of rows that need to be laid out. |
void |
showRules(java.awt.Graphics2D graphics,
java.awt.Color color)
This method is provided for conveninence of debugging layout problems. |
private int |
topBuffer(int usedHeight,
java.awt.Container parent)
Computes the top buffer value based on the container width and the setting for the top buffer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LEFT
public static final int RIGHT
public static final int CENTER
private java.util.Vector[] components
private TwoColumnConstraints title
private int margin
private int topBuffer
private int indent
private int gap
private int alignment
private int leftRule
private int rightRule
private int centerRule
private int titleHeight
Constructor Detail |
public TwoColumnLayout(int margin, int gap, int indent, int topBuffer, int alignment)
TwoColumnLayout
layout manager. To add components use the
container's add(comp, constraints)
method with a TwoColumnConstraints object.
margin
- the margin width to use on the left and right side in % of the total container
width. Values less than 0% and greater than 50% are not accepted.gap
- the gap between the two columns.indent
- the indent to use for components that have that constraint set. This is a value
in pixels.topBuffer
- the percentage of left over vertical space to place on top of the component
cluster. Values between 0% and 100% are accepted.alignment
- how to align the overall layout. Legal values are LEFT, CENTER, RIGHT.Method Detail |
public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
null
is a
legal value for a component, but not for a constraints object.
addLayoutComponent
in interface java.awt.LayoutManager2
comp
- the component to be modified.constraints
- the constraints to be applied.public void layoutContainer(java.awt.Container parent)
layoutContainer
in interface java.awt.LayoutManager
parent
- the component which needs to be laid out.private void positionRules(java.awt.Container parent)
leftRule
rightRule
centerRule
parent
- the component which needs to be laid out.private void positionTitle(java.awt.Container parent)
titleHeight
. Note:
this method depends on the fact that the rules are set to their correct layout position.
parent
- the component which needs to be laid out.private void positionComponents(java.awt.Container parent)
parent
- the component which needs to be laid out.private void positionComponent(int y, int row, int column, java.awt.Container parent)
stretch
, BOTH
and indent
are taken into
account. In addition, empty comonents are handled properly.
y
- the y location within the continer, where the component should be positioned.row
- the row of the componentcolumn
- the column of the componentparent
- the container which needs to be laid out.private int minimumColumnWidth(int column, java.awt.Container parent)
column
- the columns to measure (LEFT / RIGHT)parent
- the component which needs to be laid out.
private int minimumBothColumnsWidth(java.awt.Container parent)
parent
- the component which needs to be laid out.
private int minimumClusterHeight()
private int rows()
private int rowHeight(int row)
row
- the index of the row to measureprivate int height(int row, int column)
row
- the index of the row to measurecolumn
- the column of the component to measure (LEFT
or
RIGHT
)private int margin(java.awt.Container parent)
parent
- the component which needs to be laid out.private int topBuffer(int usedHeight, java.awt.Container parent)
usedHeight
- the amount of the parent component's height that is already in use (height
of the title and the combined height of all rows).parent
- the component which needs to be laid out.public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
parent
- the component to be laid outpublic java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
parent
- the component to be laid outpublic java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
maximumLayoutSize
in interface java.awt.LayoutManager2
parent
- the component to be laid outpublic float getLayoutAlignmentX(java.awt.Container parent)
getLayoutAlignmentX
in interface java.awt.LayoutManager2
parent
- the component to be laid outpublic float getLayoutAlignmentY(java.awt.Container parent)
getLayoutAlignmentY
in interface java.awt.LayoutManager2
parent
- the component to be laid outpublic void invalidateLayout(java.awt.Container parent)
invalidateLayout
in interface java.awt.LayoutManager2
parent
- the component to be laid outpublic void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
with layout contsraints.
addLayoutComponent
in interface java.awt.LayoutManager
name
- the component namecomp
- the component to be addedpublic void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
comp
- the component to be removedpublic void showRules(java.awt.Graphics2D graphics, java.awt.Color color)
paint()
method.
super.paint()
paint()
method to
Graphics2D
when making the call.
graphics
- the graphics context used for drawing.color
- the color to use for rendering the layout grid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |