|
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.MatrixLayout
A layout scheme that arranges components into rows and columns that fit the bounds of the container's parent. Typically, the container's parent is a viewport.
The matrix layout divides the container into "screens," where a screen is the size of the container's parent. Within each screen, the layout places the child components in equal-sized grid cells. It uses as many screens as necessary, and leftover cells are empty.
To get the child components to fit within the screen, it 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
grid cell allotted to it. In this case, MatrixLayout uses
the horizontal and vertical alignments to position the component
within the cell.
Each screen has a left, right, top, and bottom margin, and each margin is the same across all screens. The gap between rows and columns is given by the vertical and horizontal spacing, respectively.
When the container needs to be scrolled, MatrixLayout suggests
scrolling so that the next screen is completely visible.
When calculating the preferred size, MatrixLayout uses the current
size of the container's parent. If the parent's size has not yet been set,
the layout prefers a size where each child component is its preferred size.
The following diagram illustrates the placement of child components and the screen's padding:

MatrixLayout takes the container's component orientation into accout.
The above diagram assumes a locale where the orientation is left-to-right
and horizontal.
FitAllLayout,
FitLayout,
ZoomLayout,
ScalingLayoutManager,
ScrollableLayoutManager| Constructor Summary | |
MatrixLayout(int numRows,
int numColumns)
Creates a MatrixLayout with the specified number of rows and columns
per viewable area. |
|
MatrixLayout(int numRows,
int numColumns,
int horizontalAlignment,
int verticalAlignment)
Creates a MatrixLayout with the specified number of rows and columns
per viewable area and with the specified alignments. |
|
MatrixLayout(int numRows,
int numColumns,
int horizontalSpacing,
int verticalSpacing,
int minLeftMargin,
int minRightMargin,
int minTopMargin,
int minBottomMargin)
Creates a MatrixLayout with the specified number of rows and columns
per viewable area and with the specified spacing. |
|
MatrixLayout(int numRows,
int numColumns,
int horizontalAlignment,
int verticalAlignment,
int horizontalSpacing,
int verticalSpacing,
int minLeftMargin,
int minRightMargin,
int minTopMargin,
int minBottomMargin)
Creates a MatrixLayout with the specified number of rows and columns
per viewable area, the specified alignments, and the specified 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 |
getColumnCount()
Returns the number of columns per visible area. |
java.awt.Dimension |
getPreferredScrollableViewportSize(java.awt.Container container)
Returns the specified container's preferred scrollable viewport size. |
int |
getRowCount()
Returns the number of rows per visible area. |
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 MatrixLayout(int numRows,
int numColumns)
throws java.lang.IllegalArgumentException
MatrixLayout with the specified number of rows and columns
per viewable area.
numRows - The number of rows of components per viewable areanumColumns - The number of columns of components per viewable area
java.lang.IllegalArgumentException - if numRows < 1 or numColumns < 1MatrixLayout(int,int,int,int,int,int,int,int,int,int)
public MatrixLayout(int numRows,
int numColumns,
int horizontalAlignment,
int verticalAlignment)
throws java.lang.IllegalArgumentException
MatrixLayout with the specified number of rows and columns
per viewable area and with the specified alignments.
numRows - The number of rows of components per viewable areanumColumns - The number of columns of components per viewable areahorizontalAlignment - 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 numRows < 1, numColumns < 1,
or one of the alignment parameters is unacceptableMatrixLayout(int,int,int,int,int,int,int,int,int,int)
public MatrixLayout(int numRows,
int numColumns,
int horizontalSpacing,
int verticalSpacing,
int minLeftMargin,
int minRightMargin,
int minTopMargin,
int minBottomMargin)
throws java.lang.IllegalArgumentException
MatrixLayout with the specified number of rows and columns
per viewable area and with the specified spacing.
numRows - The number of rows of components per viewable areanumColumns - The number of columns of components per viewable areahorizontalSpacing - Horizontal spacing between componentsverticalSpacing - Vertical spacing between componentsminLeftMargin - Minimum left marginminRightMargin - Minimum right marginminTopMargin - Minimum top marginminBottomMargin - Minimum bottom margin
java.lang.IllegalArgumentException - if numRows < 1, numColumns < 1,
or one of the spacing parameters is negativeMatrixLayout(int,int,int,int,int,int,int,int,int,int)
public MatrixLayout(int numRows,
int numColumns,
int horizontalAlignment,
int verticalAlignment,
int horizontalSpacing,
int verticalSpacing,
int minLeftMargin,
int minRightMargin,
int minTopMargin,
int minBottomMargin)
throws java.lang.IllegalArgumentException
MatrixLayout with the specified number of rows and columns
per viewable area, the specified alignments, and the specified spacing.
numRows - The number of rows of components per viewable areanumColumns - The number of columns of components per viewable areahorizontalAlignment - 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.horizontalSpacing - Horizontal spacing between componentsverticalSpacing - Vertical spacing between componentsminLeftMargin - Minimum left marginminRightMargin - Minimum right marginminTopMargin - Minimum top marginminBottomMargin - Minimum bottom margin
java.lang.IllegalArgumentException - if numRows < 1, numColumns < 1,
one of the alignment parameters is unacceptable,
or one of the spacing parameters is negative| Method Detail |
public void addLayoutComponent(java.lang.String name,
java.awt.Component component)
addLayoutComponent in interface java.awt.LayoutManagername - the string to be associated with the componentcomponent - the component to be addedpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the reference object with which to compare
true if this object is the same as objpublic int getColumnCount()
public java.awt.Dimension getPreferredScrollableViewportSize(java.awt.Container container)
ScrollableLayoutManagerjavax.swing.Scrollable#getPreferredScrollableViewportSize,
except the container is a parameter instead of the receiver.
getPreferredScrollableViewportSize in interface ScrollableLayoutManagercontainer - Container for which the preferred size is requested
containerpublic int hashCode()
hashCode in class java.lang.Objectpublic double preferredScale(java.awt.Container container)
ScalingLayoutManager
preferredScale in interface ScalingLayoutManagercontainer - container for which to calculate the scale
public int getRowCount()
public int getScrollableBlockIncrement(java.awt.Container container,
java.awt.Rectangle rectangle,
int orientation,
int direction)
ScrollableLayoutManagerjavax.swing.Scrollable#getScrollableBlockIncrement,
except the container is a parameter instead of the receiver.
getScrollableBlockIncrement in interface ScrollableLayoutManagercontainer - The container that is being scrolledrectangle - The view area visible within the viewportorientation - The axis of the scrolling--either
SwingConstants.VERTICAL or SwingConstants.HORIZONTALdirection - 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)
ScrollableLayoutManagertrue 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 ScrollableLayoutManagercontainer - 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)
ScrollableLayoutManagertrue 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 ScrollableLayoutManagercontainer - The container in question
true if a viewport should keep the
container's width the same width of the viewport
public int getScrollableUnitIncrement(java.awt.Container container,
java.awt.Rectangle rectangle,
int orientation,
int direction)
ScrollableLayoutManagerjavax.swing.Scrollable#getScrollableUnitIncrement,
except the container is a parameter instead of the receiver.
getScrollableUnitIncrement in interface ScrollableLayoutManagercontainer - The container that is being scrolledrectangle - The view area visible within the viewportorientation - The axis of the scrolling--either
SwingConstants.VERTICAL or SwingConstants.HORIZONTALdirection - 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.LayoutManagercontainer - the container to be laid outpublic java.awt.Dimension minimumLayoutSize(java.awt.Container container)
minimumLayoutSize in interface java.awt.LayoutManagercontainer - the container to be laid out
containerpublic java.awt.Dimension preferredLayoutSize(java.awt.Container container)
preferredLayoutSize in interface java.awt.LayoutManagercontainer - the container to be laid out
containerpublic void removeLayoutComponent(java.awt.Component component)
removeLayoutComponent in interface java.awt.LayoutManagercomponent - the component to be removedpublic double scaleComponents(java.awt.Container container)
ScalingLayoutManager
scaleComponents in interface ScalingLayoutManagercontainer - 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 | |||||||||