|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.gjt.universe.gui.StripLayout
This class is a layout manager which places components adjacent to each other in a horizontal or vertical strip, without attempting to standardize the size of the components like a GridLayout would, or stretch components to fill all the available space like it and other standard layouts would. As well, this layout manager will not automatically stretch components to fill all available space. Instead, components will be packed a tightly as possible based on their preferred size. Additional attributes of this layout manager allow introduction of a uniform inter-component gap and minimum size. By design, this layout manager differs from the FlowLayout in that it will not wrap and thus is a good choice for use when this is undesirable. Instead of wrapping this layout will attempt to stay within the maximum size Although the same layouts can be achieved by using nested panels with different standard layout managers assigned carefully crafted constraints objects, this layout manager is many times easier to use. Acknowledgement: Inspired by the GPL'd StackLayout class of SoftBear, Inc. TO DO: - Add parameter to allow alignment to opposite end (i.e. right in horizontal, bottom in vertical) - Add option to allow filling of all the available space by stretching the components proportionally to their relative preferred sizes - Improve handling of hitting the maximum size of parent component by shrinking the to fit while maintaining relative preferred sizes and honoring minimum sizes.
Field Summary | |
static char |
HORIZONTAL
|
private int |
myGap
|
private int |
myMinHeight
|
private int |
myMinWidth
|
private char |
myOrientation
|
static char |
VERTICAL
|
Constructor Summary | |
StripLayout()
This constructor returns a StripLayout instance which will lay out components horizontally, with no gap between adjacent components and no minimum size for each component. |
|
StripLayout(char orientation)
This constructor returns a StripLayout instance which will lay out components in the given orientation with no gap between adjacent components and no minimum size for each component. |
|
StripLayout(char orientation,
int minWidth,
int minHeight,
int gap)
This method is the designated constructor for instances of this class. |
Method Summary | |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
|
void |
layoutContainer(java.awt.Container parent)
This method does the actual positioning of the components of the given container. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent)
This method returns the minimum size that should be needed to arrange the components of the given container using this layout instance. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent)
This method returns the preferred size for laying out the given container using this layout. |
void |
removeLayoutComponent(java.awt.Component comp)
|
private java.awt.Dimension |
totalComponentSizes(java.awt.Container parent,
boolean isMinimum)
This method returns the a summation of the sizes of all the components present in the given parent container, if they were to be laid out in our orientation and with the given gap. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static char HORIZONTAL
public static char VERTICAL
private char myOrientation
private int myMinWidth
private int myMinHeight
private int myGap
Constructor Detail |
public StripLayout()
public StripLayout(char orientation)
public StripLayout(char orientation, int minWidth, int minHeight, int gap)
orientation
- HORIZONTAL or VERTICALminWidth
- The minimum width which all components should be given.minHeight
- The minimum height which all components should be given.gap
- The number of pixels to be left between adjacent components.Method Detail |
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
in interface java.awt.LayoutManager
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
public void layoutContainer(java.awt.Container parent)
layoutContainer
in interface java.awt.LayoutManager
parent
- The container whose components are to be laid out.public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
parent
- The container whose oomponents would be laid out.public void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
private java.awt.Dimension totalComponentSizes(java.awt.Container parent, boolean isMinimum)
parent
- A container whose component sizes are to be summed.isMinimum
- If true then the minimum sizes are to be used, otherwise the preferred sizes will be used.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |