|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.sahits.game.graphic.layout.MaximalGridLayout
public class MaximalGridLayout
Grid layout that sizes the cells according the the biggest sized component in the same row/column. If the component does not fill the whole size of the cell it is by default positioned in the center.
| Field Summary | |
|---|---|
private Hashtable<Component,MaximalGridLayoutConstraints> |
compTable
|
private int |
gap
|
private int[] |
maxHight
|
private int[] |
maxWidth
|
private int |
nbCols
|
private int |
nbRows
|
private ECellPosition |
position
|
| Constructor Summary | |
|---|---|
MaximalGridLayout()
Default constructor initializing a grid of size 1x1. |
|
MaximalGridLayout(int cols,
int rows)
Initialize the layout with the number of columns and rows |
|
MaximalGridLayout(int cols,
int rows,
int gapWidth,
ECellPosition positioning)
Initialize the layout with the number of columns and rows and the gaping between them as well as the positioning of the whole if there is any space. |
|
| Method Summary | |
|---|---|
void |
addLayoutComponent(Component comp,
Object constraints)
Adding a component with a MaximalGridLayoutConstraints |
void |
addLayoutComponent(String name,
Component comp)
Has no effect, since this layout manager does not use a per-component string. |
private int |
addUpColumnWidth(Container parent)
Adding up the column width of a container. |
private int |
addUpRowHeight(Container parent)
Adding up the row height of a container. |
private boolean |
checkHeight(Container parent)
check if the size of the children add up to more than the parents size |
private boolean |
checkWidth(Container parent)
check if the size of the children add up to more than the parents size |
(package private) int |
computeColumnIndex(int i)
Compute the column based on the index of the component |
(package private) int |
computeHeight(int row,
Container parent)
Compute the height of the highest component in the specified row. |
private double |
computeHeightScale(Container parent)
Compute the scale factor that is needed on the components to resize them to the heigth of the container |
(package private) int |
computeRowIndex(int i)
Compute the row based on the index of the component |
(package private) int |
computeWidth(int column,
Container parent)
Compute the width of the widest component in the specified column. |
private double |
computeWidthScale(Container parent)
Compute the scale factor that is needed on the components to resize them to the width of the container |
(package private) int |
computeXPadding(int columnWidth,
int width,
MaximalGridLayoutConstraints constraints)
Compute the horizontal padding within a cell based upon the alignment of the component |
(package private) int |
computeYPadding(int rowHeight,
int height,
MaximalGridLayoutConstraints constraints)
Compute the vertical padding within a cell based upon the alignment of the component |
(package private) int |
getColumnStart(int index,
Container parent)
Compute the x position where the column with the given index starts |
MaximalGridLayoutConstraints |
getConstraints(Component comp)
Gets the constraints for the specified component. |
float |
getLayoutAlignmentX(Container target)
If there is a constraint defined by the target, the position
is used for the alignment |
float |
getLayoutAlignmentY(Container target)
If there is a constraint defined by the target, the position
is used for the alignment |
(package private) int |
getRowStart(int index,
Container parent)
Compute the y position where the row with the given index starts |
void |
invalidateLayout(Container target)
|
void |
layoutContainer(Container parent)
|
Dimension |
maximumLayoutSize(Container target)
|
Dimension |
minimumLayoutSize(Container parent)
|
Dimension |
preferredLayoutSize(Container parent)
Computing the prefered size by adding the sizes of the columns and rows together with the insets |
void |
removeLayoutComponent(Component comp)
Remove the component from the stored data. |
private void |
resetSizeCache()
|
void |
setConstraints(Component comp,
MaximalGridLayoutConstraints constraints)
Sets the constraints for the specified component in this layout. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final int nbCols
private final int nbRows
private final int[] maxWidth
private final int[] maxHight
private final int gap
private final ECellPosition position
private final Hashtable<Component,MaximalGridLayoutConstraints> compTable
| Constructor Detail |
|---|
public MaximalGridLayout(int cols,
int rows)
cols - rows -
public MaximalGridLayout(int cols,
int rows,
int gapWidth,
ECellPosition positioning)
cols - rows - gapWidth - positioning - public MaximalGridLayout()
| Method Detail |
|---|
private void resetSizeCache()
public void addLayoutComponent(String name,
Component comp)
addLayoutComponent in interface LayoutManagerpublic void removeLayoutComponent(Component comp)
removeLayoutComponent in interface LayoutManager
final int computeWidth(int column,
Container parent)
column - number of the column (starting with index 1)parent - parent container
final int computeHeight(int row,
Container parent)
row - number of the row (starting with index 1)parent - parent container
public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize in interface LayoutManagerpublic void layoutContainer(Container parent)
layoutContainer in interface LayoutManagerprivate double computeHeightScale(Container parent)
parent - container
private double computeWidthScale(Container parent)
parent - container
private boolean checkHeight(Container parent)
parent - container
private int addUpRowHeight(Container parent)
parent - container
private boolean checkWidth(Container parent)
parent - container
private int addUpColumnWidth(Container parent)
parent - container
final int computeYPadding(int rowHeight,
int height,
MaximalGridLayoutConstraints constraints)
rowHeight - height of the cellheight - of the componentconstraints - Objects
final int computeXPadding(int columnWidth,
int width,
MaximalGridLayoutConstraints constraints)
columnWidth - width of the cellwidth - of the componentconstraints - Object
final int getRowStart(int index,
Container parent)
index - of the rowparent - container
final int getColumnStart(int index,
Container parent)
index - of the columnparent - container
final int computeRowIndex(int i)
i - index of the component
final int computeColumnIndex(int i)
i - index of the component
public Dimension minimumLayoutSize(Container parent)
minimumLayoutSize in interface LayoutManager
public void setConstraints(Component comp,
MaximalGridLayoutConstraints constraints)
comp - the component to be modifiedconstraints - the constraints to be appliedpublic MaximalGridLayoutConstraints getConstraints(Component comp)
GridBagConstraints object is returned.
comp - the component to be queried
public void addLayoutComponent(Component comp,
Object constraints)
MaximalGridLayoutConstraints
addLayoutComponent in interface LayoutManager2public Dimension maximumLayoutSize(Container target)
maximumLayoutSize in interface LayoutManager2public float getLayoutAlignmentX(Container target)
target, the position
is used for the alignment
getLayoutAlignmentX in interface LayoutManager2public float getLayoutAlignmentY(Container target)
target, the position
is used for the alignment
getLayoutAlignmentY in interface LayoutManager2public void invalidateLayout(Container target)
invalidateLayout in interface LayoutManager2
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||