ilog.views.util.swing.calendar.plaf
Class BasicCalendarPanelUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by ilog.views.util.swing.calendar.plaf.CalendarPanelUI
          extended by ilog.views.util.swing.calendar.plaf.BasicCalendarPanelUI

public class BasicCalendarPanelUI
extends CalendarPanelUI

This class is the basic UI delegate implementation for IlvJCalendarPanel components.

Since:
JViews 5.5

Nested Class Summary
 class BasicCalendarPanelUI.CalendarModelHandler
          The CalendarModelListener that is added to the calendar panel's model as needed.
 class BasicCalendarPanelUI.FocusHandler
          The focus listener that is added to the calendar panel at installUI(javax.swing.JComponent) time.
 class BasicCalendarPanelUI.MouseHandler
          The mouse input listener that is added to the calendar panel at installUI(javax.swing.JComponent) time.
 class BasicCalendarPanelUI.PropertyChangeHandler
          The PropertyChangeListener that is added to the calendar panel at installUI(javax.swing.JComponent) time.
static class BasicCalendarPanelUI.SelectionBorder
          SelectionBorder is the default border for selected day cells in an IlvJCalendarPanel.
 
Field Summary
protected  IlvJCalendarPanel calendarPanel
          The IlvJCalendarPanel that we're a UI delegate for.
protected  FocusListener focusListener
          The listener for focus changes to the calendar panel.
protected  CalendarModelListener modelListener
          The listener for changes to the calendar data model.
protected  MouseInputListener mouseListener
          The listener for mouse input events.
protected  PropertyChangeListener propertyChangeListener
          The listener for property changes to the calendar panel.
protected  CellRendererPane rendererPane
          The intermediate container between the calendar panel and its renderers.
 
Constructor Summary
BasicCalendarPanelUI()
          Creates a new BasicCalendarPanelUI delegate.
 
Method Summary
protected  CalendarModelListener createCalendarModelListener()
          Creates an instance of BasicCalendarPanelUI.CalendarModelHandler that is added to the calendar panel's model as needed.
protected  FocusListener createFocusListener()
          Creates an instance of BasicCalendarPanelUI.FocusHandler that is added to the calendar panel by installUI(javax.swing.JComponent).
protected  MouseInputListener createMouseListener()
          Creates an instance of BasicCalendarPanelUI.MouseHandler that is added to the calendar panel by installUI(javax.swing.JComponent).
protected  PropertyChangeListener createPropertyChangeListener()
          Creates an instance of BasicCalendarPanelUI.PropertyChangeHandler that is added to the calendar panel by installUI(javax.swing.JComponent).
static ComponentUI createUI(JComponent c)
          Returns a new instance of BasicCalendarPanelUI.
 Calendar getCellDate(IlvJCalendarPanel calendarPanel, int row, int column)
          Returns the date displayed in the day cell that lies at the intersection of the specified week row and day-of-week column.
 Rectangle getCellRect(IlvJCalendarPanel calendarPanel, int row, int column)
          Returns a rectangle for the day cell that lies at the intersection of the specified week row and day-of-week column.
 int getColumnAtPoint(IlvJCalendarPanel calendarPanel, Point point)
          Returns the index of the day-of-week column that point lies in.
 int getColumnCount(IlvJCalendarPanel calendarPanel)
          Returns the number of day-of-week columns in the specified calendar panel.
 int getColumnWidth(IlvJCalendarPanel calendarPanel)
          Returns the width of the day-of-week columns in the specified calendar panel.
protected  Calendar getFirstDayOfMonth()
          Returns the first day of the month displayed by the calendar panel.
protected  Calendar getFirstDayOfPanel()
          Returns the date displayed in the first day cell of the calendar panel.
 Dimension getMaximumSize(JComponent c)
          Returns the maximum size of the calendar panel.
 Dimension getMinimumSize(JComponent c)
          Returns the minimum size of the calendar panel.
 Dimension getPreferredSize(JComponent c)
          Returns the preferred size of the calendar panel.
 int getRowAtPoint(IlvJCalendarPanel calendarPanel, Point point)
          Returns the index of the week row that point lies in.
 int getRowCount(IlvJCalendarPanel calendarPanel)
          Returns the number of week rows in the specified calendar panel.
 int getRowHeight(IlvJCalendarPanel calendarPanel)
          Returns the height of the week rows in the specified calendar panel.
protected  void installDefaults()
          Initializes the calendar panel properties.
protected  void installListeners()
          Creates and installs the listeners for the calendar panel and its model.
 void installUI(JComponent c)
          Configures the specified calendar panel for the look and feel.
 void paint(Graphics g, JComponent c)
          Paints a representation of the calendar panel.
protected  void paintCell(Graphics g, Rectangle cellRect, int row, int column, IlvCalendarCellRenderer cellRenderer, Calendar calendar, boolean prevMonth, boolean nextMonth, boolean selected)
          Paints one day cell of the calendar panel.
protected  void paintHeader(Graphics g, Rectangle cellRect, int column, IlvCalendarHeaderRenderer headerRenderer, Calendar calendar)
          Paints one cell of the day-of-week column header.
protected  void resizeAndRepaint()
          Resizes the calendar panel and marks it as needing display.
protected  void uninstallDefaults()
          Reverses the configuration of the calendar panel that was performed during installDefaults().
protected  void uninstallListeners()
          Removes the listeners for the calendar panel and its model.
 void uninstallUI(JComponent c)
          Reverses the configuration that was done on the specified calendar panel during installUI(javax.swing.JComponent).
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

calendarPanel

protected IlvJCalendarPanel calendarPanel
The IlvJCalendarPanel that we're a UI delegate for. Initialized by the installUI(javax.swing.JComponent) method, and reset to null by uninstallUI(javax.swing.JComponent).


rendererPane

protected CellRendererPane rendererPane
The intermediate container between the calendar panel and its renderers.


propertyChangeListener

protected PropertyChangeListener propertyChangeListener
The listener for property changes to the calendar panel.


modelListener

protected CalendarModelListener modelListener
The listener for changes to the calendar data model.


focusListener

protected FocusListener focusListener
The listener for focus changes to the calendar panel.


mouseListener

protected MouseInputListener mouseListener
The listener for mouse input events.

Constructor Detail

BasicCalendarPanelUI

public BasicCalendarPanelUI()
Creates a new BasicCalendarPanelUI delegate.

Method Detail

createUI

public static ComponentUI createUI(JComponent c)
Returns a new instance of BasicCalendarPanelUI. UI delegates are allocated one per IlvJCalendarPanel.

Parameters:
c - The IlvJCalendarPanel.
Returns:
A new BasicCalendarPanelUI object.

installUI

public void installUI(JComponent c)
Configures the specified calendar panel for the look and feel.

Overrides:
installUI in class ComponentUI
Parameters:
c - The IlvJCalendarPanel where this UI delegate is being installed.
See Also:
uninstallUI(javax.swing.JComponent)

uninstallUI

public void uninstallUI(JComponent c)
Reverses the configuration that was done on the specified calendar panel during installUI(javax.swing.JComponent).

Overrides:
uninstallUI in class ComponentUI
Parameters:
c - The IlvJCalendarPanel from which this UI delegate is being removed.

installDefaults

protected void installDefaults()
Initializes the calendar panel properties.

See Also:
uninstallDefaults(), installUI(javax.swing.JComponent)

uninstallDefaults

protected void uninstallDefaults()
Reverses the configuration of the calendar panel that was performed during installDefaults().


installListeners

protected void installListeners()
Creates and installs the listeners for the calendar panel and its model. This method is called at installUI(javax.swing.JComponent) time.

See Also:
uninstallListeners()

uninstallListeners

protected void uninstallListeners()
Removes the listeners for the calendar panel and its model. This method is called at uninstallUI(javax.swing.JComponent) time.

See Also:
installListeners()

createFocusListener

protected FocusListener createFocusListener()
Creates an instance of BasicCalendarPanelUI.FocusHandler that is added to the calendar panel by installUI(javax.swing.JComponent).


createMouseListener

protected MouseInputListener createMouseListener()
Creates an instance of BasicCalendarPanelUI.MouseHandler that is added to the calendar panel by installUI(javax.swing.JComponent).


createCalendarModelListener

protected CalendarModelListener createCalendarModelListener()
Creates an instance of BasicCalendarPanelUI.CalendarModelHandler that is added to the calendar panel's model as needed.


createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()
Creates an instance of BasicCalendarPanelUI.PropertyChangeHandler that is added to the calendar panel by installUI(javax.swing.JComponent).


getRowCount

public int getRowCount(IlvJCalendarPanel calendarPanel)
Returns the number of week rows in the specified calendar panel. This implementation returns 6.

Specified by:
getRowCount in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel.
Returns:
The number of week rows.

getColumnCount

public int getColumnCount(IlvJCalendarPanel calendarPanel)
Returns the number of day-of-week columns in the specified calendar panel.

Specified by:
getColumnCount in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel. This implementation returns 7.
Returns:
The number of day-of-week columns.

getRowHeight

public int getRowHeight(IlvJCalendarPanel calendarPanel)
Returns the height of the week rows in the specified calendar panel.

Specified by:
getRowHeight in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel.
Returns:
The height of a week row, in pixels.

getColumnWidth

public int getColumnWidth(IlvJCalendarPanel calendarPanel)
Returns the width of the day-of-week columns in the specified calendar panel.

Specified by:
getColumnWidth in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel.
Returns:
The width of a day-of-week column, in pixels.

getCellRect

public Rectangle getCellRect(IlvJCalendarPanel calendarPanel,
                             int row,
                             int column)
Returns a rectangle for the day cell that lies at the intersection of the specified week row and day-of-week column. A value of -1 can be specified for the row to indicate the days-of-week header. If the specified cell coordinates are out of range, then null is returned.

Specified by:
getCellRect in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel.
row - The week row, or -1 to indicate the days-of-week header.
column - The day-of-week column.
Returns:
The rectangle of the day cell.

getRowAtPoint

public int getRowAtPoint(IlvJCalendarPanel calendarPanel,
                         Point point)
Returns the index of the week row that point lies in. This method returns -1 if the point lies in the days-of-week header. Otherwise, this method returns -2 if the result is not in the range [0, getRowCount(ilog.views.util.swing.calendar.IlvJCalendarPanel)-1].

Specified by:
getRowAtPoint in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel.
point - The location of interest.
Returns:
The index of the week row that point lies in, or -1 if point lies in the days-of-week header, or -2 if the result is not in the range [0, getRowCount(ilog.views.util.swing.calendar.IlvJCalendarPanel)-1].
See Also:
getColumnAtPoint(ilog.views.util.swing.calendar.IlvJCalendarPanel, java.awt.Point)

getColumnAtPoint

public int getColumnAtPoint(IlvJCalendarPanel calendarPanel,
                            Point point)
Returns the index of the day-of-week column that point lies in. This method returns -1 if the point is not in the range [0, getColumnCount(ilog.views.util.swing.calendar.IlvJCalendarPanel)-1].

Specified by:
getColumnAtPoint in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel.
point - The location of interest.
Returns:
The index of the day-of-week column that point lies in, or -1 if the result is not in the range [0, getColumnCount(ilog.views.util.swing.calendar.IlvJCalendarPanel)-1].
See Also:
getRowAtPoint(ilog.views.util.swing.calendar.IlvJCalendarPanel, java.awt.Point)

getPreferredSize

public Dimension getPreferredSize(JComponent c)
Returns the preferred size of the calendar panel.

Overrides:
getPreferredSize in class ComponentUI

getMinimumSize

public Dimension getMinimumSize(JComponent c)
Returns the minimum size of the calendar panel.

Overrides:
getMinimumSize in class ComponentUI

getMaximumSize

public Dimension getMaximumSize(JComponent c)
Returns the maximum size of the calendar panel.

Overrides:
getMaximumSize in class ComponentUI

getFirstDayOfMonth

protected final Calendar getFirstDayOfMonth()
Returns the first day of the month displayed by the calendar panel.

Returns:
The first day of the calendar month.

getFirstDayOfPanel

protected final Calendar getFirstDayOfPanel()
Returns the date displayed in the first day cell of the calendar panel.

Returns:
The date displayed in the first day cell.

getCellDate

public Calendar getCellDate(IlvJCalendarPanel calendarPanel,
                            int row,
                            int column)
Returns the date displayed in the day cell that lies at the intersection of the specified week row and day-of-week column. If the specified cell coordinates are out of range, then null is returned.

Specified by:
getCellDate in class CalendarPanelUI
Parameters:
calendarPanel - The calendar panel.
row - The week row.
column - The day-of-week column.
Returns:
The date displayed in the day cell.

resizeAndRepaint

protected void resizeAndRepaint()
Resizes the calendar panel and marks it as needing display. This method is equivalent to invoking revalidate followed by repaint on the calendar panel.


paint

public void paint(Graphics g,
                  JComponent c)
Paints a representation of the calendar panel.

Overrides:
paint in class ComponentUI
Parameters:
g - The paint graphics.
c - The IlvJCalendarPanel.

paintHeader

protected void paintHeader(Graphics g,
                           Rectangle cellRect,
                           int column,
                           IlvCalendarHeaderRenderer headerRenderer,
                           Calendar calendar)
Paints one cell of the day-of-week column header. This method obtains the "rubber stamp" header renderer component and then uses the CellRendererPane to paint it.

Parameters:
g - The paint graphics.
cellRect - The bounds of the header cell.
column - The column index of the day-of-week header cell being drawn.
headerRenderer - The day-of-week column header renderer.
calendar - The calendar value of the day-of-week column.

paintCell

protected void paintCell(Graphics g,
                         Rectangle cellRect,
                         int row,
                         int column,
                         IlvCalendarCellRenderer cellRenderer,
                         Calendar calendar,
                         boolean prevMonth,
                         boolean nextMonth,
                         boolean selected)
Paints one day cell of the calendar panel. This method obtains the "rubber stamp" cell renderer component and then uses the CellRendererPane to paint it.

Parameters:
g - The paint graphics.
cellRect - The bounds of the day cell.
row - The row index of the cell being drawn.
column - The column index of the cell being drawn.
cellRenderer - The day cell renderer.
calendar - The calendar value of the cell.
prevMonth - Indicates if the cell is in the month prior to the current month displayed by the calendar panel.
nextMonth - Indicates if the cell is in the month after the current month displayed by the calendar panel.
selected - Indicates if the cell is selected.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.