com.miginfocom.calendar.header
Class SubRowGridHeader

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.SubRowGridHeader
All Implemented Interfaces:
InteractionListener, GridContainer, Header, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.Scrollable

public class SubRowGridHeader
extends AbstractGridHeader
implements InteractionListener

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

To actually paint something you will nedd to add one or more decorators. E.g. SubRowHeaderDecorator and GridLineDecorator.

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 int DEFAULT_ROW_SIZE
           
 
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
SubRowGridHeader(DateArea dateArea, GridLineSpecification gridLineSpec, int[] sizes, int rowLevelCount, int edge)
          Constructor.
SubRowGridHeader(DateArea dateArea, int gridLineSize, java.awt.Paint gridLinePaint, int[] sizes, int rowLevelCount, int edge)
          Constructor for many rows but s simple grid line specification.
SubRowGridHeader(DateArea dateArea, int gridLineSize, java.awt.Paint gridLinePaint, int size, int rowLevelCount, 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.
 HeaderGrid getHeaderGrid()
          Returns the grid that this header uses for layout
 int getRowLevelCount()
          Returns the number of rows (levels) in the secondary, short, dimension.
 void removeDateChangeListener(javax.swing.event.ChangeListener 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 setRowLevelCount(int count)
          Sets the number of rows (levels) in the secondary, short, dimension.
 void setSizes(int[] sizes)
          Sets the absolute sizes 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
 
Methods inherited from interface com.miginfocom.ashape.interaction.InteractionListener
interactionOccured
 

Field Detail

DEFAULT_ROW_SIZE

public static final int DEFAULT_ROW_SIZE
See Also:
Constant Field Values
Constructor Detail

SubRowGridHeader

public SubRowGridHeader(DateArea dateArea,
                        int gridLineSize,
                        java.awt.Paint gridLinePaint,
                        int size,
                        int rowLevelCount,
                        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.
size - The size, relative or absolute, of all rows (in the short, or secondary dimension) in the header.
rowLevelCount - The number of rows (levels) in the secondary, short, dimension.
edge - On what side of the grid the label will be. E.g. SwingConstants.TOP .

SubRowGridHeader

public SubRowGridHeader(DateArea dateArea,
                        int gridLineSize,
                        java.awt.Paint gridLinePaint,
                        int[] sizes,
                        int rowLevelCount,
                        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.
sizes - The sizes, relative or absolute, of the individualt rows (in the short, or secondary dimension) in the header. If null or length is less than rowLabelCount DEFAULT_ROW_SIZE will be used.
rowLevelCount - The number of rows (levels) in the secondary, short, dimension.
edge - On what side of the grid the label will be. E.g. SwingConstants.TOP .

SubRowGridHeader

public SubRowGridHeader(DateArea dateArea,
                        GridLineSpecification gridLineSpec,
                        int[] sizes,
                        int rowLevelCount,
                        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.
sizes - The sizes, relative or absolute, of the individualt rows (in the short, or secondary dimension) in the header. If null or length is less than rowLabelCount DEFAULT_ROW_SIZE will be used.
rowLevelCount - The number of rows (levels) in the secondary, short, dimension.
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

getRowLevelCount

public int getRowLevelCount()
Returns the number of rows (levels) in the secondary, short, dimension.

Returns:
The number of rows (levels) in the secondary, short, dimension.

setRowLevelCount

public void setRowLevelCount(int count)
Sets the number of rows (levels) in the secondary, short, dimension.

Parameters:
count - The number of rows (levels) in the secondary, short, dimension.

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.

setSizes

public void setSizes(int[] sizes)
Sets the absolute sizes of the individualt rows in the header. If null or length is less than rowLabelCount 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.

revalidateGrid

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


getHeaderGrid

public HeaderGrid getHeaderGrid()
Description copied from class: AbstractGridHeader
Returns the grid that this header uses for layout

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

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.


addDateChangeListener

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

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.
l - The listener

removeDateChangeListener

public void removeDateChangeListener(javax.swing.event.ChangeListener l)
Removes a listener

Parameters:
l - the listener

fireDateChangeEvent

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



Copyright © 2009 MiG InfoCom AB. All Rights Reserved.