org.formaria.swing.date
Class YearPlanner

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.formaria.swing.Panel
                      extended by org.formaria.swing.date.YearPlanner
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, PersistentState

public class YearPlanner
extends Panel
implements java.awt.event.KeyListener

A year planner - renders a calendar as an editable table where dates can be annotated as a diary.

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.29 $

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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 DIARY_VIEW
           
protected  int highlightedDay
           
static int MAX_PLAN_DAYS
           
static int PLANNER_VIEW
           
protected  int selectedDay
           
protected  StyleManager styleManager
           
protected  java.lang.String[] styles
           
 
Fields inherited from class org.formaria.swing.Panel
arc, BORDER_BEVEL, BORDER_FLAT, BORDER_NONE, drawBorder, padding, translucent, usesLaf
 
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
YearPlanner()
           
 
Method Summary
 void addNotify()
          Repaint the component once it has been created
 java.util.Date getDate()
          Gets the current date.
 boolean getDayNames()
          Get the style of the 3D elements including the navigation buttons
 java.lang.String getFormat()
          Get the format of the edit field.
 java.lang.String getHeaderStyle()
          Get the style of the header.
 java.lang.String getHighlightStyle()
          Get the style of the highlighted date.
 java.lang.String getSelectedStyle()
          Get the style of the selected date.
 java.lang.String getStyle()
          Get the style asociated with the normal elements
 java.lang.String getStyleHighlighted()
          Get the style asociated with the highlighted element
 java.lang.String getStyleSelected()
          Get the style asociated with the selected elements
 java.lang.String getStyleWeekend()
          Get the style asociated with the weekend element
 java.lang.String getText()
           
 java.lang.String getThreeDStyle()
          Get the style of the 3D elements including the navigation buttons
 java.lang.String getWeekendStyle()
          Get the style of the weekend elements.
 void init()
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void nextYear()
          Move to the next year
 void prevYear()
          Move to the previous year
 int setAttribute(java.lang.String attribName, java.lang.Object attribValue)
          Set one or more attributes of the component.
 void setDate(java.util.Date newDate)
          Sets the current date
 void setDateFormat(java.lang.String dateFormat)
          Set the date format string
 void setDayNames(boolean show)
          Set the style of the 3D elements including the navigation buttons
 void setFormat(java.lang.String format)
          Set the format of the edit field.
 void setHeaderStyle(java.lang.String styleName)
          Set the style of the header.
 void setHighlightStyle(java.lang.String styleName)
          Set the style of the highlighted date.
 void setSelectedStyle(java.lang.String styleName)
          Set the style of the selected date.
 void setSelectionMode(java.lang.String mode)
          Set the display mode
 void setShowDayNames(boolean state)
          Show or hide the day names
 void setStyle(java.lang.String newStyle)
          set the style asociated with the normal elements
 void setStyleHighlighted(java.lang.String newStyle)
          set the style asociated with highlighted element
 void setStyles(java.lang.String[] styles)
          Set the styles for the date panel
 void setStyleSelected(java.lang.String newStyle)
          Get the style asociated with the selected elements
 void setStyleWeekend(java.lang.String newStyle)
          set the style asociated with weekend element
 void setText(java.lang.String s)
           
 void setThreeDStyle(java.lang.String styleName)
          Set the style of the 3D elements including the navigation buttons
 void setViewMode(java.lang.String mode)
          Set the display mode
 void setWeekendStyle(java.lang.String styleName)
          Set the style of the weekend elements.
 void showNavItems(boolean bShow)
          Show the navigation header items
 
Methods inherited from class org.formaria.swing.Panel
getArc, getDrawBorder, getInsets, getPainter, getPreferredSize, getUsesLaf, paintComponent, restoreState, saveState, setArc, setBlend, setBorder, setBounds, setDrawBorder, setImageName, setPad, setPainter, setSwingBorder, setTitle, setTitlePos, setTitlePosition, setTitleStyle, setToolTip, setTranslucent, setUsesLaf, update
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, processEvent, 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, 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

DIARY_VIEW

public static final int DIARY_VIEW
See Also:
Constant Field Values

PLANNER_VIEW

public static final int PLANNER_VIEW
See Also:
Constant Field Values

MAX_PLAN_DAYS

public static final int MAX_PLAN_DAYS
See Also:
Constant Field Values

styleManager

protected StyleManager styleManager

styles

protected java.lang.String[] styles

selectedDay

protected int selectedDay

highlightedDay

protected int highlightedDay
Constructor Detail

YearPlanner

public YearPlanner()
Method Detail

init

public void init()

addNotify

public void addNotify()
Description copied from class: Panel
Repaint the component once it has been created

Overrides:
addNotify in class Panel

showNavItems

public void showNavItems(boolean bShow)
Show the navigation header items

Parameters:
bShow - true to show the navigation items

setDateFormat

public void setDateFormat(java.lang.String dateFormat)
Set the date format string

Parameters:
dateFormat -

setViewMode

public void setViewMode(java.lang.String mode)
Set the display mode

Parameters:
mode - diary or oher

setSelectionMode

public void setSelectionMode(java.lang.String mode)
Set the display mode

Parameters:
mode - "multiple" or "single"

setAttribute

public int setAttribute(java.lang.String attribName,
                        java.lang.Object attribValue)
Set one or more attributes of the component. Currently this handles the attributes
  1. view (month|day) or
  2. format, value=the date format
  3. style, value=the default style
  4. selectedStyle, value=the selected date's style
  5. weekendStyle, value=the weekend date style
  6. highlightStyle, value=the rollover/highlighted date style
  7. headerStyle, value=the header style
  8. threeDStyle, value=the 3d element style
  9. daynames, value=true to show the day names
  10. header, value=true to show the date navigation headers
  11. selectionmode, value=multiple for multiple selection ranges, single=a single selection range, singleSelection for a single item/row selection

Parameters:
attribName - the attribute name
attribValue - the attribute value
Returns:
0 for success, non zero otherwise

getDate

public java.util.Date getDate()
Gets the current date.

Returns:

setDate

public void setDate(java.util.Date newDate)
Sets the current date

Parameters:
newDate - the new date

prevYear

public void prevYear()
Move to the previous year


nextYear

public void nextYear()
Move to the next year


getStyleSelected

public java.lang.String getStyleSelected()
Get the style asociated with the selected elements

Returns:
the style name

setStyleSelected

public void setStyleSelected(java.lang.String newStyle)
Get the style asociated with the selected elements

Parameters:
newStyle - the style name

getStyleWeekend

public java.lang.String getStyleWeekend()
Get the style asociated with the weekend element

Returns:
the style name

setStyleWeekend

public void setStyleWeekend(java.lang.String newStyle)
set the style asociated with weekend element

Parameters:
newStyle - the style name

getStyleHighlighted

public java.lang.String getStyleHighlighted()
Get the style asociated with the highlighted element

Returns:
the style name

setStyleHighlighted

public void setStyleHighlighted(java.lang.String newStyle)
set the style asociated with highlighted element

Parameters:
newStyle - the style name

getStyle

public java.lang.String getStyle()
Get the style asociated with the normal elements

Returns:
the style name

setStyle

public void setStyle(java.lang.String newStyle)
set the style asociated with the normal elements

Parameters:
newStyle - the style name

setStyles

public void setStyles(java.lang.String[] styles)
Set the styles for the date panel

Parameters:
styles - the styles in the following order: style, selectedStyle, weekendStyle, highlightStyle, headerStyle, threeDStyle

setShowDayNames

public void setShowDayNames(boolean state)
Show or hide the day names

Parameters:
state - true to show the day names

setWeekendStyle

public void setWeekendStyle(java.lang.String styleName)
Set the style of the weekend elements. The weekend elements are the dates that fall on weekends (Saturday and Sunday). This style allowes those dates to be shown in an alternative styles, typically with a grayed out or less saturated/right background color.

Parameters:
styleName - the style name for the weekend dates

setSelectedStyle

public void setSelectedStyle(java.lang.String styleName)
Set the style of the selected date. The selected date is chosen by clicking on a date. It is shown in the specified style even if the curosr is moved.

Parameters:
styleName - the style name for the selected date

setHighlightStyle

public void setHighlightStyle(java.lang.String styleName)
Set the style of the highlighted date. The highlighted date is is the date shown below the curose. Setting this style provides user feedback when the mouse moves.

Parameters:
styleName - the style name for the highlighted date

setHeaderStyle

public void setHeaderStyle(java.lang.String styleName)
Set the style of the header. The header shows the month, year and the navigation buttons. It is painted with a gradient

Parameters:
styleName - the style name for the highlighted date

setThreeDStyle

public void setThreeDStyle(java.lang.String styleName)
Set the style of the 3D elements including the navigation buttons

Parameters:
styleName - the style name for the highlighted date

setFormat

public void setFormat(java.lang.String format)
Set the format of the edit field. The format is used in the construction of a java.text.SimpleDateFormat instance.

Parameters:
format - the new date format

setDayNames

public void setDayNames(boolean show)
Set the style of the 3D elements including the navigation buttons

Parameters:
styleName - the style name for the highlighted date

getWeekendStyle

public java.lang.String getWeekendStyle()
Get the style of the weekend elements. The weekend elements are the dates that fall on weekends (Saturday and Sunday). This style allowes those dates to be shown in an alternative styles, typically with a grayed out or less saturated/right background color.

Returns:
the style name for the weekend dates

getSelectedStyle

public java.lang.String getSelectedStyle()
Get the style of the selected date. The selected date is chosen by clicking on a date. It is shown in the specified style even if the curosr is moved.

Returns:
the style name for the selected date

getHighlightStyle

public java.lang.String getHighlightStyle()
Get the style of the highlighted date. The highlighted date is is the date shown below the curose. Setting this style provides user feedback when the mouse moves.

Returns:
the style name for the highlighted date

getHeaderStyle

public java.lang.String getHeaderStyle()
Get the style of the header. The header shows the month, year and the navigation buttons. It is painted with a gradient

Returns:
the style name for the highlighted date

getThreeDStyle

public java.lang.String getThreeDStyle()
Get the style of the 3D elements including the navigation buttons

Returns:
the style name for the highlighted date

getFormat

public java.lang.String getFormat()
Get the format of the edit field. The format is used in the construction of a java.text.SimpleDateFormat instance.

Returns:
the new date format

getDayNames

public boolean getDayNames()
Get the style of the 3D elements including the navigation buttons

Returns:
the style name for the highlighted date

setText

public void setText(java.lang.String s)

getText

public java.lang.String getText()

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener