public class JideBoxLayout
extends java.lang.Object
implements java.awt.LayoutManager2, java.io.Serializable
JideSplitPane
.Modifier and Type | Field and Description |
---|---|
protected int |
_axis
Axis, 0 for horizontal, or 1 for vertical.
|
protected int[] |
_componentSizes |
protected java.awt.Container |
_target |
static java.lang.String |
FIX
For FIX component, the width (or height if vertical) is and will always be the preferred width.
|
static java.lang.String |
FLEXIBLE
FLEXIBLE components try to keep the preferred width.
|
static int |
LINE_AXIS
Specifies that components should be laid out in the direction of a line of text as determined by the target
container's
ComponentOrientation property. |
static int |
PAGE_AXIS
Specifies that components should be laid out in the direction that lines flow across a page as determined by the
target container's
ComponentOrientation property. |
static java.lang.String |
VARY
For VARY component, the width will always be whatever width left.
|
static int |
X_AXIS
Specifies that components should be laid out left to right.
|
static int |
Y_AXIS
Specifies that components should be laid out top to bottom.
|
Constructor and Description |
---|
JideBoxLayout(java.awt.Container target)
Creates a layout manager that will lay out components along the given axis.
|
JideBoxLayout(java.awt.Container target,
int axis) |
JideBoxLayout(java.awt.Container target,
int axis,
int gap) |
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.
|
void |
addLayoutComponent(java.lang.String name,
java.awt.Component component)
If the layout manager uses a per-component string, adds the component
comp to the layout,
associating it with the string specified by name . |
protected boolean |
calculateComponentSizes(int availableSize,
int startIndex,
int endIndex) |
protected boolean |
componentCountChanged(java.awt.Container c) |
protected int |
getAvailableSize(java.awt.Dimension containerSize,
java.awt.Insets insets)
Returns the available width based on the container size and Insets.
|
int |
getAxis()
Gets the axis.
|
java.util.Map<java.awt.Component,java.lang.Object> |
getConstraintMap()
Gets the map of constraints.
|
int |
getGap()
Gets the gap between each component.
|
protected int |
getInitialLocation(java.awt.Insets insets)
Returns the left inset, unless the Insets are null in which case 0 is returned.
|
float |
getLayoutAlignmentX(java.awt.Container target)
Returns the alignment along the x axis.
|
float |
getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis.
|
protected java.awt.Dimension |
getPreferredSizeOf(java.awt.Component comp,
int atIndex) |
protected int |
getPreferredSizeOfComponent(java.awt.Component c)
Returns the width of the passed in Components preferred size.
|
protected int |
getSizeOfComponent(java.awt.Component c)
Returns the width of the passed in component.
|
void |
invalidateLayout(java.awt.Container c)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
|
boolean |
isAlwaysLayout()
Checks if the alwaysLayout flag is true.
|
boolean |
isResetWhenInvalidate()
Checks of the layout should be reset when
invalidateLayout(java.awt.Container) is called. |
void |
layoutContainer(java.awt.Container container)
Lays out the specified container.
|
java.awt.Dimension |
maximumLayoutSize(java.awt.Container target)
Returns the maximum layout size, which is Integer.MAX_VALUE in both directions.
|
java.awt.Dimension |
minimumLayoutSize(java.awt.Container container)
Returns the minimum size needed to contain the children.
|
java.awt.Dimension |
preferredLayoutSize(java.awt.Container container)
Returns the preferred size needed to contain the children.
|
void |
removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.
|
protected static int |
resolveAxis(int axis,
java.awt.ComponentOrientation o)
Given one of the 4 axis values, resolve it to an absolute axis.
|
void |
setAlwaysLayout(boolean alwaysLayout)
Sets the alwaysLayout flag.
|
void |
setAxis(int axis)
Sets the axis.
|
protected void |
setComponentToSize(java.awt.Component c,
int size,
int location,
java.awt.Insets insets,
java.awt.Dimension containerSize)
Sets the width of the component c to be size, placing its x location at location, y to the insets.top and height
to the containersize.height less the top and bottom insets.
|
void |
setGap(int gap)
Sets the gap between each component.
|
void |
setResetWhenInvalidate(boolean resetWhenInvalidate)
Sets the flag if the layout should be reset when
invalidateLayout(java.awt.Container) is called. |
protected int _axis
protected java.awt.Container _target
protected int[] _componentSizes
public static final java.lang.String FIX
public static final java.lang.String FLEXIBLE
public static final java.lang.String VARY
public static final int X_AXIS
public static final int Y_AXIS
public static final int LINE_AXIS
ComponentOrientation
property.public static final int PAGE_AXIS
ComponentOrientation
property.public JideBoxLayout(java.awt.Container target)
target
- the container that needs to be laid outjava.awt.AWTError
- if the value of axis
is invalidpublic JideBoxLayout(java.awt.Container target, int axis)
target
- the container that needs to be laid outaxis
- the axis to lay out components along. Can be one of: JideBoxLayout.X_AXIS
,
JideBoxLayout.Y_AXIS
, JideBoxLayout.LINE_AXIS
or
JideBoxLayout.PAGE_AXIS
public JideBoxLayout(java.awt.Container target, int axis, int gap)
target
- the container that needs to be laid outaxis
- the axis to lay out components along. Can be one of: JideBoxLayout.X_AXIS
,
JideBoxLayout.Y_AXIS
, JideBoxLayout.LINE_AXIS
or
JideBoxLayout.PAGE_AXIS
gap
- the gappublic void layoutContainer(java.awt.Container container)
layoutContainer
in interface java.awt.LayoutManager
container
- the container to be laid outprotected boolean calculateComponentSizes(int availableSize, int startIndex, int endIndex)
public void addLayoutComponent(java.lang.String name, java.awt.Component component)
comp
to the layout,
associating it with the string specified by name
.addLayoutComponent
in interface java.awt.LayoutManager
name
- the string to be associated with the componentcomponent
- the component to be addedpublic java.awt.Dimension minimumLayoutSize(java.awt.Container container)
minimumLayoutSize
in interface java.awt.LayoutManager
public java.awt.Dimension preferredLayoutSize(java.awt.Container container)
preferredLayoutSize
in interface java.awt.LayoutManager
public void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
comp
- the component to be removedpublic void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
addLayoutComponent
in interface java.awt.LayoutManager2
comp
- the component to be addedconstraints
- where/how the component is added to the layout.public float getLayoutAlignmentX(java.awt.Container target)
getLayoutAlignmentX
in interface java.awt.LayoutManager2
public float getLayoutAlignmentY(java.awt.Container target)
getLayoutAlignmentY
in interface java.awt.LayoutManager2
public void invalidateLayout(java.awt.Container c)
invalidateLayout
in interface java.awt.LayoutManager2
protected boolean componentCountChanged(java.awt.Container c)
public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
maximumLayoutSize
in interface java.awt.LayoutManager2
protected int getPreferredSizeOfComponent(java.awt.Component c)
c
- the componentprotected int getSizeOfComponent(java.awt.Component c)
c
- the componentprotected int getAvailableSize(java.awt.Dimension containerSize, java.awt.Insets insets)
containerSize
- the size of the containerinsets
- the insetsprotected int getInitialLocation(java.awt.Insets insets)
insets
- the insetsprotected void setComponentToSize(java.awt.Component c, int size, int location, java.awt.Insets insets, java.awt.Dimension containerSize)
c
- the componentsize
- the size of the componentlocation
- the location of the componentinsets
- the insets of the componentcontainerSize
- the size of the containerpublic java.util.Map<java.awt.Component,java.lang.Object> getConstraintMap()
protected static int resolveAxis(int axis, java.awt.ComponentOrientation o)
axis
- the axis to resolveo
- the ComponentOrientation to resolve againstpublic int getGap()
public void setGap(int gap)
gap
- the gapprotected java.awt.Dimension getPreferredSizeOf(java.awt.Component comp, int atIndex)
public boolean isResetWhenInvalidate()
invalidateLayout(java.awt.Container)
is called.public void setResetWhenInvalidate(boolean resetWhenInvalidate)
invalidateLayout(java.awt.Container)
is called.resetWhenInvalidate
- the flagpublic int getAxis()
public void setAxis(int axis)
axis
- the new axis.public boolean isAlwaysLayout()
public void setAlwaysLayout(boolean alwaysLayout)
alwaysLayout
- true to always layout components even there is no way to satisfy the minimum size
requirements from all FIXED components.