|
Side of Software Print Preview Library 1.8.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sos.preview.FitLayout
A layout scheme that scales all components such that one dimension of the largest component fits in container's parent. The dimension is specified in the constructor and must be one of the following:
BoxLayout.X_AXIS | Conponent are laid out horizontally. |
BoxLayout.Y_AXIS | Conponent are laid out vertically. |
BoxLayout.PAGE_AXIS | Conponent are laid out horizontally if the component orientation is not horizontal and vertically otherwise. |
BoxLayout.LINE_AXIS | Conponent are laid out horizontally if the component orientation is horizontal and vertically otherwise. |
To get the child components to fit the given dimension, the layout may have to scale
them. It scales each child component the same amount. If a child
component has a smaller preferred size, it will not fill the
space allotted to it. In this case, FitLayout
uses
the horizontal and vertical alignments to position the component
within the cell.
The layout honors suggested left, right, top, and bottom margins as well as the spacing between child components. The spacing only applies for the axis being laid out.
The following diagram illustrates the placement of child components along the Y_AXIS and the container's padding:
FitAllLayout
,
MatrixLayout
,
ZoomLayout
,
ScalingLayoutManager
,
ScrollableLayoutManager
Constructor Summary | |
FitLayout(int axis)
Creates a FitLayout along the specified axis and
with default alignments and spacing. |
|
FitLayout(int axis,
int horizontalAlignment,
int verticalAlignment)
Creates a FitLayout along the specified axis, with the specified
alignments, and with default spacing. |
|
FitLayout(int axis,
int spacing,
int leftMargin,
int rightMargin,
int topMargin,
int bottomMargin)
Creates a FitLayout along the specified axis, with the specified
spacing, and with default alignments. |
|
FitLayout(int axis,
int horizontalAlignment,
int verticalAlignment,
int spacing,
int leftMargin,
int rightMargin,
int topMargin,
int bottomMargin)
Creates a FitLayout along the specified axis and with
the specified alignments and spacing. |
Method Summary | |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component component)
If the layout manager uses a per-component string, adds the specified component to the layout, associating it with the specified name. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. |
int |
getAxis()
Returns the axis that this layout fits in the container. |
java.awt.Dimension |
getPreferredScrollableViewportSize(java.awt.Container container)
Returns the specified container's preferred scrollable viewport size. |
int |
getScrollableBlockIncrement(java.awt.Container container,
java.awt.Rectangle rectangle,
int orientation,
int direction)
Returns the specified container's scrollable block increment. |
boolean |
getScrollableTracksViewportHeight(java.awt.Container container)
Returns true if a viewport should always force the height of the
specified container to match the height of the viewport. |
boolean |
getScrollableTracksViewportWidth(java.awt.Container container)
Returns true if a viewport should always force the width of the
specified container to match the width of the viewport. |
int |
getScrollableUnitIncrement(java.awt.Container container,
java.awt.Rectangle rectangle,
int orientation,
int direction)
Returns the specified container's scrollable unit increment. |
int |
hashCode()
Returns a hash code value for the object. |
void |
layoutContainer(java.awt.Container container)
Lays out the specified container. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container container)
Calculates the minimum size dimensions for the specified container, given the components it contains. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container container)
Calculates the preferred size dimensions for the specified container, given the components it contains. |
double |
preferredScale(java.awt.Container container)
Returns the scale of the specified container's components if the container were to get its preferred size. |
void |
removeLayoutComponent(java.awt.Component component)
Removes the specified component from the layout. |
double |
scaleComponents(java.awt.Container container)
Lays out the container's components and returns the scale factor. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FitLayout(int axis) throws java.lang.IllegalArgumentException
FitLayout
along the specified axis and
with default alignments and spacing.
axis
- The axis to make fit in the container. Acceptable values are
BoxLayout.X_AXIS
, BoxLayout.Y_AXIS
,
BoxLayout.PAGE_AXIS
, and BoxLayout.LINE_AXIS
.
java.lang.IllegalArgumentException
- if axis
is not an acceptable SwingConstant
FitLayout(int,int,int,int,int,int,int,int)
public FitLayout(int axis, int horizontalAlignment, int verticalAlignment) throws java.lang.IllegalArgumentException
FitLayout
along the specified axis, with the specified
alignments, and with default spacing.
axis
- The axis to make fit in the container. Acceptable values are
BoxLayout.X_AXIS
, BoxLayout.Y_AXIS
,
BoxLayout.PAGE_AXIS
, and BoxLayout.LINE_AXIS
.horizontalAlignment
- Horizontal alignment of components that are
not as wide as the widest component in the container. Acceptable values
are SwingConstants.CENTER, SwingConstants.LEFT, SwingConstants.RIGHT,
SwingConstants.LEADING, and SwingConstants.TRAILING.verticalAlignment
- Vertical alignment of components that are
not as tall as the tallest component in the container. Acceptable values
are SwingConstants.CENTER, SwingConstants.TOP, and SwingConstants.BOTTOM.
java.lang.IllegalArgumentException
- if axis
,
horizontalAlignment
, or verticalAlignment
is not an acceptable SwingConstant
FitLayout(int,int,int,int,int,int,int,int)
public FitLayout(int axis, int spacing, int leftMargin, int rightMargin, int topMargin, int bottomMargin) throws java.lang.IllegalArgumentException
FitLayout
along the specified axis, with the specified
spacing, and with default alignments.
axis
- The axis to make fit in the container. Acceptable values are
BoxLayout.X_AXIS
, BoxLayout.Y_AXIS
,
BoxLayout.PAGE_AXIS
, and BoxLayout.LINE_AXIS
.spacing
- Spacing between componentsleftMargin
- the left marginrightMargin
- the right margintopMargin
- the top marginbottomMargin
- the bottom margin
java.lang.IllegalArgumentException
- if axis
is not an acceptable SwingConstant
; or if one of the spacing
parameters is negativeFitLayout(int,int,int,int,int,int,int,int)
public FitLayout(int axis, int horizontalAlignment, int verticalAlignment, int spacing, int leftMargin, int rightMargin, int topMargin, int bottomMargin) throws java.lang.IllegalArgumentException
FitLayout
along the specified axis and with
the specified alignments and spacing.
axis
- The axis to make fit in the container. Acceptable values are
BoxLayout.X_AXIS
, BoxLayout.Y_AXIS
,
BoxLayout.PAGE_AXIS
, and BoxLayout.LINE_AXIS
.horizontalAlignment
- Horizontal alignment of components that are
not as wide as the widest component in the container. Acceptable values
are SwingConstants.CENTER, SwingConstants.LEFT, SwingConstants.RIGHT,
SwingConstants.LEADING, and SwingConstants.TRAILING.verticalAlignment
- Vertical alignment of components that are
not as tall as the tallest component in the container. Acceptable values
are SwingConstants.CENTER, SwingConstants.TOP, and SwingConstants.BOTTOM.spacing
- Spacing between componentsleftMargin
- the left marginrightMargin
- the right margintopMargin
- the top marginbottomMargin
- the bottom margin
java.lang.IllegalArgumentException
- if axis
,
horizontalAlignment
, or verticalAlignment
is not an acceptable SwingConstant
; or if one of the spacing
parameters is negativeMethod Detail |
public void addLayoutComponent(java.lang.String name, java.awt.Component component)
addLayoutComponent
in interface java.awt.LayoutManager
name
- the string to be associated with the componentcomponent
- the component to be addedpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the reference object with which to compare
true
if this object is the same as obj
public int getAxis()
public java.awt.Dimension getPreferredScrollableViewportSize(java.awt.Container container)
ScrollableLayoutManager
javax.swing.Scrollable#getPreferredScrollableViewportSize
,
except the container is a parameter instead of the receiver.
getPreferredScrollableViewportSize
in interface ScrollableLayoutManager
container
- Container for which the preferred size is requested
container
public int hashCode()
hashCode
in class java.lang.Object
public double preferredScale(java.awt.Container container)
ScalingLayoutManager
preferredScale
in interface ScalingLayoutManager
container
- container for which to calculate the scale
public int getScrollableBlockIncrement(java.awt.Container container, java.awt.Rectangle rectangle, int orientation, int direction)
ScrollableLayoutManager
javax.swing.Scrollable#getScrollableBlockIncrement
,
except the container is a parameter instead of the receiver.
getScrollableBlockIncrement
in interface ScrollableLayoutManager
container
- The container that is being scrolledrectangle
- The view area visible within the viewportorientation
- The axis of the scrolling--either
SwingConstants.VERTICAL
or SwingConstants.HORIZONTAL
direction
- A negative number to indicate scrolling left or up, or
a positive number to indicate scrolling right or down
public boolean getScrollableTracksViewportHeight(java.awt.Container container)
ScrollableLayoutManager
true
if a viewport should always force the height of the
specified container to match the height of the viewport.
The semantics are the same as
javax.swing.Scrollable#getScrollableTracksViewportHeight
,
except the container is a parameter instead of the receiver.
getScrollableTracksViewportHeight
in interface ScrollableLayoutManager
container
- The container in question
true
if a viewport should keep the
container
's height the same height of the viewportpublic boolean getScrollableTracksViewportWidth(java.awt.Container container)
ScrollableLayoutManager
true
if a viewport should always force the width of the
specified container to match the width of the viewport.
The semantics are the same as
javax.swing.Scrollable#getScrollableTracksViewportWidth
,
except the container is a parameter instead of the receiver.
getScrollableTracksViewportWidth
in interface ScrollableLayoutManager
container
- The container in question
true
if a viewport should keep the
container
's width the same width of the viewportpublic int getScrollableUnitIncrement(java.awt.Container container, java.awt.Rectangle rectangle, int orientation, int direction)
ScrollableLayoutManager
javax.swing.Scrollable#getScrollableUnitIncrement
,
except the container is a parameter instead of the receiver.
getScrollableUnitIncrement
in interface ScrollableLayoutManager
container
- The container that is being scrolledrectangle
- The view area visible within the viewportorientation
- The axis of the scrolling--either
SwingConstants.VERTICAL
or SwingConstants.HORIZONTAL
direction
- A negative number to indicate scrolling left or up, or
a positive number to indicate scrolling right or down
public void layoutContainer(java.awt.Container container)
layoutContainer
in interface java.awt.LayoutManager
container
- the container to be laid outpublic java.awt.Dimension minimumLayoutSize(java.awt.Container container)
minimumLayoutSize
in interface java.awt.LayoutManager
container
- the container to be laid out
container
public java.awt.Dimension preferredLayoutSize(java.awt.Container container)
preferredLayoutSize
in interface java.awt.LayoutManager
container
- the container to be laid out
container
public void removeLayoutComponent(java.awt.Component component)
removeLayoutComponent
in interface java.awt.LayoutManager
component
- the component to be removedpublic double scaleComponents(java.awt.Container container)
ScalingLayoutManager
scaleComponents
in interface ScalingLayoutManager
container
- container for which to lay out its children
|
Side of Software Print Preview Library 1.8.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |