com.miginfocom.calendar.layout
Class ActivityLayout

java.lang.Object
  extended by com.miginfocom.calendar.layout.ActivityLayout
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
FlexGridLayout, HideLayout, TimeBoundsLayout

public abstract class ActivityLayout
extends java.lang.Object
implements java.io.Serializable

A interface describing how an activity layout class should be implemented. Activity layouts are used to layout ActivityViews in a DateGrid.

See Also:
Serialized Form

Constructor Summary
ActivityLayout()
           
 
Method Summary
abstract  java.lang.String[] getDefaultContexts()
          Return the default contexts that this layout should react to.
 java.lang.String[] getLayoutContexts()
          Returns the live array of the current contexts to look for.
abstract  int getLayoutPriority(ActivityView actView)
          Returns in which degree this layout accepts responsibility for laying out this ActivityView.
protected  boolean isInContexts(java.lang.String layoutContext)
          Returns if layoutContext equals one of the registered contexts.
abstract  TimeSpanList layout(DateGrid dateGrid, TimeSpanList actViewList, java.util.ArrayList occupiedRects, ImmutableDateRange onlyRange)
          Layout the activities within the bounds.
 void setLayoutContexts(java.lang.String[] contexts)
          Sets the context to use for this layout.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActivityLayout

public ActivityLayout()
Method Detail

layout

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

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.

getLayoutPriority

public abstract int getLayoutPriority(ActivityView actView)
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.

Parameters:
actView - The view that is to be laid out
Returns:
If this layout accepts responsibility for laying out this ActivityView.

getDefaultContexts

public abstract java.lang.String[] getDefaultContexts()
Return the default contexts that this layout should react to.

Returns:
The default contexts that this layout should react to. Not null.

isInContexts

protected boolean isInContexts(java.lang.String layoutContext)
Returns if layoutContext equals one of the registered contexts.

Parameters:
layoutContext - The context to look for. May be null but that will NEVER equal any contexts.
Returns:
If layoutContext equals one of the registered contexts.

getLayoutContexts

public java.lang.String[] getLayoutContexts()
Returns the live array of the current contexts to look for.

Returns:
The live array of the current contexts to look for.

setLayoutContexts

public void setLayoutContexts(java.lang.String[] contexts)
Sets the context to use for this layout. Default is only {"FlexGrid"}. If an activity's layoutContext equals one of these contexts this layout will report that it is very keep (20) to layout that activity. See getLayoutPriority(com.miginfocom.calendar.activity.view.ActivityView).

Parameters:
contexts - The contexts to set. If null reset to defaults (getDefaultContexts()). Will be overtaken. No null elements.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.