com.miginfocom.calendar.layout
Class TimeBoundsLayout

java.lang.Object
  extended by com.miginfocom.calendar.layout.ActivityLayout
      extended by com.miginfocom.calendar.layout.TimeBoundsLayout
All Implemented Interfaces:
java.io.Serializable

public class TimeBoundsLayout
extends ActivityLayout

A layout that lays out ActivityViews in a rectangular shape exactly as big as the time it occupies. This layout always returns at least 0 in getLayoutPriority(com.miginfocom.calendar.activity.view.ActivityView) so it should be last in the DateArea and effectively becomes the "fall back" layout alternative.

Since the algorithm is quite extensive this layout is not suited for laing out an extremely larget amount activity views. Performance is decreased exponentionally since all activity view have to be check if they overlap any other. A thousand or so should be ok though.

Note that this layout can round the visual bounds with a DateRangeRounder. This means that it can also be used to create a list, much like the month view in Outlook or iCal, just round it to day boundary with:

layout.setVisualDateRangeRounder(new BoundaryRounder(DateRangeI.RANGE_TYPE_DAY, true, true, false));

See Also:
Serialized Form

Constructor Summary
TimeBoundsLayout()
          Constructor for a general gap of two pixels
TimeBoundsLayout(AtRefNumber shapeGap, AtRefRangeNumber primStart, AtRefRangeNumber primEnd, AtRefRangeNumber secStart, AtRefRangeNumber secEnd, int categoryGap, AtRefNumber prefSize, AtRefNumber minSize, AtRefNumber maxSize, java.lang.String[] layoutContexts, DateRangeRounder rounder)
          Constructor.
TimeBoundsLayout(AtRefNumber shapeGap, AtRefRangeNumber start, AtRefRangeNumber end, int categoryGap)
          Constructor for no specifiec size constraints of the laid out rectangles.
TimeBoundsLayout(AtRefNumber shapeGap, AtRefRangeNumber start, AtRefRangeNumber end, int categoryGap, AtRefNumber prefSize, AtRefNumber minSize, AtRefNumber maxSize)
          Constructor.
TimeBoundsLayout(AtRefNumber shapeGap, AtRefRangeNumber start, AtRefRangeNumber end, int categoryGap, AtRefNumber prefSize, AtRefNumber minSize, AtRefNumber maxSize, java.lang.String[] layoutContexts, DateRangeRounder rounder)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 int getCategoryGap()
          Returns the gap in pixels between category grid lines and the bounds of the text rects.
 java.lang.String[] getDefaultContexts()
          Returns the contexts this layout will report a higher priority to layout.
 AtRefRangeNumber getEnd()
          Returns where to end layout activity views within the cells.
 int getLayoutPriority(ActivityView actView)
          Returns in which degree this layout accepts responsibility for laying out this ActivityView.
 AtRefNumber getMaximumRectangleSize()
          Returns the maximum size for the laid out rectangles.
If != null this is the preferred size (height or width) of the rect.
 AtRefNumber getMinimumRectangleSize()
          Returns the minimum size for the laid out rectangles.
If != null this is the preferred size (height or width) of the rect.
 AtRefNumber getPreferredRectangleSize()
          Returns the preferred size for the laid out rectangles.
If != null this is the preferred size (height or width) of the rect.
 AtRefRangeNumber getPrimaryDimCellEnd()
          Returns the cell insets for the end in the primary dimension.
 AtRefRangeNumber getPrimaryDimCellStart()
          Returns the cell insets for the start in the primary dimension.
 AtRefNumber getShapeGap()
          Returns the internal gap between the different shapes.
 AtRefRangeNumber getStart()
          Returns where to start layout activity views within the cells.
 DateRangeRounder getVisualDateRangeRounder()
          Returns the rounder used for rounding of the laid out activity view's date ranges.
 TimeSpanList layout(DateGrid dateGrid, TimeSpanList actViewList, java.util.ArrayList occupiedRects, ImmutableDateRange onlyRange)
          Layout the activities within the bounds.
 void setCategoryGap(int catGap)
          Sets the gap in pixels between category grid lines and the bounds of the text rects.
 void setEnd(AtRefRangeNumber end)
          Sets where to end layout activity views within the cells.
 void setMaximumRectangleSize(AtRefNumber maxSize)
          Sets the maximum size for the laid out rectangles.
 void setMinimumRectangleSize(AtRefNumber minSize)
          Sets the minimum size for the laid out rectangles.
 void setPreferredRectangleSize(AtRefNumber prefSize)
          Sets the preferred size for the laid out rectangles.
 void setPrimaryDimCellEnd(AtRefRangeNumber s)
          Returns the cell insets for the end in the primary dimension.
 void setPrimaryDimCellStart(AtRefRangeNumber s)
          Returns the cell insets for the start in the primary dimension.
 void setShapeGap(AtRefNumber shapeGap)
          Sets the internal gap between the different shapes.
 void setStart(AtRefRangeNumber start)
          Sets where to start layout activity views within the cells.
 void setVisualDateRangeRounder(DateRangeRounder rounder)
          Sets the rounder used for rounding of the laid out activity view's date ranges.
 
Methods inherited from class com.miginfocom.calendar.layout.ActivityLayout
getLayoutContexts, isInContexts, setLayoutContexts, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeBoundsLayout

public TimeBoundsLayout()
Constructor for a general gap of two pixels


TimeBoundsLayout

public TimeBoundsLayout(AtRefNumber shapeGap,
                        AtRefRangeNumber start,
                        AtRefRangeNumber end,
                        int categoryGap)
Constructor for no specifiec size constraints of the laid out rectangles.

Parameters:
shapeGap - The internal gap between the different shapes. Negative values makes the text rects overlap. In reference to row size.
start - The gap in pixels between cell grid line before and the bounds of the text rects.
end - The gap in pixels between cell grid line after and the bounds of the text rects.
categoryGap - The gap in pixels between category grid lines and the bounds of the text rects.
See Also:
AtFixed, AtFraction

TimeBoundsLayout

public TimeBoundsLayout(AtRefNumber shapeGap,
                        AtRefRangeNumber start,
                        AtRefRangeNumber end,
                        int categoryGap,
                        AtRefNumber prefSize,
                        AtRefNumber minSize,
                        AtRefNumber maxSize)
Constructor.

Parameters:
shapeGap - The internal gap between the different shapes. Negative values makes the text rects overlap. In reference to row size.
start - The gap in pixels between cell grid line before and the bounds of the text rects.
end - The gap in pixels between cell grid line after and the bounds of the text rects.
categoryGap - The gap in pixels between category grid lines and the bounds of the text rects.
prefSize - The preferred size for the laid out rectangles. null means "fill to bounds".
minSize - The minimum size for the laid out rectangles. null means no minimum size.
maxSize - The maximum size for the laid out rectangles.null means no maximum size.
See Also:
AtFixed, AtFraction

TimeBoundsLayout

public TimeBoundsLayout(AtRefNumber shapeGap,
                        AtRefRangeNumber start,
                        AtRefRangeNumber end,
                        int categoryGap,
                        AtRefNumber prefSize,
                        AtRefNumber minSize,
                        AtRefNumber maxSize,
                        java.lang.String[] layoutContexts,
                        DateRangeRounder rounder)
Constructor.

Parameters:
shapeGap - The internal gap between the different shapes. Negative values makes the text rects overlap. In reference to row size.
start - The gap between cell grid line before and the bounds of the text rects.
end - The gap between cell grid line after and the bounds of the text rects.
categoryGap - The gap in pixels between category grid lines and the bounds of the text rects.
prefSize - The preferred size for the laid out rectangles. null means "fill to bounds".
minSize - The minimum size for the laid out rectangles. null means no minimum size.
maxSize - The maximum size for the laid out rectangles.null means no maximum size.
layoutContexts - The layout contexts this layout should react to. If null the default one {"TimeBounds"} is used.
rounder - The rounder (e.g. BoundaryRounder) to round the visual appearance. null means no rounding.
See Also:
AtFixed, AtFraction

TimeBoundsLayout

public TimeBoundsLayout(AtRefNumber shapeGap,
                        AtRefRangeNumber primStart,
                        AtRefRangeNumber primEnd,
                        AtRefRangeNumber secStart,
                        AtRefRangeNumber secEnd,
                        int categoryGap,
                        AtRefNumber prefSize,
                        AtRefNumber minSize,
                        AtRefNumber maxSize,
                        java.lang.String[] layoutContexts,
                        DateRangeRounder rounder)
Constructor.

Parameters:
shapeGap - The internal gap between the different shapes. Negative values makes the text rects overlap. In reference to row size.
primStart - The cell insets for the start in the primary dimension. Not null.
primEnd - The cell insets for the end in the primary dimension. Not null.
secStart - The gap between cell grid line before and the bounds of the text rects.
secEnd - The gap between cell grid line after and the bounds of the text rects.
categoryGap - The gap in pixels between category grid lines and the bounds of the text rects.
prefSize - The preferred size for the laid out rectangles. null means "fill to bounds".
minSize - The minimum size for the laid out rectangles. null means no minimum size.
maxSize - The maximum size for the laid out rectangles.null means no maximum size.
layoutContexts - The layout contexts this layout should react to. If null the default one {"TimeBounds"} is used.
rounder - The rounder (e.g. BoundaryRounder) to round the visual appearance. null means no rounding.
See Also:
AtFixed, AtFraction
Method Detail

getLayoutPriority

public int getLayoutPriority(ActivityView actView)
Description copied from class: ActivityLayout
Returns in which degree this layout accepts responsibility for laying out this ActivityView.
The Activity.getLayoutContext() and the duration is normally used to determine this. The installed layout with the highest priority will get the chance to layout the actView later on. TimeBoundsLayout will always return 0 so returning a negative value will make sure that this layout won't be called to layout that actView (that is if TimeBoundsLayout is installed in the DateArea. Should normally be < 10.

Specified by:
getLayoutPriority in class ActivityLayout
Parameters:
actView - The view that is to be laid out
Returns:
If this layout accepts responsibility for laying out this ActivityView.

getDefaultContexts

public java.lang.String[] getDefaultContexts()
Returns the contexts this layout will report a higher priority to layout.

Specified by:
getDefaultContexts in class ActivityLayout
Returns:
new String[] {"TimeBounds"}

layout

public TimeSpanList layout(DateGrid dateGrid,
                           TimeSpanList actViewList,
                           java.util.ArrayList occupiedRects,
                           ImmutableDateRange onlyRange)
Description copied from class: ActivityLayout
Layout the activities within the bounds. All activities that couldn't fit for some reason should have their bounds set to null.

Specified by:
layout in class ActivityLayout
Parameters:
dateGrid - The Grid to layout the activities within
actViewList - A number of ActivityView objects to layout. Will not be "changed". The individual views should be sorted in the preferred order to paint the activities later.
occupiedRects - The areas (Rectangle2D) that currently are not free. They may or may not be within the bounds. They also may or may not be ignored, but if they are ignored, they will possibly be painted over or paint over something else. Not null.
onlyRange - The layout range that actually need to be laid out. If null all in actViewList should be laid out. This argument is mostly for optimizing. Since the container can't know which dates translates to what pixels this optimization is up to the atcivity layout.
Returns:
A list with DateRangeIs representing time spans that couldn't be laid out due to shortage of free space. Not null and it should be a newly created list that can be overtaken by the caller of this method.

getPrimaryDimCellStart

public AtRefRangeNumber getPrimaryDimCellStart()
Returns the cell insets for the start in the primary dimension. It can be used to for instance specify an empty border in the cells.

Returns:
The cell insets for the start in the primary dimension. Not null.
See Also:
getStart()

setPrimaryDimCellStart

public void setPrimaryDimCellStart(AtRefRangeNumber s)
Returns the cell insets for the start in the primary dimension. It can be used to for instance specify an empty border in the cells.

Parameters:
s - The cell insets for the start in the primary dimension. Not null.
See Also:
setStart(com.miginfocom.util.gfx.geometry.numbers.AtRefRangeNumber)

getPrimaryDimCellEnd

public AtRefRangeNumber getPrimaryDimCellEnd()
Returns the cell insets for the end in the primary dimension. It can be used to for instance specify an empty border in the cells.

Returns:
The cell insets for the end in the primary dimension. Not null.
See Also:
getEnd()

setPrimaryDimCellEnd

public void setPrimaryDimCellEnd(AtRefRangeNumber s)
Returns the cell insets for the end in the primary dimension. It can be used to for instance specify an empty border in the cells.

Parameters:
s - The cell insets for the end in the primary dimension. Not null.
See Also:
setEnd(com.miginfocom.util.gfx.geometry.numbers.AtRefRangeNumber)

getShapeGap

public AtRefNumber getShapeGap()
Returns the internal gap between the different shapes. It can be of two types:
Float or Double: -1 to "MAX". The gap in a percentage of the available bounds. Negative values makes the text rects overlap. -1f means fully overlap, 0f means side by side.

Returns:
The internal gap between the different shapes.

setShapeGap

public void setShapeGap(AtRefNumber shapeGap)
Sets the internal gap between the different shapes.

Parameters:
shapeGap - The internal gap between the different shapes.
See Also:
getShapeGap()

getStart

public AtRefRangeNumber getStart()
Returns where to start layout activity views within the cells.

Note that this is for the Secondary dimension.

Returns:
Where to start layout activity views within the cells. Not null.

setStart

public void setStart(AtRefRangeNumber start)
Sets where to start layout activity views within the cells. E.g. new AtStart(2) to start two pixels in.

Note that this is for the Secondary dimension.

Parameters:
start - Where to start layout activity views within the cells. Not null.

getEnd

public AtRefRangeNumber getEnd()
Returns where to end layout activity views within the cells.

Note that this is for the Secondary dimension.

Returns:
Where to end layout activity views within the cells. Not null.

setEnd

public void setEnd(AtRefRangeNumber end)
Sets where to end layout activity views within the cells. E.g. new AtEnd(-2) to end two pixels from the cell's end.

Note that this is for the Secondary dimension.

Parameters:
end - Where to end layout activity views within the cells. Not null.

getCategoryGap

public int getCategoryGap()
Returns the gap in pixels between category grid lines and the bounds of the text rects.

Returns:
The gap in pixels between category grid lines and the bounds of the text rects.

setCategoryGap

public void setCategoryGap(int catGap)
Sets the gap in pixels between category grid lines and the bounds of the text rects.

Parameters:
catGap - The gap in pixels between category grid lines and the bounds of the text rects.

getPreferredRectangleSize

public AtRefNumber getPreferredRectangleSize()
Returns the preferred size for the laid out rectangles.
If != null this is the preferred size (height or width) of the rect. If the grid's primaryDimension is HORIZONTAL it's the height, and vice versa. null means "fill to bounds". Can be of two types:
Float: 0f to 1f. The size is a percentage of the bounds in the laid out dimension.
Integer: The size is in absolute pixels.

Returns:
The preferred size for the laid out rectangles.

setPreferredRectangleSize

public void setPreferredRectangleSize(AtRefNumber prefSize)
Sets the preferred size for the laid out rectangles.

Parameters:
prefSize - The preferred size for the laid out rectangles.
See Also:
getPreferredRectangleSize()

getMinimumRectangleSize

public AtRefNumber getMinimumRectangleSize()
Returns the minimum size for the laid out rectangles.
If != null this is the preferred size (height or width) of the rect. If the grid's primaryDimension is HORIZONTAL it's the height, and vice versa. null means no minimum size. Can be of two types:
Float: 0f to 1f. The size is a percentage of the bounds in the laid out dimension.
Integer: The size is in absolute pixels.

Returns:
The minimum size for the laid out rectangles.

setMinimumRectangleSize

public void setMinimumRectangleSize(AtRefNumber minSize)
Sets the minimum size for the laid out rectangles.

Parameters:
minSize - The minimum size for the laid out rectangles.
See Also:
getMinimumRectangleSize()

getMaximumRectangleSize

public AtRefNumber getMaximumRectangleSize()
Returns the maximum size for the laid out rectangles.
If != null this is the preferred size (height or width) of the rect. If the grid's primaryDimension is HORIZONTAL it's the height, and vice versa. null means no maximum size. Can be of two types:
Float: 0f to 1f. The size is a percentage of the bounds in the laid out dimension.
Integer: The size is in absolute pixels.

Returns:
The maximum size for the laid out rectangles.

setMaximumRectangleSize

public void setMaximumRectangleSize(AtRefNumber maxSize)
Sets the maximum size for the laid out rectangles.

Parameters:
maxSize - The maximum size for the laid out rectangles.
See Also:
getMaximumRectangleSize()

getVisualDateRangeRounder

public DateRangeRounder getVisualDateRangeRounder()
Returns the rounder used for rounding of the laid out activity view's date ranges.

Returns:
The rounder used for rounding of the laid out activity view's date ranges. May be null.
See Also:
setVisualDateRangeRounder(com.miginfocom.util.dates.DateRangeRounder)

setVisualDateRangeRounder

public void setVisualDateRangeRounder(DateRangeRounder rounder)
Sets the rounder used for rounding of the laid out activity view's date ranges. The view's date ranges will not be changed but the date range used for laying out will. If for instance the rounder rounds to day boundaries all activity views will start and end visually at a day boundary. The activities themselves though will not have their actual date/time range changed.
Set to null for no rounding.

Parameters:
rounder - The rounder that should be used for rounding of the laid out activity view's date ranges. May be null.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.