org.jdesktop.swingx.plaf.basic
Class BasicMonthViewUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.jdesktop.swingx.plaf.MonthViewUI
          extended by org.jdesktop.swingx.plaf.basic.BasicMonthViewUI

public class BasicMonthViewUI
extends MonthViewUI

Base implementation of the JXMonthView UI.

Note: The api changed considerably between releases 0.9.4 and 0.9.5.

The general drift of the change was to delegate all text rendering to a dedicated rendering controller (currently named RenderingHandler), similar to the collection view rendering. The UI itself keeps layout and positioning of the rendering components. Plus updating on property changes received from the monthView.

Painting: coordinate systems.

On the road to "zoomable" date range views (Vista-style).

Added support (doesn't do anything yet, zoom-logic must yet be defined) by way of an active calendar header which is added to the monthView if zoomable. It is disabled by default. In this mode, the view is always traversable and shows exactly one calendar. It is orthogonal to the classic mode, that is client code should not be effected in any way as long as the mode is not explicitly enabled.

NOTE to LAF implementors: the active calendar header is very, very, very raw and sure to change without much notice. Better not yet to support it right now.

Author:
dmouse, rbair, rah003, Jeanette Winzenburg

Field Summary
static int MONTH_DOWN
          Return value used to identify when the month down button is pressed.
static int MONTH_UP
          Return value used to identify when the month up button is pressed.
 
Constructor Summary
BasicMonthViewUI()
           
 
Method Summary
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
           
 java.util.Date getDayAtLocation(int x, int y)
          Returns the Date at the given location.
 java.lang.String[] getDaysOfTheWeek()
          Returns an array of String to use as names for the days of the week.
 java.util.Date getLastDisplayedDay()
          Returns the last possible date that can be displayed.
 void installUI(javax.swing.JComponent c)
          Installs the component as appropriate for the current lf.
 boolean isUsingKeyboard()
           
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
          
 void setUsingKeyboard(boolean val)
           
 void uninstallUI(javax.swing.JComponent c)
           
 void update(java.awt.Graphics g, javax.swing.JComponent c)
          Overridden to extract the background painting for ease-of-use of subclasses.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MONTH_DOWN

public static final int MONTH_DOWN
Return value used to identify when the month down button is pressed.

See Also:
Constant Field Values

MONTH_UP

public static final int MONTH_UP
Return value used to identify when the month up button is pressed.

See Also:
Constant Field Values
Constructor Detail

BasicMonthViewUI

public BasicMonthViewUI()
Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)

installUI

public void installUI(javax.swing.JComponent c)
Installs the component as appropriate for the current lf. PENDING JW: clarify sequence of installXX methods.

Overrides:
installUI in class javax.swing.plaf.ComponentUI

uninstallUI

public void uninstallUI(javax.swing.JComponent c)
Overrides:
uninstallUI in class javax.swing.plaf.ComponentUI

getDaysOfTheWeek

public java.lang.String[] getDaysOfTheWeek()
Description copied from class: MonthViewUI
Returns an array of String to use as names for the days of the week.

Specified by:
getDaysOfTheWeek in class MonthViewUI
Returns:
array of names for the days of the week.

isUsingKeyboard

public boolean isUsingKeyboard()

setUsingKeyboard

public void setUsingKeyboard(boolean val)

getDayAtLocation

public java.util.Date getDayAtLocation(int x,
                                       int y)
Returns the Date at the given location. May be null if the coordinates don't map to a day in the month which contains the coordinates. Specifically: hitting leading/trailing dates returns null. Mapping pixel to calendar day.

Specified by:
getDayAtLocation in class MonthViewUI
Parameters:
x - the x position of the location in pixel
y - the y position of the location in pixel
Returns:
the day at the given location or null if the location doesn't map to a day in the month which contains the coordinates.
See Also:
getDayBounds(Date)

update

public void update(java.awt.Graphics g,
                   javax.swing.JComponent c)
Overridden to extract the background painting for ease-of-use of subclasses.

Overrides:
update in class javax.swing.plaf.ComponentUI

paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent c)

Overrides:
paint in class javax.swing.plaf.ComponentUI

getLastDisplayedDay

public java.util.Date getLastDisplayedDay()
Returns the last possible date that can be displayed. This is implemented by the UI since it is in control of layout and may possibly yeild different results based on implementation.

It's up to the UI to keep this property, based on internal state and the firstDisplayed as controlled by the JXMonthView.

Specified by:
getLastDisplayedDay in class MonthViewUI
Returns:
Date The date.