|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.sahits.game.graphic.layout.SahitsMaximalGridLayout
public class SahitsMaximalGridLayout
Grid layout that sizes the cells according the the biggest sized ISahitsComponent in the same row/column. If the ISahitsComponent does not fill the whole size of the cell it is by default positioned in the center.
| Field Summary | |
|---|---|
private Hashtable<ISahitsComponent,MaximalGridLayoutConstraints> |
compTable
|
private int |
gap
|
private int[] |
maxHight
|
private int[] |
maxWidth
|
private int |
nbCols
|
private int |
nbRows
|
private ECellPosition |
position
|
| Constructor Summary | |
|---|---|
SahitsMaximalGridLayout()
Default constructor initializing a grid of size 1x1. |
|
SahitsMaximalGridLayout(int cols,
int rows)
Initialize the layout with the number of columns and rows |
|
SahitsMaximalGridLayout(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(ISahitsComponent comp,
ISahitsLayoutConstraint constraints)
Adding a ISahitsComponent with a MaximalGridLayoutConstraints |
private int |
addUpColumnWidth(ISahitsContainer parent)
Adding up the column width of a ISahitsContainer. |
private int |
addUpRowHeight(ISahitsContainer parent)
Adding up the row height of a ISahitsContainer. |
private boolean |
checkHeight(ISahitsContainer parent)
check if the size of the children add up to more than the parents size |
private boolean |
checkWidth(ISahitsContainer 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 ISahitsComponent |
(package private) int |
computeHeight(int row,
ISahitsContainer parent)
Compute the height of the highest ISahitsComponent in the specified row. |
private double |
computeHeightScale(ISahitsContainer parent)
Compute the scale factor that is needed on the ISahitsComponents to resize them to the heigth of the ISahitsContainer |
(package private) int |
computeRowIndex(int i)
Compute the row based on the index of the ISahitsComponent |
(package private) int |
computeWidth(int column,
ISahitsContainer parent)
Compute the width of the widest ISahitsComponent in the specified column. |
private double |
computeWidthScale(ISahitsContainer parent)
Compute the scale factor that is needed on the ISahitsComponents to resize them to the width of the ISahitsContainer |
(package private) int |
computeXPadding(int columnWidth,
int width,
MaximalGridLayoutConstraints constraints)
Compute the horizontal padding within a cell based upon the alignment of the ISahitsComponent |
(package private) int |
computeYPadding(int rowHeight,
int height,
MaximalGridLayoutConstraints constraints)
Compute the vertical padding within a cell based upon the alignment of the ISahitsComponent |
(package private) int |
getColumnStart(int index,
ISahitsContainer parent)
Compute the x position where the column with the given index starts |
MaximalGridLayoutConstraints |
getConstraints(ISahitsComponent comp)
Gets the constraints for the specified ISahitsComponent. |
(package private) int |
getRowStart(int index,
ISahitsContainer parent)
Compute the y position where the row with the given index starts |
void |
layoutContainer(ISahitsContainer parent)
Compute the layout of the all the children in the parent container. |
Dimension |
preferredLayoutSize(ISahitsContainer parent)
Computing the prefered size by adding the sizes of the columns and rows together with the insets |
private void |
resetSizeCache()
|
void |
setConstraints(ISahitsComponent comp,
MaximalGridLayoutConstraints constraints)
Sets the constraints for the specified ISahitsComponent 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<ISahitsComponent,MaximalGridLayoutConstraints> compTable
| Constructor Detail |
|---|
public SahitsMaximalGridLayout(int cols,
int rows)
cols - rows -
public SahitsMaximalGridLayout(int cols,
int rows,
int gapWidth,
ECellPosition positioning)
cols - rows - gapWidth - positioning - public SahitsMaximalGridLayout()
| Method Detail |
|---|
private void resetSizeCache()
final int computeWidth(int column,
ISahitsContainer parent)
column - number of the column (starting with index 1)parent - parent ISahitsContainer
final int computeHeight(int row,
ISahitsContainer parent)
row - number of the row (starting with index 1)parent - parent ISahitsContainer
public Dimension preferredLayoutSize(ISahitsContainer parent)
public void layoutContainer(ISahitsContainer parent)
ISahitsLayoutManager
layoutContainer in interface ISahitsLayoutManagerprivate double computeHeightScale(ISahitsContainer parent)
parent - ISahitsContainer
private double computeWidthScale(ISahitsContainer parent)
parent - ISahitsContainer
private boolean checkHeight(ISahitsContainer parent)
parent - ISahitsContainer
private int addUpRowHeight(ISahitsContainer parent)
parent - ISahitsContainer
private boolean checkWidth(ISahitsContainer parent)
parent - ISahitsContainer
private int addUpColumnWidth(ISahitsContainer parent)
parent - ISahitsContainer
final int computeYPadding(int rowHeight,
int height,
MaximalGridLayoutConstraints constraints)
rowHeight - height of the cellheight - of the ISahitsComponentconstraints - Objects
final int computeXPadding(int columnWidth,
int width,
MaximalGridLayoutConstraints constraints)
columnWidth - width of the cellwidth - of the ISahitsComponentconstraints - Object
final int getRowStart(int index,
ISahitsContainer parent)
index - of the rowparent - ISahitsContainer
final int getColumnStart(int index,
ISahitsContainer parent)
index - of the columnparent - ISahitsContainer
final int computeRowIndex(int i)
i - index of the ISahitsComponent
final int computeColumnIndex(int i)
i - index of the ISahitsComponent
public void setConstraints(ISahitsComponent comp,
MaximalGridLayoutConstraints constraints)
comp - the ISahitsComponent to be modifiedconstraints - the constraints to be appliedpublic MaximalGridLayoutConstraints getConstraints(ISahitsComponent comp)
GridBagConstraints object is returned.
comp - the ISahitsComponent to be queried
public void addLayoutComponent(ISahitsComponent comp,
ISahitsLayoutConstraint constraints)
MaximalGridLayoutConstraints
addLayoutComponent in interface ISahitsLayoutManager
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||