com.miginfocom.calendar.activity.view
Class AbstractActivityView

java.lang.Object
  extended by com.miginfocom.calendar.activity.view.AbstractActivityView
All Implemented Interfaces:
ActivityView, Categorizable, TimeSpan, PropertyProvider, java.lang.Comparable
Direct Known Subclasses:
DefaultActivityView

public abstract class AbstractActivityView
extends java.lang.Object
implements ActivityView

Implements some basic functionality from the ActivityView interface.
Mainly Category, DateRange, AShape and Interactors handling. This view is also connected to a JComponent.


Constructor Summary
protected AbstractActivityView(javax.swing.JComponent container, Activity model, InteractionListener iListener)
          Contructor
protected AbstractActivityView(javax.swing.JComponent container, Activity model, InteractionListener iListener, ImmutableDateRange viewRange)
          Contructor
 
Method Summary
 void addCategoryID(java.lang.Object catID, int index)
          Adds a category to the category list.
 int compareTo(java.lang.Object o)
          If they overlaps, the longest is first.
 boolean containsProperty(PropertyKey property)
          Return if the provider contains the property.
 void dispose()
          Disposes of any resourses the view has tied.
 java.lang.Object[] getCategoryIDs()
          Returns the categories that this object is linked to.
 javax.swing.JComponent getContainer()
          Returns the container component.
 MutableDateRange getDateRangeClone()
          Returns the date range that the object spans as a clone which is safe to change without chaning the original time span.
 DateRangeI getDateRangeForReading()
          Returns the date range that the object spans.
 InteractionListener getInteractionListener()
          Returns the interaction listener or null.
 Interactor[] getInteractors()
          Returns the interactors for this view.
 Activity getModel()
          Returns the 'model', which is the Activity
 java.lang.Object getPaintObject()
          Returns the object that this view will be painted with.
 java.lang.Object getProperty(PropertyKey property)
          Returns the property for a name.
 ImmutableDateRange getViewDateRange()
          Returns the date range that this view should represent.
 MutableDateRange getWritableDateRange()
          Returns the contained date range for editing.
 void invalidate()
          Removes all cached paint optimizations for this view so that they will be recreated next paint run.
 boolean isCategory(java.lang.Object id)
          Returns if id is one of the id:s that this categorizable has.
 void removeCategoryID(java.lang.Object catID)
          Removes a category from the category list.
 void setCategoryIDs(java.lang.Object[] catIDs)
          Sets the IDs of the categories that this activity should belong to or an empty array if none.
 void setInteractionListener(InteractionListener iListener)
          Sets the interaction listener.
 void setInteractors(Interactor[] interactors)
          Sets the interactors for this view.
 void setPaintObject(java.lang.Object object)
          Sets the object that will be used to paint this view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.miginfocom.calendar.activity.view.ActivityView
getBounds, getBoundsUnion, getPaddedBoundsUnion, getPadding, repaint, setBounds, setPadding
 

Constructor Detail

AbstractActivityView

protected AbstractActivityView(javax.swing.JComponent container,
                               Activity model,
                               InteractionListener iListener)
Contructor

Parameters:
container - The component to show this view. Will be kept in a WeakReference
model - The Activity to create a view for
iListener - Optional listener to InteractionEvents

AbstractActivityView

protected AbstractActivityView(javax.swing.JComponent container,
                               Activity model,
                               InteractionListener iListener,
                               ImmutableDateRange viewRange)
Contructor

Parameters:
container - The component to show this view. Will be kept in a WeakReference
model - The Activity to create a view for
iListener - Optional listener to InteractionEvents
viewRange - The view date range. Only should be non-null if the view is representing a different date range than the model. This usually only happens if the model is recurrent and the view represents one of the recurrencies.
Method Detail

dispose

public void dispose()
Description copied from interface: ActivityView
Disposes of any resourses the view has tied. The view can not be used after this.

Specified by:
dispose in interface ActivityView

invalidate

public void invalidate()
Description copied from interface: ActivityView
Removes all cached paint optimizations for this view so that they will be recreated next paint run.

Specified by:
invalidate in interface ActivityView

getViewDateRange

public ImmutableDateRange getViewDateRange()
Description copied from interface: ActivityView
Returns the date range that this view should represent. If the Activity that this view represents isn't recurrent this date range is the Activity's own base date range.

Specified by:
getViewDateRange in interface ActivityView
Returns:
The date range that this view should represent. Returns the live MutableDateRange object to avoid unnecessary copying. Don't change this object other than temporary.

getModel

public Activity getModel()
Description copied from interface: ActivityView
Returns the 'model', which is the Activity

Specified by:
getModel in interface ActivityView
Returns:
The 'model', which is the Activity. Never null.

getDateRangeClone

public MutableDateRange getDateRangeClone()
Description copied from interface: TimeSpan
Returns the date range that the object spans as a clone which is safe to change without chaning the original time span. If the range is only to be read from use TimeSpan.getDateRangeForReading() instead to avoid unnecessary object cloning.

Specified by:
getDateRangeClone in interface TimeSpan
Returns:
Returns the date range that the object spans.

getDateRangeForReading

public DateRangeI getDateRangeForReading()
Description copied from interface: TimeSpan
Returns the date range that the object spans. If the object contains an immutable date range or a range that must not be changed that is returned here. In order to get a truly immutable date range that will not change call DateRangeI.getImmutable() on the returned range. The contract is to not change the returned date range.

Specified by:
getDateRangeForReading in interface TimeSpan
Returns:
Returns the date range that the object spans.

getWritableDateRange

public MutableDateRange getWritableDateRange()
Description copied from interface: TimeSpan
Returns the contained date range for editing. If the local date range isn't allowed to be edited an UnsupportedOperationException should be thrown.

Specified by:
getWritableDateRange in interface TimeSpan
Returns:
The contained date range for editing.

getContainer

public javax.swing.JComponent getContainer()
Description copied from interface: ActivityView
Returns the container component.

Specified by:
getContainer in interface ActivityView
Returns:
The container component. Migtht be null at any time since it's kept in a WeakReference.

getProperty

public java.lang.Object getProperty(PropertyKey property)
Description copied from interface: PropertyProvider
Returns the property for a name.

Specified by:
getProperty in interface PropertyProvider
Parameters:
property - The property key for the property to return. Not null.
Returns:
The value, may be null.

containsProperty

public boolean containsProperty(PropertyKey property)
Description copied from interface: PropertyProvider
Return if the provider contains the property.

Specified by:
containsProperty in interface PropertyProvider
Parameters:
property - The property key. Not null.
Returns:
If the provider contains the property.

getInteractionListener

public InteractionListener getInteractionListener()
Description copied from interface: ActivityView
Returns the interaction listener or null.

Specified by:
getInteractionListener in interface ActivityView
Returns:
The interaction listener or null.
See Also:
InteractionListener

setInteractionListener

public void setInteractionListener(InteractionListener iListener)
Description copied from interface: ActivityView
Sets the interaction listener.

Specified by:
setInteractionListener in interface ActivityView
Parameters:
iListener - The interaction listener or null.
See Also:
InteractionListener

setInteractors

public void setInteractors(Interactor[] interactors)
Description copied from interface: ActivityView
Sets the interactors for this view. Not used internally.

Specified by:
setInteractors in interface ActivityView
Parameters:
interactors - The interactors for this view or null if there aren't any.

getInteractors

public Interactor[] getInteractors()
Description copied from interface: ActivityView
Returns the interactors for this view. Don't clone, returns live array.

Specified by:
getInteractors in interface ActivityView
Returns:
The interactors for this view or null if there aren't any.

setPaintObject

public void setPaintObject(java.lang.Object object)
Description copied from interface: ActivityView
Sets the object that will be used to paint this view. The type can be anything that the controller decide it should be. Not used internally.

Specified by:
setPaintObject in interface ActivityView
Parameters:
object - The object. Can be null.

getPaintObject

public java.lang.Object getPaintObject()
Description copied from interface: ActivityView
Returns the object that this view will be painted with.

Specified by:
getPaintObject in interface ActivityView
Returns:
The object that this view will be painted with. Can be null.

compareTo

public int compareTo(java.lang.Object o)
If they overlaps, the longest is first. Otherwise they are sorted according to the start time

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The other Activity to compare to
Returns:
< 0 if less, > 0 if more or 0 if same.

getCategoryIDs

public java.lang.Object[] getCategoryIDs()
Description copied from interface: Categorizable
Returns the categories that this object is linked to.

Specified by:
getCategoryIDs in interface Categorizable
Returns:
The categories that this object is linked to. May be null and with length 0.

setCategoryIDs

public void setCategoryIDs(java.lang.Object[] catIDs)
Description copied from interface: Categorizable
Sets the IDs of the categories that this activity should belong to or an empty array if none. Never null.

Specified by:
setCategoryIDs in interface Categorizable
Parameters:
catIDs - The IDs of the categories that this activity should belong to or an empty array if none. May be null and with length 0.

isCategory

public boolean isCategory(java.lang.Object id)
Description copied from interface: Categorizable
Returns if id is one of the id:s that this categorizable has.

Specified by:
isCategory in interface Categorizable
Parameters:
id - The id to check.
Returns:
If id is one of the id:s that this categorizable has.

addCategoryID

public void addCategoryID(java.lang.Object catID,
                          int index)
Description copied from interface: Categorizable
Adds a category to the category list. If catID already exists for this object, nothing is changed.
Will remake an array every time. I.e. optimized for retrieval of the categories, not insertion.

Specified by:
addCategoryID in interface Categorizable
Parameters:
catID - The ID of the categories that this activity should also belong to. Not null.
index - The index at which to add the category id. It might be important since category IDs earlier in the array will sometimes hide latter ones, such as for category overrides.

index is lenient in the upper range. It is legal to set a very high value (e.g. MigUtil.BIG_INT to be sure it will be added last. 0 will add it first. It should not be negative though.


removeCategoryID

public void removeCategoryID(java.lang.Object catID)
Description copied from interface: Categorizable
Removes a category from the category list. If catID don't exist for this object, nothing is changed.

Will normally remake a new array every time. I.e. optimized for retrieval of the categories, not removal.

Specified by:
removeCategoryID in interface Categorizable
Parameters:
catID - The ID of the categories that this activity should no longer belong to. Not null.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.