| java.lang.Object pnuts.awt.PnutsLayout
PnutsLayout | public class PnutsLayout implements LayoutManager2,Serializable(Code) | | The PnutsLayout is a general purpose geometry manager. It is very easy to use and can accomplish any grid based layout.
setLayout(new PnutsLayout(3));
add(button1, "ipadding=20");
add(button2, "padding=20");
add(button3, "colspan=2");
add(button4, "rowspan=2");
add(button3, "align=top:left");
add(button3, "align=bottom:right");
add(button3, "width=100:center");
Property |
Meaning |
Default |
constructor |
add() |
columns |
The number of columns. |
1 |
true |
false |
uniform |
Sets the width or height to be the same for each column. Can be x/y/xy/none. |
none |
true |
false |
colspan |
Number of columns the component occupies. |
1 |
false |
true |
rowspan |
Number of rows the component occupies. |
1 |
false |
true |
spacing |
Minimum spacing that will be put around the component. Can be a single value (5) or top:right:bottom:left (eg 5:10:5:10). |
0 |
true |
true |
padding |
Padding around the component. Can be a single value (5) or top:right:bottom:left (eg 5:10:5:10). |
0 |
true |
true |
ipadding |
Padding inside the component (making it larger). Can be a single value (5) or x:y (eg 5:10). |
0 |
true |
true |
fill |
Sets the width and/or height of the component to a percentage of the cell width. Can be x/y/xy/none or a single value (5) or
x:y (eg 25:75). 0 or none sizes the component to its preferred size. |
none |
true |
true |
align |
Alignment of the component in the cell. Can be top/bottom/left/right/center or top/bottom/center:left/right/center (eg
top:right). |
center |
true |
true |
expand |
Expands the size of the cell so the table takes up the size of the container. Can be x/y/xy/none. |
none |
true |
true |
border |
Draws the grid borders of the table. Great for debugging. Can be true/false. |
false |
true |
true |
version: 2.0 author: Toyokazu Tomatsu author: Nathan Sweet (misc@n4te.com) |
Inner Class :abstract public class Constraints | |
Inner Class :public class TableConstraints extends Constraints | |
Inner Class :public class CellConstraints extends Constraints | |
Field Summary | |
final public static int | BOTTOM | final public static int | CENTER | final public static int | LEFT | final public static int | NONE | final public static int | RIGHT | final public static int | TOP | final public static int | X | final public static int | Y |
Constructor Summary | |
public | PnutsLayout() Constructs a PnutsLayout with a single column. | public | PnutsLayout(int columns) Constructs a PnutsLayout with the specified number of columns. | public | PnutsLayout(String str) | public | PnutsLayout(Map map) Constructs a PnutsLayout from a constraint Map. |
Method Summary | |
public void | addLayoutComponent(Component comp, Object obj) Adds the specified component to the layout, using the specified constraint object. | public void | addLayoutComponent(String name, Component comp) Adds the specified component with the specified name to the layout. | public TableConstraints | getCellConstraints(Component comp) Returns the constraints used by the cell for the specified component. | public Point | getGridPoint(int gridX, int gridY) Returns the left-top point of the specified cell. | public Rectangle | getGridRectangle(Container parent, int index) Returns the bounding box for child component at the specified index. | public float | getLayoutAlignmentX(Container target) Returns the alignment along the x axis. | public float | getLayoutAlignmentY(Container target) Returns the alignment along the y axis. | public int | getRows() Returns the number of rows in this layout. | public TableConstraints | getTableConstraints() Returns the constraints used by the table and the default constraints used for all cells in the table. | public void | invalidate() Invalidates the layout, indicating that if the PnutsLayout has cached information it should be discarded. | public void | invalidateLayout(Container target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. | public void | layoutContainer(Container target) Lays out the container. | public Dimension | maximumLayoutSize(Container target) Returns the maximum size of this component. | public Dimension | minimumLayoutSize(Container target) Returns the minimum dimensions needed to layout the components contained in the specified target container. | public Dimension | preferredLayoutSize(Container target) Returns the preferred dimensions for this layout given the components in the specified target container. | public void | removeLayoutComponent(Component comp) Removes the specified component from the layout. | public void | setConstraints(Component comp, String str) Sets the constraints for a component. | public void | setConstraints(Component comp, Map map) Sets the constraints for a component. | public void | setConstraints(Component comp, CellConstraints constraints) Sets the constraints for a component. | static Map | str2table(String constraintString) Transforms a constraint name/value pair String into a Map. | public String | toString() |
BOTTOM | final public static int BOTTOM(Code) | | |
CENTER | final public static int CENTER(Code) | | |
LEFT | final public static int LEFT(Code) | | |
NONE | final public static int NONE(Code) | | |
RIGHT | final public static int RIGHT(Code) | | |
TOP | final public static int TOP(Code) | | |
X | final public static int X(Code) | | |
Y | final public static int Y(Code) | | |
PnutsLayout | public PnutsLayout()(Code) | | Constructs a PnutsLayout with a single column.
|
PnutsLayout | public PnutsLayout(int columns)(Code) | | Constructs a PnutsLayout with the specified number of columns.
|
PnutsLayout | public PnutsLayout(Map map)(Code) | | Constructs a PnutsLayout from a constraint Map. See PnutsLayout class comments for constraints usage.
Parameters: map - |
addLayoutComponent | public void addLayoutComponent(Component comp, Object obj)(Code) | | Adds the specified component to the layout, using the specified constraint object.
Parameters: obj - Map or String defining constraints for the component. |
addLayoutComponent | public void addLayoutComponent(String name, Component comp)(Code) | | Adds the specified component with the specified name to the layout.
|
getCellConstraints | public TableConstraints getCellConstraints(Component comp)(Code) | | Returns the constraints used by the cell for the specified component. Modifying this object will modify the cell's
constraints.
|
getGridPoint | public Point getGridPoint(int gridX, int gridY)(Code) | | Returns the left-top point of the specified cell.
|
getGridRectangle | public Rectangle getGridRectangle(Container parent, int index)(Code) | | Returns the bounding box for child component at the specified index.
|
getLayoutAlignmentX | public float getLayoutAlignmentX(Container target)(Code) | | Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other
components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the
furthest away from the origin, 0.5 is centered, etc.
|
getLayoutAlignmentY | public float getLayoutAlignmentY(Container target)(Code) | | Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other
components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the
furthest away from the origin, 0.5 is centered, etc.
|
getRows | public int getRows()(Code) | | Returns the number of rows in this layout.
|
getTableConstraints | public TableConstraints getTableConstraints()(Code) | | Returns the constraints used by the table and the default constraints used for all cells in the table. Modifying this object
will modify the table's constraints.
|
invalidate | public void invalidate()(Code) | | Invalidates the layout, indicating that if the PnutsLayout has cached information it should be discarded. This happens
automatically when cell or table constraints are modified.
|
invalidateLayout | public void invalidateLayout(Container target)(Code) | | Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
|
layoutContainer | public void layoutContainer(Container target)(Code) | | Lays out the container. This method will actually reshape the components in the target in order to satisfy the constraints
of the PnutsLayout object.
See Also: Container |
removeLayoutComponent | public void removeLayoutComponent(Component comp)(Code) | | Removes the specified component from the layout.
|
setConstraints | public void setConstraints(Component comp, String str)(Code) | | Sets the constraints for a component. See PnutsLayout class comments for constraints usage.
|
setConstraints | public void setConstraints(Component comp, Map map)(Code) | | Sets the constraints for a component. See PnutsLayout class comments for constraints usage.
|
setConstraints | public void setConstraints(Component comp, CellConstraints constraints)(Code) | | Sets the constraints for a component. See PnutsLayout class comments for constraints usage.
|
str2table | static Map str2table(String constraintString)(Code) | | Transforms a constraint name/value pair String into a Map.
|
|
|