com.sas.visuals
Class RowLayout

com.sas.visuals.RowLayout
All Implemented Interfaces:
Alignment, Direction, Justification, Sizing, java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class RowLayout
implements java.awt.LayoutManager2, Direction, Sizing, Justification, java.io.Serializable

RowLayout is a class that implements the java.awt.LayoutManager2 interface to be able to layout components within a container in rows. It is mainly used in the TabBar to layout tabs.
The components are laid out in rows. The start index indicates which component is the first one displayed when rowStyle is SINGLEROW. All components before the start index are not displayed. Components can be added to different groups. When the rowStyle is MULTIROW, components from different groups are displayed on different rows. The rows are determined by the components that will fit on each row. One group can take up several rows, but no two groups will share the same row. The components can all be justified to the LEFT, RIGHT, CENTER or FULL( to take up the entire row ). They also can all be oriented to the TOP, BOTTOM, LEFT, or RIGHT.

See Also:
Serialized Form

Field Summary
static int BOTTOM
           
static int LEFT
           
static int MULTIROW
           
static int NONE
           
static int RIGHT
           
static int SINGLEROW
           
static int TOP
           
 
Fields inherited from interface com.sas.visuals.Direction
BOTTOM_TO_TOP, COLUMN_MAJOR, LEFT_TO_RIGHT, RB_KEY, RIGHT_TO_LEFT, ROW_MAJOR, TOP_TO_BOTTOM
 
Fields inherited from interface com.sas.visuals.Sizing
PROPORTIONAL, UNIFORM
 
Fields inherited from interface com.sas.visuals.Justification
FULL
 
Fields inherited from interface com.sas.visuals.Alignment
BEGIN, CENTER, END
 
Constructor Summary
RowLayout()
          Default constructor.
RowLayout(int sizing, int just, int orient, int fill, int style, int compSpacing, int rSpacing)
          Constructor that sets all properties of the RowLayout except the margins.
RowLayout(int sizing, int just, int orient, int fill, int style, int compSpacing, int rSpacing, int right, int left, int top, int bottom)
          Constructor that sets all properties of the RowLayout.
 
Method Summary
 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 group, java.awt.Component comp)
          Adds the specified component with the specified name to the layout.
 void decrementStartIndex()
          Decrement the startIndex to the next visible component.
 java.util.Vector getAllGroups()
          Get all components from every of the group.
 int getBottomMargin()
          Get the margin of the bottom of the container.
 java.awt.Dimension getComponentSize()
          Get the component size used when the sizing property is UNIFORM.
 int getEndIndex()
          Get the index of the last component showing.
 int getFillFrom()
          Get the direction to fill the rows from.
 java.util.Vector getGroup(int index)
          Get the components in the group at the specified index
 int getGroupCount()
          Get the number of groups.
 int getGroupIndex(java.awt.Component comp)
          Get the index of the group to which the component belongs.
 int getJustification()
          Get the justification of the components on the rows.
 float getLayoutAlignmentX(java.awt.Container parent)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container parent)
          Returns the alignment along the y axis.
 int getLeftMargin()
          Get the margin of the left of the container.
protected  java.awt.Dimension getMaximumSize()
          Get the maximum component size.
 int getOrientation()
          Get the orientation of the rows.
 int getRightMargin()
          Get the margin of the right of the container.
 int getRowCount(int grpIndex)
          Get the number of rows a group of components is displayed on.
 int getRowHeight()
          Get the height of the rows.
 int getRowIndex(int grpIndex, int tabIndex)
          Get the index of the row to which the specific component belongs.
 int getRowSpacing()
          Get the spacing between rows.
 java.util.Vector getRowStartPositions()
          Get the positions of each row start.
 int getRowStyle()
          Get the row style.
 int getSizing()
          Get the type of sizing for the components in this layout.
 int getSpacing()
          Get the pixel amount of spacing between components.
 int getStartIndex()
          Get the index of the first component showing.
 int getThresholdCount()
          Get the number of tabs used to calculate the preferredSize of the container.
 int getTopMargin()
          Get the margin of the top of the container.
 void incrementEndIndex()
           
 void incrementStartIndex()
          Increment the startIndex to the next visible component.
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 boolean isDecrementable()
          Get if the start index can be decremented.
 boolean isIncrementable()
          Get if the start index can be incremented.
 void layoutContainer(java.awt.Container parent)
          Layout the components in the specified container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum dimensions for this layout given the components in the specified target container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Returns the minimum dimensions needed to layout the components contained in the specified panel.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Returns the preferred dimensions for this layout given the components in the specified panel.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void reorderComponents(java.awt.Container parent)
          Reorder the components to be laid out according to their order in the parent Container.
 void setBottomMargin(int margin)
          Set the bottom margin.
 java.awt.Dimension setComponentSize(java.awt.Dimension newSize)
          Set the component size used when the sizing property is set to UNIFORM.
 void setFillFrom(int fill)
          Set the direction to fill the rows from.
 void setFirstGroup(int index)
          Set the first group.
 void setFirstRow(int index)
          Set the first row within the first group.
 void setJustification(int just)
          Set the justification of the components on the rows.
 void setLeftMargin(int margin)
          Set the left margin.
 void setOrientation(int orient)
          Set the orientation of the rows.
 void setRightMargin(int margin)
          Set the right margin.
 void setRowSpacing(int gap)
          Set the spacing between the rows.
 void setRowStyle(int style)
          Set the row style used.
 void setSizing(int sizing)
          Set the sizing property used to size the components.
 void setSpacing(int gap)
          Set the pixel amount of spacing between the components.
 void setStartIndex(int index)
          Set the start index.
 void setThresholdCount(int number)
          Set the number of tabs used to calculate the preferredSize of the container.
 void setTopMargin(int margin)
          Set the top margin.
 java.lang.String toString()
          Returns the String representation of this RowColumnLayout's values.
 

Field Detail

NONE

public static final int NONE
See Also:
Constant Field Values

TOP

public static final int TOP
See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

SINGLEROW

public static final int SINGLEROW
See Also:
Constant Field Values

MULTIROW

public static final int MULTIROW
See Also:
Constant Field Values
Constructor Detail

RowLayout

public RowLayout()
Default constructor.


RowLayout

public RowLayout(int sizing,
                 int just,
                 int orient,
                 int fill,
                 int style,
                 int compSpacing,
                 int rSpacing)
Constructor that sets all properties of the RowLayout except the margins.

Parameters:
sizing - the sizing property
just - the justification property
orient - the orientation property
fill - the fillFrom direction property
style - the style property: multi-row or single row
compSpacing - the spacing between the components
rSpacing - the spacing between the rows

RowLayout

public RowLayout(int sizing,
                 int just,
                 int orient,
                 int fill,
                 int style,
                 int compSpacing,
                 int rSpacing,
                 int right,
                 int left,
                 int top,
                 int bottom)
Constructor that sets all properties of the RowLayout.

Parameters:
sizing - the sizing property
just - the justification property
orient - the orientation property
fill - the fillFrom direction property
style - the style property: multi-row or single row
compSpacing - the spacing between the components
rSpacing - the spacing between the rows
right - the rightMargin
left - the leftMargin
top - the topMargin
bottom - the bottomMargin
Method Detail

getStartIndex

public int getStartIndex()
Get the index of the first component showing.

Returns:
the index of the first component to display.
See Also:
setStartIndex(int)

getEndIndex

public int getEndIndex()
Get the index of the last component showing.

Returns:
the index of the last component displayed

getComponentSize

public java.awt.Dimension getComponentSize()
Get the component size used when the sizing property is UNIFORM.

Returns:
the UNIFORM component size
See Also:
setComponentSize(java.awt.Dimension)

getMaximumSize

protected java.awt.Dimension getMaximumSize()
Get the maximum component size.

Returns:
the maximum component size or the componentSize property value if sizing is UNIFORM

getFillFrom

public int getFillFrom()
Get the direction to fill the rows from.

Returns:
a direction value from com.sas.visuals.Direction
See Also:
Direction, setFillFrom(int)

getJustification

public int getJustification()
Get the justification of the components on the rows.

Returns:
a justification value from com.sas.visuals.Justification
See Also:
Justification, setJustification(int)

getBottomMargin

public int getBottomMargin()
Get the margin of the bottom of the container.

Returns:
the pixel amount of the bottom margin
See Also:
setBottomMargin(int)

getLeftMargin

public int getLeftMargin()
Get the margin of the left of the container.

Returns:
the pixel amount of the left margin
See Also:
setLeftMargin(int)

getRightMargin

public int getRightMargin()
Get the margin of the right of the container.

Returns:
the pixel amount of the right margin
See Also:
setRightMargin(int)

getTopMargin

public int getTopMargin()
Get the margin of the top of the container.

Returns:
the pixel amount of the top margin
See Also:
setTopMargin(int)

getOrientation

public int getOrientation()
Get the orientation of the rows.

Returns:
an orientation value: TOP, BOTTOM, LEFT, or RIGHT
See Also:
setOrientation(int)

getGroupIndex

public int getGroupIndex(java.awt.Component comp)
Get the index of the group to which the component belongs.

Parameters:
comp - the component to find the index of
Returns:
the index of the component's group

getRowIndex

public int getRowIndex(int grpIndex,
                       int tabIndex)
Get the index of the row to which the specific component belongs.

Parameters:
grpIndex - the group index of the specified component
tabIndex - the overall index of the specified component
Returns:
the index of the component's row or -1 if component exists at the specified indexes

getGroup

public java.util.Vector getGroup(int index)
Get the components in the group at the specified index

Parameters:
index - index of the group to get the components from.
Returns:
the components in the group at index

getGroupCount

public int getGroupCount()
Get the number of groups.

Returns:
the number of groups

getAllGroups

public java.util.Vector getAllGroups()
Get all components from every of the group.

Returns:
all of the components every group

getRowCount

public int getRowCount(int grpIndex)
Get the number of rows a group of components is displayed on.

Parameters:
grpIndex - the index of the specified group
Returns:
the number of rows the specified group is displayed on.

getRowHeight

public int getRowHeight()
Get the height of the rows.

Returns:
the row height.

getRowSpacing

public int getRowSpacing()
Get the spacing between rows.

Returns:
the row spacing
See Also:
setRowSpacing(int)

getRowStartPositions

public java.util.Vector getRowStartPositions()
Get the positions of each row start.

Returns:
a Vector of row start java.awt.Points

getRowStyle

public int getRowStyle()
Get the row style.

Returns:
a row style of: MULTIROW(1) or SINGLEROW(0)
See Also:
setRowStyle(int)

getSizing

public int getSizing()
Get the type of sizing for the components in this layout.

Returns:
the sizing: PROPORTIONAL or UNIFORM
See Also:
setSizing(int)

getSpacing

public int getSpacing()
Get the pixel amount of spacing between components.

Returns:
pixel spacing amount
See Also:
setSpacing(int)

setComponentSize

public java.awt.Dimension setComponentSize(java.awt.Dimension newSize)
Set the component size used when the sizing property is set to UNIFORM.

Parameters:
newSize - the new component size when UNIFORM sizing
Returns:
the new UNIFORM component size
See Also:
getComponentSize()

setFillFrom

public void setFillFrom(int fill)
Set the direction to fill the rows from.

Parameters:
fill - a Direction to fill the rows from.
See Also:
getFillFrom(), Direction

setTopMargin

public void setTopMargin(int margin)
Set the top margin.

See Also:
getTopMargin()

setBottomMargin

public void setBottomMargin(int margin)
Set the bottom margin.

See Also:
getBottomMargin()

setRightMargin

public void setRightMargin(int margin)
Set the right margin.

See Also:
getRightMargin()

setLeftMargin

public void setLeftMargin(int margin)
Set the left margin.

See Also:
getLeftMargin()

setJustification

public void setJustification(int just)
Set the justification of the components on the rows.

Parameters:
just - the justification layout the components with
See Also:
getJustification()

setOrientation

public void setOrientation(int orient)
Set the orientation of the rows.

Parameters:
orient - the orientation: TOP, BOTTOM, LEFT, or RIGHT
See Also:
getOrientation()

setRowStyle

public void setRowStyle(int style)
Set the row style used.

Parameters:
style - the row style: MULTIROW(1) or SINGLEROW(0)
See Also:
getRowStyle()

setRowSpacing

public void setRowSpacing(int gap)
Set the spacing between the rows.

Parameters:
the - pixel spacing between the rows
See Also:
getRowSpacing()

setFirstGroup

public void setFirstGroup(int index)
Set the first group. The first group is laid out closest to the edge opposite the orientation. Example: if TOP orientation, then the first group is laid out closest to the bottom edge of the container.

Parameters:
index - the index of first group.

setFirstRow

public void setFirstRow(int index)
Set the first row within the first group. The first row is laid out closest to the edge opposite the orientation. Example: if TOP orientation, then the first row is laid out closest to the bottom edge of the container.

Parameters:
index - the index of the group to layout first.

setSizing

public void setSizing(int sizing)
Set the sizing property used to size the components.

Parameters:
sizing - either PROPORTIONAL or UNIFORM sizing
See Also:
getSizing()

setSpacing

public void setSpacing(int gap)
Set the pixel amount of spacing between the components.

Parameters:
gap - the pixel spacing amount
See Also:
getSpacing()

isDecrementable

public boolean isDecrementable()
Get if the start index can be decremented.

Returns:
true if there are visible components before the startIndex; false otherwise.
See Also:
isIncrementable(), decrementStartIndex()

isIncrementable

public boolean isIncrementable()
Get if the start index can be incremented.

Returns:
true if there are visible components after the startIndex; false otherwise.
See Also:
isDecrementable(), incrementStartIndex()

incrementStartIndex

public void incrementStartIndex()
Increment the startIndex to the next visible component.


incrementEndIndex

public void incrementEndIndex()

decrementStartIndex

public void decrementStartIndex()
Decrement the startIndex to the next visible component.


setStartIndex

public void setStartIndex(int index)
Set the start index.


reorderComponents

public void reorderComponents(java.awt.Container parent)
Reorder the components to be laid out according to their order in the parent Container.


addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - where/how the component is added to the layout.

addLayoutComponent

public void addLayoutComponent(java.lang.String group,
                               java.awt.Component comp)
Adds the specified component with the specified name to the layout.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the String of the index of the component
comp - the component to be added

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout. Does not apply.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to be removed

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum dimensions for this layout given the components in the specified target container.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
Parameters:
target - the component which needs to be laid out
See Also:
Container, minimumLayoutSize(java.awt.Container), preferredLayoutSize(java.awt.Container)

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container parent)
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.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container parent)
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.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2

getThresholdCount

public int getThresholdCount()
Get the number of tabs used to calculate the preferredSize of the container.

Returns:
the number of tabs used from the 1st group to calculate the preferredSize of the container

setThresholdCount

public void setThresholdCount(int number)
Set the number of tabs used to calculate the preferredSize of the container.

Parameters:
number - the number of tabs used from the 1st group to calculate the preferredSize of the container

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Returns the preferred dimensions for this layout given the components in the specified panel.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component which needs to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Returns the minimum dimensions needed to layout the components contained in the specified panel.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component which needs to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(java.awt.Container parent)
Layout the components in the specified container.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the specified component being laid out
See Also:
Container

toString

public java.lang.String toString()
Returns the String representation of this RowColumnLayout's values.

Overrides:
toString in class java.lang.Object



Copyright © 2009 SAS Institute Inc. All Rights Reserved.