com.miginfocom.calendar.grid
Class GridSegmentSpec

java.lang.Object
  extended by com.miginfocom.calendar.grid.GridSegmentSpec
All Implemented Interfaces:
java.io.Serializable

public class GridSegmentSpec
extends java.lang.Object
implements java.io.Serializable

Holds the segments in one dimension that a grid consists of.

See Also:
GridSegment, Serialized Form

Constructor Summary
GridSegmentSpec(GridSegment segment)
          Constructor for a single segment that will make out the whole spec.
GridSegmentSpec(GridSegment[] segments, int cellCount)
          Constructor
GridSegmentSpec(int cellCount)
          Shortcut costructor that creates one segment with no size restrictions
GridSegmentSpec(int cellCount, AtRefNumber prefSize)
          Shortcut costructor that creates one segment with no size restrictions
 
Method Summary
 int getCellCount()
          Returns the number of cells in all segments added together
 int getFirstCellIndex(GridSegment segment)
          Returns the cell index for the first cell in the segment
 java.lang.Integer getMaxSize()
          Returns the maximum size.
 int getMinSize()
          Returns the minimum size.
 java.lang.Integer getPreferredSize()
          Returns the preferred size.
 GridSegment getSegmentForCell(int cell)
          Returns the segment (subgrid) that contains a cell.
 int getSegmentIndexForCell(int cell)
          Returns the segment index (subgrid) that contains a cell.
 GridSegment[] getSegments()
          Return the contained segments.
 AtRefNumber[][] getSizes()
          Returns the size constraints for every segment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridSegmentSpec

public GridSegmentSpec(int cellCount)
Shortcut costructor that creates one segment with no size restrictions

Parameters:
cellCount - The number of cells

GridSegmentSpec

public GridSegmentSpec(int cellCount,
                       AtRefNumber prefSize)
Shortcut costructor that creates one segment with no size restrictions

Parameters:
cellCount - The number of cells
prefSize - The preferred size that all rows will get. No min/max.

GridSegmentSpec

public GridSegmentSpec(GridSegment segment)
Constructor for a single segment that will make out the whole spec.

Parameters:
segment - The segment that make out this size specification.

GridSegmentSpec

public GridSegmentSpec(GridSegment[] segments,
                       int cellCount)
Constructor

Parameters:
segments - The segments that make out this size specification. Can be null or have length > 0 and elements can be null in which case they are just ignored.
cellCount - The number of cells. If it differs from the sum of the cell counts for the segments, extra segments will be added or removed. The last segment's grid count may be adjusted to add up to cellCount.
Method Detail

getCellCount

public int getCellCount()
Returns the number of cells in all segments added together

Returns:
The number of cells in all segments added together

getMinSize

public int getMinSize()
Returns the minimum size.

Returns:
The minimum size.

getPreferredSize

public java.lang.Integer getPreferredSize()
Returns the preferred size. If any segment has a relative value or no preferred size null will be returned.

Returns:
The preferred size or null if no value could be determined.

getMaxSize

public java.lang.Integer getMaxSize()
Returns the maximum size. If no max is set for at least one GridSegment MigUtil.BIG_INT is returned.

Returns:
The maximum size.

getSegments

public GridSegment[] getSegments()
Return the contained segments.

Returns:
The contained segments. Never null and always > 0.

getSegmentIndexForCell

public int getSegmentIndexForCell(int cell)
Returns the segment index (subgrid) that contains a cell. The method is lenient and returns the first or last segment index if cell is < 0 or >= cellCount, respectively.

Returns:
The segment index (subgrid) that contains a cell. Never out of bounds.

getSegmentForCell

public GridSegment getSegmentForCell(int cell)
Returns the segment (subgrid) that contains a cell. The method is lenient and returns the first or last segment if cell is < 0 or >= cellCount, respectively.

Returns:
The segment index (subgrid) that contains a cell

getFirstCellIndex

public int getFirstCellIndex(GridSegment segment)
Returns the cell index for the first cell in the segment

Returns:
The cell index for the first cell in the segment. If segment doesn't exist -1 is returned.

getSizes

public AtRefNumber[][] getSizes()
Returns the size constraints for every segment. [segment#][MIN, PREFERRED, MAX].

The arrays is shared and must not be changed!

Returns:
The size constraints for every segment


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.