com.miginfocom.calendar.header
Class DateGridHeader

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.miginfocom.calendar.header.AbstractGridHeader
                  extended by com.miginfocom.calendar.header.DateGridHeader
All Implemented Interfaces:
InteractionListener, GridContainer, Header, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.Scrollable

public class DateGridHeader
extends AbstractGridHeader
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

A generic header that can show date/time labels and grid lines horizontally or vertically. Maps positions in the primary dimension to a Grid object.

You will have to add decorators to draw, for instance, the labels.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static AtFixed DEF_FIXED
           
static int DEFAULT_ROW_SIZE
           
protected  GridLineSpecification gridLineSpec
          The sizes/paint or the grid lines.
protected  int[] rangeTypes
          The range types that goes with eachdate format above.
protected  AtRefNumber[] sizes
          The sizes in the secondary dimension.
protected  DateGrid trackedGrid
          The grid that this header tracks and paints the labels for.
 
Fields inherited from class com.miginfocom.calendar.header.AbstractGridHeader
decoratorSupport, HOR, VER
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DateGridHeader(DateArea dateArea, GridLineSpecification gridLineSpec, int[] rangeTypes, AtRefNumber[] sizes, int edge)
          Constructor.
DateGridHeader(DateArea dateArea, int gridLineSize, java.awt.Paint gridLinePaint, int[] rangeTypes, AtRefNumber[] sizes, int edge)
          Constructor for many rows but s simple grid line specification.
DateGridHeader(DateArea dateArea, int gridLineSize, java.awt.Paint gridLinePaint, int rangeType, AtRefNumber size, int edge)
          Constructor for only one row.
 
Method Summary
 void addDateChangeListener(DateChangeListener l)
          Adds a listener that is notified of all changes to the date in the header.
 void addDateChangeListener(DateChangeListener l, boolean asWeakRef)
          Adds a listener that is notified of all changes to the date in the header.
protected  void checkGrid()
          Creates (or re-creates) the grid that is used to track the grid in the labeled date area if the grid in the date area has changed.
 void dispose()
          Manually releases any resources allocated.
protected  void fireDateChangeEvent(DateChangeEvent e)
          Fires a change event to all registerd listeners.
 DateCellRange getCellRange(int x, int y, boolean lenient)
          Returns the DateCellRange that the point hits.
 DateHeaderGrid getDateHeaderGrid()
          Returns the grid that this header uses for layout
 HeaderGrid getHeaderGrid()
          Returns the grid that this header uses for layout
 DateCellRange getMouseOverRange()
           
 DateCellRange getPressedRange()
           
 ImmutableDateRange getSelectedDateRange()
           
 DateArea getTrackedDateArea()
          Returns the date area that is tracked.
 boolean isMouseOverEffectsEnabled()
          Returns if mouse over-type effects are enabled.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void removeDateChangeListener(DateChangeListener l)
          Removes a listener
 void revalidateGrid()
          Invalidates the grid and revalidate the header.
 void setGridLineSpecification(GridLineSpecification gridLineSpec)
          Sets how thick and with paint to draw the separators between labels.
 void setMouseOverEffectsEnabled(boolean b)
          Sets if mouse over-type effects are to be enabled.
 void setRangeTypes(int[] rangeTypes)
          Sets the types of ranges in the different rows.
 void setSizes(AtRefNumber[] sizes)
          Sets the sizes, relative or absolute, of the individualt rows in the header.
 
Methods inherited from class com.miginfocom.calendar.header.AbstractGridHeader
addDecorator, addDecorators, addGridListener, addGridListener, addInteractionListener, addInteractionListener, addNotify, clearBackBuffer, doLayout, fireInteractionOccured, fireStructureChanged, getBackgroundPaint, getComponent, getDecorator, getDecorators, getEdge, getGrid, getMaximumSize, getMinimumSize, getPreferredScrollableViewportSize, getPreferredSecondarySize, getPreferredSize, getPrimaryDimension, getPrimaryInsets, getPrimDim, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollPane, getSecondaryInsets, getTrackedComponent, getUseStartDate, interactionOccured, isBeforeGrid, isCacheWithBackBuffer, paint, paintComponent, print, processEvent, propertyChange, removeDecorator, removeDecorators, removeDecorators, removeGridListener, removeInteractionListener, removeNotify, setBackground, setBackgroundPaint, setCacheWithBackBuffer, setGridBoundsAndLayout, setPreferredSecondarySize, setUseStartDate, shouldUseStartDate
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ROW_SIZE

public static final int DEFAULT_ROW_SIZE
See Also:
Constant Field Values

DEF_FIXED

public static final AtFixed DEF_FIXED

sizes

protected AtRefNumber[] sizes
The sizes in the secondary dimension.


rangeTypes

protected int[] rangeTypes
The range types that goes with eachdate format above. (dateFormats.length == rangeTypes.length)


trackedGrid

protected transient DateGrid trackedGrid
The grid that this header tracks and paints the labels for.


gridLineSpec

protected GridLineSpecification gridLineSpec
The sizes/paint or the grid lines.

Constructor Detail

DateGridHeader

public DateGridHeader(DateArea dateArea,
                      int gridLineSize,
                      java.awt.Paint gridLinePaint,
                      int rangeType,
                      AtRefNumber size,
                      int edge)
Constructor for only one row.

Parameters:
dateArea - The date area to show the label for. Not null.
gridLineSize - The thickness of the grid lines.
gridLinePaint - The paint to paint the grid lines with.
rangeType - The type of the range in the row. E.g. DateRangeI.RANGE_TYPE_DAY.
edge - On what side of the grid the label will be. E.g. SwingConstants.TOP .

DateGridHeader

public DateGridHeader(DateArea dateArea,
                      int gridLineSize,
                      java.awt.Paint gridLinePaint,
                      int[] rangeTypes,
                      AtRefNumber[] sizes,
                      int edge)
Constructor for many rows but s simple grid line specification.

Parameters:
dateArea - The date area to show the label for. Not null.
gridLineSize - The thickness of the grid lines.
gridLinePaint - The paint to paint the grid lines with.
rangeTypes - The types of ranges in the different rows. The length of this arrays will be the number of rows (in the secondary dimension) for this header.
sizes - The sizes, relative or absolute, of the individualt rows in the header. If null or length is less than rangeTypes DEFAULT_ROW_SIZE will be used.
edge - On what side of the grid the label will be. E.g. SwingConstants.TOP .

DateGridHeader

public DateGridHeader(DateArea dateArea,
                      GridLineSpecification gridLineSpec,
                      int[] rangeTypes,
                      AtRefNumber[] sizes,
                      int edge)
Constructor.

Parameters:
dateArea - The date area to show the label for. Not null.
gridLineSpec - The specification for the grid lines in the primary and secondary dimensins. Not null.
rangeTypes - The types of ranges in the different rows. The length of this arrays will be the number of rows (in the secondary dimension) for this header.
sizes - The sizes, relative or absolute, of the individualt rows in the header. If null or length is less than rangeTypes DEFAULT_ROW_SIZE will be used.
edge - On what side of the grid the label will be. E.g. SwingConstants.TOP.
Method Detail

dispose

public void dispose()
Description copied from interface: Header
Manually releases any resources allocated. Should normally not be needed, implementations shoudl be self disposing.

Specified by:
dispose in interface Header

getTrackedDateArea

public DateArea getTrackedDateArea()
Returns the date area that is tracked.

Returns:
The date area that is tracked. Not null.

isMouseOverEffectsEnabled

public boolean isMouseOverEffectsEnabled()
Returns if mouse over-type effects are enabled. Mouse listeners will be installed and repaints issues on events if so.

Returns:
true if enabled. false is default.

setMouseOverEffectsEnabled

public void setMouseOverEffectsEnabled(boolean b)
Sets if mouse over-type effects are to be enabled. Mouse listeners will be installed and repaints issues on events if so.

Parameters:
b - true if enabled. false is default.

setGridLineSpecification

public void setGridLineSpecification(GridLineSpecification gridLineSpec)
Sets how thick and with paint to draw the separators between labels. If null no grid lines are painted and they will have size 0.

Won't revalidate or repaint the header, that has to be done manually.

Parameters:
gridLineSpec - The spec, can be null.

setRangeTypes

public void setRangeTypes(int[] rangeTypes)
Sets the types of ranges in the different rows. The length of this arrays will be the number of rows (in the secondary dimension) in the header.
Won't revalidate or repaint the header, that has to be done manually.

Parameters:
rangeTypes - The types of ranges. Not null.

setSizes

public void setSizes(AtRefNumber[] sizes)
Sets the sizes, relative or absolute, of the individualt rows in the header. If null or lenght is less than rangeTypes DEFAULT_ROW_SIZE will be used.
Won't revalidate or repaint the header, that has to be done manually.

Parameters:
sizes - The sizes, can be null.

getHeaderGrid

public HeaderGrid getHeaderGrid()
Returns the grid that this header uses for layout

Specified by:
getHeaderGrid in class AbstractGridHeader
Returns:
The grid that this header uses for layout

getDateHeaderGrid

public DateHeaderGrid getDateHeaderGrid()
Returns the grid that this header uses for layout

Returns:
The grid that this header uses for layout

revalidateGrid

public void revalidateGrid()
Invalidates the grid and revalidate the header.


checkGrid

protected void checkGrid()
Creates (or re-creates) the grid that is used to track the grid in the labeled date area if the grid in the date area has changed.


getCellRange

public DateCellRange getCellRange(int x,
                                  int y,
                                  boolean lenient)
Returns the DateCellRange that the point hits. Gets the cell under the point and expandes in both directions to nearby cells that are merged. The user object

Parameters:
x - X. Can be outside component.
y - Y. Can be outside component.
lenient - If true the method will always return a DateCellRange even if outside bounds.
Returns:
The DateCellRange that the point hits

addDateChangeListener

public void addDateChangeListener(DateChangeListener l)
Adds a listener that is notified of all changes to the date in the header.

Note that mouse effects must be enabled. See setMouseOverEffectsEnabled(boolean)

Parameters:
l - The listener

addDateChangeListener

public void addDateChangeListener(DateChangeListener l,
                                  boolean asWeakRef)
Adds a listener that is notified of all changes to the date in the header.

Parameters:
asWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since the garbage collector can collect the listener if it is only referenced from this list.
Note! This (weak reference) can not be used with listeners that doesn't have another real (a.k.a Strong) reference to it, as for instance an annonymous inner class. If one such listener is added it will be removed almost immediately by the garbage collector.

Note that mouse effects must be enabled. See setMouseOverEffectsEnabled(boolean)

l - The listener

removeDateChangeListener

public void removeDateChangeListener(DateChangeListener l)
Removes a listener

Parameters:
l - the listener

fireDateChangeEvent

protected void fireDateChangeEvent(DateChangeEvent e)
Fires a change event to all registerd listeners.


getMouseOverRange

public DateCellRange getMouseOverRange()

getPressedRange

public DateCellRange getPressedRange()

getSelectedDateRange

public ImmutableDateRange getSelectedDateRange()

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.