public class ColumnLayout extends Object implements Serializable
ColumnLayout is the model used to support any 1 to n
column-based layout. ColumnLayout is constrained by a number
columns that will not be exceeded, even if a fragment specifies a column
outside of this constraint. Any fragment exceeded the specified column
constraint will be deposited into the right-most column.
null.When any move*() method is invoked and a portlet is actually moved (see individual methods for what causes these circumstances), an initial LayoutEvent is dispatched. This may cause a cascade of LayoutEvents to be fired in turn if the movement of the target fragment cause other fragments to be repositioned. In this case a LayoutEvent is dispatched for each portlet moved, which in turn may our may not cause another LayoutEvent to be fired.
LayoutEvent,
LayoutEventListener,
LayoutCoordinate,
Fragment,
Serialized Form| Constructor and Description |
|---|
ColumnLayout(int numberOfColumns,
String layoutType,
Collection<ContentFragment> fragments,
String[] columnWidths) |
ColumnLayout(int numberOfColumns,
String layoutType,
Collection<ContentFragment> fragments,
String[] columnWidths,
ContentFragment maximized)
Same as ColumnLayout(int numberOfColumns, String layoutType) but also
supplies a Collection of fragments to initially populate the layout
with.
|
ColumnLayout(int numberOfColumns,
String layoutType,
String[] columnWidths) |
| Modifier and Type | Method and Description |
|---|---|
void |
addFragment(ContentFragment fragment)
Adds a fragment to the layout using fragment properties of
row and column as hints on where to put
this fragment. |
void |
addLayoutEventListener(LayoutEventListener eventListener)
Adds a LayoutEventListener to this layout that will be fired any time
a LayoutEvent is dispatched.
|
void |
buildDetachedPortletList(Collection<ContentFragment> fragments) |
protected void |
doAdd(int columnNumber,
int rowNumber,
ContentFragment fragment)
Adds a fragment at the indicated
columnNumber
and rowNumber. |
protected void |
doMove(ContentFragment fragment,
LayoutCoordinate oldCoordinate,
LayoutCoordinate newCoordinate)
Performs the actual movement of a fragment.
|
protected int |
getColumn(ContentFragment fragment)
Gets the row number of this fragment to looking the
layoutType
property column. |
Collection<ContentFragment> |
getColumn(int columnNumber) |
String |
getColumnFloat(int columnNumber)
returns the float to be used with the specified column.
|
protected SortedMap<Integer,ContentFragment> |
getColumnMap(int columnNumber)
Retrieves this specified
columnNumber as a
SortedMap. |
Collection<Collection<ContentFragment>> |
getColumns() |
String |
getColumnWidth(int columnNumber)
returns the width to be used with the specified column.
|
LayoutCoordinate |
getCoordinate(ContentFragment fragment) |
List<ContentFragment> |
getDetachedPortlets() |
Collection<ContentFragment> |
getFirstColumn() |
ContentFragment |
getFragmentAt(int columnNumber,
int rowNumber)
Retrieves the fragment at the specified loaction.
|
ContentFragment |
getFragmentAt(LayoutCoordinate coodinate)
Retrieves the fragment at the specified loaction.
|
Collection<ContentFragment> |
getFragments()
Returns an immutable Collection of all the Fragments contained within
this ColumnLayout in no sepcific order.
|
Collection<ContentFragment> |
getLastColumn() |
int |
getLastRowNumber(int columnNumber)
Returns the index of the last row in the specified column.
|
int |
getNumberOfColumns() |
protected int |
getRow(int currentColumn,
ContentFragment fragment)
Gets the row number of this fragment to looking the
layoutType
property row. |
void |
moveDown(ContentFragment fragment) |
void |
moveLeft(ContentFragment fragment)
Moves a fragment one column to the left.
|
void |
moveRight(ContentFragment fragment)
Moves a fragment one column to the right.
|
void |
moveUp(ContentFragment fragment)
Moves a fragment one row to the up.
|
protected void |
processEvent(LayoutEvent event)
Dispatches a LayoutEvent to all LayoutEventListeners registered to this layout.
|
public ColumnLayout(int numberOfColumns,
String layoutType,
String[] columnWidths)
numberOfColumns - the maximum number of columns this layout will have.layoutType - this value corresponds to the property settings of the
fragments within your psml. Layout type allows segregation of
property settings based on the type of layout in use. This
effectively allows for the interchange of multiple layout
formats without one format effecting the settings of another.columnWidths - widths for each column that accumulate to 100% if percentages
are used.Fragment.getType()public ColumnLayout(int numberOfColumns,
String layoutType,
Collection<ContentFragment> fragments,
String[] columnWidths,
ContentFragment maximized)
throws LayoutEventException
numberOfColumns - the maximum number of columns this layout will have.layoutType - this value corresponds to the property settings of the
fragments within your psml. Layout type allows segregation of
property settings based on the type of layout in use. This
effectively allows for the interchange of multiple layout
formats without one format effecting the settings of another.fragments - Initial set of fragments to add to this layout.columnWidths - widths for each column that accumulate to 100% if percentages
are used.LayoutEventExceptionColumnLayout(int numberOfColumns, String layoutType)public ColumnLayout(int numberOfColumns,
String layoutType,
Collection<ContentFragment> fragments,
String[] columnWidths)
throws LayoutEventException
LayoutEventExceptionpublic void addFragment(ContentFragment fragment) throws LayoutEventException
Adds a fragment to the layout using fragment properties of
row and column as hints on where to put
this fragment. The following rules apply to malformed fragment
definitions:
fragment - Fragment to add to this layout.LayoutEventExceptionFragmentpublic void addLayoutEventListener(LayoutEventListener eventListener)
eventListener - LayoutEventListener,
LayoutEventListenerpublic Collection<ContentFragment> getColumn(int columnNumber) throws InvalidLayoutLocationException
columnNumber - Number of column to retreivenull.InvalidLayoutLocationException - if the column is outisde of the constraints of this layoutpublic String getColumnWidth(int columnNumber)
columnNumber - whose width has been requested.public String getColumnFloat(int columnNumber)
columnNumber - whose width has been requested.public Collection<Collection<ContentFragment>> getColumns()
java.util.Collection all of columns (also
Collection objects) in order within this layout. All Collections
are immutable.public int getLastRowNumber(int columnNumber)
columnNumber - column form whom we ant to identify the
last row.public Collection<ContentFragment> getFragments()
public ContentFragment getFragmentAt(int columnNumber, int rowNumber) throws EmptyLayoutLocationException, InvalidLayoutLocationException
columnNumber - Column coordinate (first column starts at 0)rowNumber - Row coordinate (first row starts at 0)null.EmptyLayoutLocationException - if there is no fragment currently located at the specified coordinate.InvalidLayoutLocationException - if the coordinate lies outside the confines of this layout, i.e., the
columnNumber exceeds the max columns setting for this layout.public ContentFragment getFragmentAt(LayoutCoordinate coodinate) throws EmptyLayoutLocationException, InvalidLayoutLocationException
coodinate - LayoutCoordinate object that will be used to located a fragment in this
layout.null.EmptyLayoutLocationException - if there is no fragment currently located at the specified coordinate.InvalidLayoutLocationException - if the coordinate lies outside the confines of this layout, i.e., the
columnNumber exceeds the max columns setting for this layout.LayoutCoordinate,
LayoutCoordinatepublic int getNumberOfColumns()
public Collection<ContentFragment> getLastColumn()
public Collection<ContentFragment> getFirstColumn()
public void moveRight(ContentFragment fragment) throws FragmentNotInLayoutException, LayoutEventException
If the fragment currently resides in right-most column, no action is taking and no event LayoutEvent is fired.
fragment - fragment to move.FragmentNotInLayoutException - if the specified fragment is not currently in the layout.LayoutEventException - If a triggered LayoutEvent fails.public void moveLeft(ContentFragment fragment) throws FragmentNotInLayoutException, LayoutEventException
If the fragment currently resides in left-most column, no action is taking and no event LayoutEvent is fired.
fragment - FragmentNotInLayoutException - if the specified fragment is not currently in the layout.LayoutEventException - If a triggered LayoutEvent fails.public void moveUp(ContentFragment fragment) throws FragmentNotInLayoutException, LayoutEventException
If the fragment currently resides in top-most row, no action is taking and no event LayoutEvent is fired.
fragment - FragmentNotInLayoutException - if the specified fragment is not currently in the layout.LayoutEventException - If a triggered LayoutEvent fails.public void moveDown(ContentFragment fragment) throws FragmentNotInLayoutException, LayoutEventException
fragment - FragmentNotInLayoutException - if the specified fragment is not currently in the layout.LayoutEventException - If a triggered LayoutEvent fails.protected void doMove(ContentFragment fragment, LayoutCoordinate oldCoordinate, LayoutCoordinate newCoordinate) throws InvalidLayoutLocationException, LayoutEventException
fragment - oldCoordinate - newCoordinate - InvalidLayoutLocationExceptionLayoutEventExceptionpublic LayoutCoordinate getCoordinate(ContentFragment fragment) throws FragmentNotInLayoutException
fragment - fragment whose LayoutCoordinate we ant.FragmentNotInLayoutException - if the Fragment is not present in this layout.LayoutCoordinateprotected void doAdd(int columnNumber,
int rowNumber,
ContentFragment fragment)
throws InvalidLayoutLocationException,
LayoutEventException
columnNumber
and rowNumber.columnNumber - rowNumber - fragment - InvalidLayoutLocationException - if the coordinates are outside the bounds of this layout.LayoutEventException - id a LayoutEvent failsprotected final SortedMap<Integer,ContentFragment> getColumnMap(int columnNumber) throws InvalidLayoutLocationException
columnNumber as a
SortedMap.columnNumber - InvalidLayoutLocationException - if the columnNumber resides
outside the bounds of this layout.protected final int getRow(int currentColumn,
ContentFragment fragment)
layoutType
property row. If this property is undefined, the bottom-most row
number of currentColumn is returned.currentColumn - fragment - protected final int getColumn(ContentFragment fragment)
layoutType
property column.
If the column is undefined or exceeds the constriants of this
layout, the value returned is numberOfColumns - 1. If the
value is less than 0, 0 is returned.fragment - protected final void processEvent(LayoutEvent event) throws LayoutEventException
event - LayoutEventException - if an error occurs while processing a the LayoutEvent.public List<ContentFragment> getDetachedPortlets()
public void buildDetachedPortletList(Collection<ContentFragment> fragments)
Copyright © 1999–2015 The Apache Software Foundation. All rights reserved.