swingx
Version 2005-08-19

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


Field Summary
protected static SimpleDateFormat dayOfMonthFormatter
          Formatter used to format the day of the week to a numerical value.
protected  long firstDisplayedDate
           
protected  int firstDisplayedMonth
           
protected  int firstDisplayedYear
           
protected  long lastDisplayedDate
           
protected  JXMonthView monthView
           
protected  DateSpan selection
           
protected  long today
           
 
Constructor Summary
BasicMonthViewUI()
           
 
Method Summary
 long calculateLastDisplayedDate()
          Calculate the last possible date that can be displayed.
protected  LayoutManager createLayoutManager()
           
protected  MouseListener createMouseListener()
           
protected  MouseMotionListener createMouseMotionListener()
           
protected  PropertyChangeListener createPropertyChangeListener()
           
static ComponentUI createUI(JComponent c)
           
 long getDayAt(int x, int y)
          Return a long representing the date at the specified x/y position.
protected  int getDayOfTheWeek()
          Convenience method so subclasses can get the currently painted day's day of the week.
protected  int getTraversableButtonAt(int x, int y)
          Returns an index defining which, if any, of the buttons for traversing the month was pressed.
protected  void installComponents()
           
protected  void installDefaults()
           
protected  void installKeyboardActions()
           
protected  void installListeners()
           
 void installUI(JComponent c)
           
protected  boolean isToday(long date)
          Returns true if the date passed in is the same as today.
 boolean isUsingKeyboard()
           
 void paint(Graphics g, JComponent c)
           
protected  void paintDayBackground(Graphics g, int x, int y, int width, int height, long date)
          Paint the background for the specified day.
protected  void paintDayForeground(Graphics g, int x, int y, int width, int height, long date)
          Paint the foreground for the specified day.
protected  void paintFlaggedDayBackground(Graphics g, int x, int y, int width, int height, long date)
          Paint the background for the specified flagged day.
protected  void paintFlaggedDayForeground(Graphics g, int x, int y, int width, int height, long date)
          Paint the foreground for the specified flagged day.
protected  void paintMonthStringBackground(Graphics g, int x, int y, int width, int height)
          Paints the background of the month string.
 void setUsingKeyboard(boolean val)
           
protected  void uninstallComponents()
           
protected  void uninstallDefaults()
           
protected  void uninstallKeyboardActions()
           
protected  void uninstallListeners()
           
 void uninstallUI(JComponent c)
           
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dayOfMonthFormatter

protected static final SimpleDateFormat dayOfMonthFormatter
Formatter used to format the day of the week to a numerical value.


monthView

protected JXMonthView monthView

firstDisplayedDate

protected long firstDisplayedDate

firstDisplayedMonth

protected int firstDisplayedMonth

firstDisplayedYear

protected int firstDisplayedYear

lastDisplayedDate

protected long lastDisplayedDate

today

protected long today

selection

protected DateSpan selection
Constructor Detail

BasicMonthViewUI

public BasicMonthViewUI()
Method Detail

createUI

public static ComponentUI createUI(JComponent c)

installUI

public void installUI(JComponent c)
Overrides:
installUI in class ComponentUI

uninstallUI

public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI

installComponents

protected void installComponents()

uninstallComponents

protected void uninstallComponents()

installDefaults

protected void installDefaults()

uninstallDefaults

protected void uninstallDefaults()

installKeyboardActions

protected void installKeyboardActions()

uninstallKeyboardActions

protected void uninstallKeyboardActions()

installListeners

protected void installListeners()

uninstallListeners

protected void uninstallListeners()

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()

createLayoutManager

protected LayoutManager createLayoutManager()

createMouseListener

protected MouseListener createMouseListener()

createMouseMotionListener

protected MouseMotionListener createMouseMotionListener()

isUsingKeyboard

public boolean isUsingKeyboard()

setUsingKeyboard

public void setUsingKeyboard(boolean val)

isToday

protected boolean isToday(long date)
Returns true if the date passed in is the same as today.

Parameters:
date - long representing the date you want to compare to today.
Returns:
true if the date passed is the same as today.

getDayAt

public long getDayAt(int x,
                     int y)
Description copied from class: MonthViewUI
Return a long representing the date at the specified x/y position. It is expected that the date returned will have a valid day, month and year. All other fields such as hour, minute, second and milli- second will be set to 0.

Specified by:
getDayAt in class MonthViewUI
Parameters:
x - X position
y - Y position
Returns:
long The date, -1 if position does not contain a date.

getDayOfTheWeek

protected int getDayOfTheWeek()
Convenience method so subclasses can get the currently painted day's day of the week. It is assumed the calendar, _cal, is already set to the correct day.

Returns:
day of the week (Calendar.SATURDAY, Calendar.SUNDAY, ...)
See Also:
Calendar

getTraversableButtonAt

protected int getTraversableButtonAt(int x,
                                     int y)
Returns an index defining which, if any, of the buttons for traversing the month was pressed. This method should only be called when setTraversable is set to true.

Parameters:
x - x position of the pointer
y - y position of the pointer
Returns:
MONTH_UP, MONTH_DOWN or -1 when no button is selected.

calculateLastDisplayedDate

public long calculateLastDisplayedDate()
Description copied from class: MonthViewUI
Calculate 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.

Specified by:
calculateLastDisplayedDate in class MonthViewUI
Returns:
long The date.

paint

public void paint(Graphics g,
                  JComponent c)
Overrides:
paint in class ComponentUI

paintMonthStringBackground

protected void paintMonthStringBackground(Graphics g,
                                          int x,
                                          int y,
                                          int width,
                                          int height)
Paints the background of the month string. The bounding box for this background can be modified by setting its insets via setMonthStringInsets. The color of the background can be set via setMonthStringBackground.

Parameters:
g - Graphics object to paint to.
x - x-coordinate of upper left corner.
y - y-coordinate of upper left corner.
width - width of the bounding box.
height - height of the bounding box.
See Also:
JXMonthView.setMonthStringBackground(java.awt.Color), JXMonthView.setMonthStringInsets(java.awt.Insets)

paintDayBackground

protected void paintDayBackground(Graphics g,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  long date)
Paint the background for the specified day.

Parameters:
g - Graphics object to paint to
x - x-coordinate of upper left corner
y - y-coordinate of upper left corner
width - width of bounding box for the day
height - height of bounding box for the day
date - long value representing the day being painted
See Also:
JXMonthView.isSelectedDate(long), isToday(long)

paintDayForeground

protected void paintDayForeground(Graphics g,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  long date)
Paint the foreground for the specified day.

Parameters:
g - Graphics object to paint to
x - x-coordinate of upper left corner
y - y-coordinate of upper left corner
width - width of bounding box for the day
height - height of bounding box for the day
date - long value representing the day being painted

paintFlaggedDayBackground

protected void paintFlaggedDayBackground(Graphics g,
                                         int x,
                                         int y,
                                         int width,
                                         int height,
                                         long date)
Paint the background for the specified flagged day. The default implementation just calls paintDayBackground.

Parameters:
g - Graphics object to paint to
x - x-coordinate of upper left corner
y - y-coordinate of upper left corner
width - width of bounding box for the day
height - height of bounding box for the day
date - long value representing the flagged day being painted

paintFlaggedDayForeground

protected void paintFlaggedDayForeground(Graphics g,
                                         int x,
                                         int y,
                                         int width,
                                         int height,
                                         long date)
Paint the foreground for the specified flagged day.

Parameters:
g - Graphics object to paint to
x - x-coordinate of upper left corner
y - y-coordinate of upper left corner
width - width of bounding box for the day
height - height of bounding box for the day
date - long value representing the flagged day being painted

swingx
Version 2005-08-19