com.miginfocom.calendar.activity.view
Class DefaultActivityView

java.lang.Object
  extended by com.miginfocom.calendar.activity.view.AbstractActivityView
      extended by com.miginfocom.calendar.activity.view.DefaultActivityView
All Implemented Interfaces:
ActivityView, Categorizable, TimeSpan, PropertyProvider, java.beans.PropertyChangeListener, java.lang.Comparable, java.util.EventListener

public class DefaultActivityView
extends AbstractActivityView
implements java.beans.PropertyChangeListener

Default implementation of an activity's view. Moslty bounds and bounds change -> repaint handling.


Constructor Summary
DefaultActivityView(javax.swing.JComponent container, Activity model, InteractionListener iListener)
          Constructor
DefaultActivityView(javax.swing.JComponent container, Activity model, InteractionListener iListener, ImmutableDateRange viewRange)
          Constructor
 
Method Summary
protected  java.awt.Rectangle addPadding(java.awt.Rectangle r)
          Adds padding to r.
 void dispose()
          Disposes of any resourses the view has tied.
 java.awt.Rectangle[] getBounds()
          Return all bounds the this view currently occupy.
 java.awt.Rectangle getBoundsUnion()
          Returns the union of all bounds for this view
protected  java.awt.Rectangle getDifference(java.awt.Rectangle[] r1, java.awt.Rectangle[] r2)
          Unions the difference.
 java.awt.Rectangle getPaddedBoundsUnion()
          Returnes the union of all bounds for this view with padding added
 java.awt.Insets getPadding()
          Returns the external padding (e.g.
protected  java.awt.Rectangle getUnion(java.awt.Rectangle[] r)
          Unions the ractangles
 void propertyChange(java.beans.PropertyChangeEvent e)
           
 void repaint()
          Repaints ths view in the context it's in, if it can.
 void repaint(java.awt.Rectangle r)
           
 void setBounds(java.awt.Rectangle[] b)
          Sets all bounds for this view.
 void setInteractors(Interactor[] interactors)
          Sets the interactors for this view.
 void setPadding(java.awt.Insets p)
          Sets the padding for this view.
 
Methods inherited from class com.miginfocom.calendar.activity.view.AbstractActivityView
addCategoryID, compareTo, containsProperty, getCategoryIDs, getContainer, getDateRangeClone, getDateRangeForReading, getInteractionListener, getInteractors, getModel, getPaintObject, getProperty, getViewDateRange, getWritableDateRange, invalidate, isCategory, removeCategoryID, setCategoryIDs, setInteractionListener, setPaintObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultActivityView

public DefaultActivityView(javax.swing.JComponent container,
                           Activity model,
                           InteractionListener iListener)
Constructor

Parameters:
container - The component used for painting this view.
model - The 'model' to view. Never null.
iListener - Optiponal listener to InteractionEvents

DefaultActivityView

public DefaultActivityView(javax.swing.JComponent container,
                           Activity model,
                           InteractionListener iListener,
                           ImmutableDateRange viewRange)
Constructor

Parameters:
container - The component used for painting this view.
model - The 'model' to view. Never null.
iListener - Optiponal 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
Overrides:
dispose in class AbstractActivityView

setBounds

public void setBounds(java.awt.Rectangle[] b)
Description copied from interface: ActivityView
Sets all bounds for this view.

Specified by:
setBounds in interface ActivityView
Parameters:
b - null hides the view. Object will be overtaken. null elements should be ignored internally in the class and will be returned by ActivityView.getBounds().

getBounds

public java.awt.Rectangle[] getBounds()
Description copied from interface: ActivityView
Return all bounds the this view currently occupy.

Specified by:
getBounds in interface ActivityView
Returns:
null if not laid out yet or bounds set to null. Elements may be null!!.

getBoundsUnion

public java.awt.Rectangle getBoundsUnion()
Description copied from interface: ActivityView
Returns the union of all bounds for this view

Specified by:
getBoundsUnion in interface ActivityView
Returns:
null if not laid out yet or bounds set to null.

getPaddedBoundsUnion

public java.awt.Rectangle getPaddedBoundsUnion()
Description copied from interface: ActivityView
Returnes the union of all bounds for this view with padding added

Specified by:
getPaddedBoundsUnion in interface ActivityView
Returns:
null if not laid out yet or bounds set to null.

setPadding

public void setPadding(java.awt.Insets p)
Description copied from interface: ActivityView
Sets the padding for this view. This class never changes the object so it is encurraged to use a shared Insets object if possible which will reduce memory footprint when there are many views.
This padding is used to know the region to repaint.
Returns fast if same as already set.
Doesn't call repaint, that has do be done manually from the caller.

Specified by:
setPadding in interface ActivityView
Parameters:
p - The padding, can be null.

addPadding

protected java.awt.Rectangle addPadding(java.awt.Rectangle r)
Adds padding to r.

Parameters:
r - If padding != null r will be padded.
Returns:
r as convenience, NOT a new object.

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
Overrides:
setInteractors in class AbstractActivityView
Parameters:
interactors - The interactors for this view or null if there aren't any.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getPadding

public java.awt.Insets getPadding()
Description copied from interface: ActivityView
Returns the external padding (e.g. shadow). Will never be null. Default is (1, 1, 1, 1) to accomodate for anti aliasing.

Specified by:
getPadding in interface ActivityView
Returns:
The external padding for this view. Returns the live object to avoid unnecessary copying. MUST NOT BE CHANGED since it can be shared.

repaint

public void repaint()
Description copied from interface: ActivityView
Repaints ths view in the context it's in, if it can.

Specified by:
repaint in interface ActivityView

repaint

public void repaint(java.awt.Rectangle r)

getDifference

protected java.awt.Rectangle getDifference(java.awt.Rectangle[] r1,
                                           java.awt.Rectangle[] r2)
Unions the difference. Only recognizes rectangle diffrences within the bounds of parent.

Parameters:
r1 - Handles null, length 0 and null elements correctly
r2 - Handles null, length 0 and null elements correctly
Returns:
The difference union or null if no difference. Can return a rectangle bigger than the bounds.

getUnion

protected java.awt.Rectangle getUnion(java.awt.Rectangle[] r)
Unions the ractangles

Parameters:
r - The rectangles. Can be null and elements can be null.
Returns:
The union (as a new object) or null if empty (or null) array was sent in.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.