net.sf.nachocalendar.components

Class CalendarPanel

Implemented Interfaces:
ChangeListener

public class CalendarPanel
extends JPanel
implements ChangeListener

Panel used to show many months at once.
Author:
Ignacio Merani

Field Summary

static int
DOWN
Down Position.
static int
HORIZONTAL
Horizontal orientation.
static int
LEFT
Left Position.
static int
RIGHT
Right Position.
static int
UP
Up Position.
static int
VERTICAL
Vertical orientation.
protected boolean
eternalScroll

Constructor Summary

CalendarPanel()
Default constructor, constructs a vertical panel with 3 months.
CalendarPanel(boolean showWeekNumbers)
Constructrs a panel with 3 months, Vertical.
CalendarPanel(int quantity)
Constructs a panel with 3 months and the provided orientation.
CalendarPanel(int quantity, int orientation)
Constructs a panel with the provided quantity and orientation.
CalendarPanel(int quantity, int orientation, boolean showWeekNumber)
CalendarPanel(int quantity, int orientation, boolean showWeekNumber, boolean eternalScroll)
Creates a new instance of CalendarPanel.

Method Summary

void
addChangeListener(ChangeListener listener)
Registers ChangeListener to receive events.
void
addKeyListener(KeyListener listener)
Registers KeyListener to receive events.
Date
getDate()
Getter for property date.
DateSelectionModel
getDateSelectionModel()
int
getFirstDayOfWeek()
Getter for property firstDayOfWeek.
HeaderRenderer
getHeaderRenderer()
Getter for property headerRenderer.
int
getMinimalDaysInFirstWeek()
DataModel
getModel()
Getter for property model.
int
getOrientation()
Getter for property orientation.
int
getQuantity()
Getter for property quantity.
DayRenderer
getRenderer()
Getter for property renderer.
int
getScrollPosition()
Getter for property scrollPosition.
int
getSelectionMode()
Object
getValue()
Returns the selected date.
Object[]
getValues()
Return the selected dates as an Array.
boolean[]
getWorkingdays()
Getter for property workingdays.
int
getYearPosition()
Getter for property yearPosition.
boolean
isAntiAliased()
boolean
isEnabled()
Getter for enabled property
boolean
isEternalScroll()
boolean
isPrintMoon()
boolean
isShowToday()
void
refresh()
Refreshes the display of this month.
void
removeChangeListener(ChangeListener listener)
Removes ChangeListener from the list of listeners.
void
removeKeyListener(KeyListener listener)
Removes KeyListener from the list of listeners.
void
setAntiAliased(boolean antiAliased)
void
setDate(Date date)
Setter for property date.
void
setDateSelectionModel(DateSelectionModel dateSelectionModel)
void
setEnabled(boolean enabled)
Enables or disables the component
void
setEternalScroll(boolean eternalScroll)
void
setFirstDayOfWeek(int firstDayOfWeek)
Setter for property firstDayOfWeek.
void
setHeaderRenderer(HeaderRenderer headerRenderer)
Setter for property headerRenderer.
void
setMinimalDaysInFirstWeek(int number)
Specifies how many days should the first week of the year contain
If not specified, i.e.
void
setModel(DataModel model)
Setter for property model.
void
setOrientation(int orientation)
Changes the orientation (horizontal or vertical).
void
setPrintMoon(boolean printMoon)
void
setQuantity(int quantity)
Setter for property quantity.
void
setRenderer(DayRenderer renderer)
Setter for property renderer.
void
setScrollPosition(int scrollPosition)
Setter for property scrollPosition.
void
setSelectionMode(int selectionMode)
void
setShowToday(boolean showToday)
void
setTodayCaption(String caption)
void
setValue(Object date)
Sets the selected date.
void
setValues(Object[] dates)
Set the selected dates.
void
setWorkingdays(boolean[] workingdays)
Setter for property workingdays.
void
setYearPosition(int yearPosition)
Setter for property yearPosition.
void
stateChanged(ChangeEvent e)
Event fired when the selected day changes.

Field Details

DOWN

public static final int DOWN
Down Position.
Field Value:
1

HORIZONTAL

public static final int HORIZONTAL
Horizontal orientation.
Field Value:
0

LEFT

public static final int LEFT
Left Position.
Field Value:
0

RIGHT

public static final int RIGHT
Right Position.
Field Value:
1

UP

public static final int UP
Up Position.
Field Value:
0

VERTICAL

public static final int VERTICAL
Vertical orientation.
Field Value:
1

eternalScroll

protected boolean eternalScroll

Constructor Details

CalendarPanel

public CalendarPanel()
Default constructor, constructs a vertical panel with 3 months.

CalendarPanel

public CalendarPanel(boolean showWeekNumbers)
Constructrs a panel with 3 months, Vertical.
Parameters:
showWeekNumbers -

CalendarPanel

public CalendarPanel(int quantity)
Constructs a panel with 3 months and the provided orientation.
Parameters:
quantity - quantity of months to show at once

CalendarPanel

public CalendarPanel(int quantity,
                     int orientation)
Constructs a panel with the provided quantity and orientation.
Parameters:
quantity - months to show at once
orientation - orientation

CalendarPanel

public CalendarPanel(int quantity,
                     int orientation,
                     boolean showWeekNumber)

CalendarPanel

public CalendarPanel(int quantity,
                     int orientation,
                     boolean showWeekNumber,
                     boolean eternalScroll)
Creates a new instance of CalendarPanel.
Parameters:
quantity - months to show at once
orientation - the orientation
showWeekNumber - true to show the week numbers

Method Details

addChangeListener

public void addChangeListener(ChangeListener listener)
Registers ChangeListener to receive events.
Parameters:
listener - The listener to register.

addKeyListener

public void addKeyListener(KeyListener listener)
Registers KeyListener to receive events.
Parameters:
listener - The listener to register.

getDate

public Date getDate()
Getter for property date.
Returns:
Value of property date.

getDateSelectionModel

public DateSelectionModel getDateSelectionModel()
Returns:
Returns the dateSelectionModel.

getFirstDayOfWeek

public int getFirstDayOfWeek()
Getter for property firstDayOfWeek.
Returns:
Value of property firstDayOfWeek.

getHeaderRenderer

public HeaderRenderer getHeaderRenderer()
Getter for property headerRenderer.
Returns:
Value of property headerRenderer.

getMinimalDaysInFirstWeek

public int getMinimalDaysInFirstWeek()
Returns:
how many weekdays does the first week of the year have

getModel

public DataModel getModel()
Getter for property model.
Returns:
Value of property model.

getOrientation

public int getOrientation()
Getter for property orientation.
Returns:
Value of property orientation.

getQuantity

public int getQuantity()
Getter for property quantity.
Returns:
Value of property quantity.

getRenderer

public DayRenderer getRenderer()
Getter for property renderer.
Returns:
Value of property renderer.

getScrollPosition

public int getScrollPosition()
Getter for property scrollPosition.
Returns:
Value of property scrollPosition.

getSelectionMode

public int getSelectionMode()
Returns:
Returns the selectionMode.

getValue

public Object getValue()
Returns the selected date.
Returns:
Selected Date

getValues

public Object[] getValues()
Return the selected dates as an Array.
Returns:
Selected Dates

getWorkingdays

public boolean[] getWorkingdays()
Getter for property workingdays.
Returns:
Value of property workingdays.

getYearPosition

public int getYearPosition()
Getter for property yearPosition.
Returns:
Value of property yearPosition.

isAntiAliased

public boolean isAntiAliased()
Returns:
Returns the antiAliased.

isEnabled

public boolean isEnabled()
Getter for enabled property
Returns:
true if it's enabled

isEternalScroll

public boolean isEternalScroll()
Returns:
Returns the eternalScroll.

isPrintMoon

public boolean isPrintMoon()
Returns:
Returns the printMoon.

isShowToday

public boolean isShowToday()
Returns:
Returns the showToday.

refresh

public void refresh()
Refreshes the display of this month.

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes ChangeListener from the list of listeners.
Parameters:
listener - The listener to remove.

removeKeyListener

public void removeKeyListener(KeyListener listener)
Removes KeyListener from the list of listeners.
Parameters:
listener - The listener to remove.

setAntiAliased

public void setAntiAliased(boolean antiAliased)
Parameters:
antiAliased - The antiAliased to set.

setDate

public void setDate(Date date)
Setter for property date.
Parameters:
date - New value of property date.

setDateSelectionModel

public void setDateSelectionModel(DateSelectionModel dateSelectionModel)
Parameters:
dateSelectionModel - The dateSelectionModel to set.

setEnabled

public void setEnabled(boolean enabled)
Enables or disables the component
Parameters:
enabled - true for enabling

setEternalScroll

public void setEternalScroll(boolean eternalScroll)
Parameters:
eternalScroll - The eternalScroll to set.

setFirstDayOfWeek

public void setFirstDayOfWeek(int firstDayOfWeek)
Setter for property firstDayOfWeek.
Parameters:
firstDayOfWeek - New value of property firstDayOfWeek.

setHeaderRenderer

public void setHeaderRenderer(HeaderRenderer headerRenderer)
Setter for property headerRenderer.
Parameters:
headerRenderer - New value of property headerRenderer.

setMinimalDaysInFirstWeek

public void setMinimalDaysInFirstWeek(int number)
Specifies how many days should the first week of the year contain
If not specified, i.e. 0, then no changes from the defaults are done
Parameters:
number -

setModel

public void setModel(DataModel model)
Setter for property model.
Parameters:
model - New value of property model.

setOrientation

public void setOrientation(int orientation)
Changes the orientation (horizontal or vertical).
Parameters:
orientation - the new orientation

setPrintMoon

public void setPrintMoon(boolean printMoon)
Parameters:
printMoon - The printMoon to set.

setQuantity

public void setQuantity(int quantity)
Setter for property quantity.
Parameters:
quantity - New value of property quantity.

setRenderer

public void setRenderer(DayRenderer renderer)
Setter for property renderer.
Parameters:
renderer - New value of property renderer.

setScrollPosition

public void setScrollPosition(int scrollPosition)
Setter for property scrollPosition.
Parameters:
scrollPosition - New value of property scrollPosition.

setSelectionMode

public void setSelectionMode(int selectionMode)
Parameters:
selectionMode - The selectionMode to set.

setShowToday

public void setShowToday(boolean showToday)
Parameters:
showToday - The showToday to set.

setTodayCaption

public void setTodayCaption(String caption)

setValue

public void setValue(Object date)
Sets the selected date.
Parameters:
date - Date to select

setValues

public void setValues(Object[] dates)
Set the selected dates.
Parameters:
dates - Array with the Dates

setWorkingdays

public void setWorkingdays(boolean[] workingdays)
Setter for property workingdays.
Parameters:
workingdays - New value of property workingdays.

setYearPosition

public void setYearPosition(int yearPosition)
Setter for property yearPosition.
Parameters:
yearPosition - New value of property yearPosition.

stateChanged

public void stateChanged(ChangeEvent e)
Event fired when the selected day changes.
Parameters:
e - event fired