|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.standbysoft.component.date.swing.DefaultWeekModel
A default implementation for a WeekModel. It adds a few methods
that are not specified in the interface in order to make the specification
of week days names easier.
The week days names are determined using a locale
and a format (short,
long or one letter).
One can also specify custom week days names by overriding the
getDowNames() method.
Another important feature of this model is that it can compute the week number for a certain date. This means that you can override it to implement your own week numbering scheme although it may probably happen in very few cases.
What is important to know is that you can configure this model to compute
the week numbers according to the ISO 8601 standard.
| Field Summary | |
protected int |
dow
|
static int |
DOW_NAMES_LETTER
Type value indicating that the days of week names are only one letter long. |
static int |
DOW_NAMES_LONG
Type value indicating that the days of week names are long. |
static int |
DOW_NAMES_SHORT
Type value indicating that the days of week names are short. |
protected int |
dowFirst
|
protected int |
dowFormat
The format used to determine the week days names. |
protected java.lang.String[] |
dowNames
Contains the actual week days names. |
protected int[] |
dows
|
protected boolean |
dowSelectionAllowed
|
protected boolean |
isoWeekNumbersEnabled
|
protected javax.swing.event.EventListenerList |
listenerList
The list where all the registered listeners are stored. |
protected java.util.Locale |
locale
The locale used to determine the week days names. |
protected int |
month
|
protected int |
week
|
protected static int[] |
WEEK_DAYS
A list with all the Calendar week days that starts with
Sunday and ends with Saturday. |
protected boolean |
weekSelectionAllowed
|
protected int |
year
|
| Fields inherited from interface com.standbysoft.component.date.swing.WeekModel |
NO_SELECTED_DOW, NO_SELECTED_MONTH, NO_SELECTED_WEEK, NO_SELECTED_YEAR |
| Constructor Summary | |
DefaultWeekModel()
Creates a default week model that uses the default locale. |
|
| Method Summary | |
void |
addWeekModelListener(WeekModelListener listener)
Adds an object that listens to changes in this model. |
protected void |
fireDowChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
selected day of week changes. |
protected void |
fireDowFirstChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
first day of week changes. |
protected void |
fireDowNamesChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
names of the days of week change. |
protected void |
fireWeekChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
selected week changes. |
protected void |
fireWeekNumbersChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
week numbers numerotation changes. |
int |
getDowFirst()
Returns the first day of week. |
java.lang.String[] |
getDowNames()
Returns the names of the week days that are determined using the current locale and a format. |
protected java.lang.String[] |
getDowNames(int format,
java.util.Locale locale)
Returns the names of the week days. |
int |
getDowNamesFormat()
Returns the current format used to represent the week days names. |
int[] |
getDows()
Returns the days of week starting with the first day of week. |
java.util.Locale |
getLocale()
Returns the locale used to determine the names of the week days. |
int |
getSelectedDow()
Returns the day of week selected by this model. |
int |
getSelectedMonth()
Returns the month to which the selected day of week belongs. |
int |
getSelectedWeek()
Returns the number of the selected week from current year. |
int |
getSelectedYear()
Returns the year to which the selected week belongs. |
int |
getWeekNumber(java.util.Date date,
java.util.TimeZone timezone)
Returns the week number for a certain date using the Calendar.WEEK_OF_YEAR field value. |
boolean |
isDowSelectionAllowed()
Determines whether days of week may be selected. |
boolean |
isWeekNumberISOFormatEnabled()
Determines whether ISO week numbering is enabled. |
boolean |
isWeekSelectionAllowed()
Determines whether weeks of year may be selected. |
void |
removeWeekModelListener(WeekModelListener listener)
Removes a specified listener from the list of registered listeners. |
void |
setDowFirst(int day)
Specifies the first day of week. |
void |
setDowNamesFormat(int format)
Changes the format for the week days names. |
void |
setDowSelectionAllowed(boolean allowed)
Specifies whether days of week may be selected. |
void |
setLocale(java.util.Locale locale)
Specifies a new locale to change the week days names. |
void |
setSelectedDow(int month,
int dow)
Specifies the day of week that is selected by this model. |
void |
setSelectedWeek(int year,
int week)
Selects a week from a specified year. |
void |
setWeekNumberISOFormatEnabled(boolean enabled)
Specifies whether weeks are numbered according to the ISO 8601 standard which defines the numeric representations of date and time. |
void |
setWeekSelectionAllowed(boolean allowed)
Specifies whether weeks of year may be selected. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int DOW_NAMES_SHORT
public static final int DOW_NAMES_LONG
public static final int DOW_NAMES_LETTER
protected javax.swing.event.EventListenerList listenerList
protected static int[] WEEK_DAYS
Calendar week days that starts with
Sunday and ends with Saturday.
protected int dow
protected int month
protected int week
protected int year
protected int dowFirst
protected int[] dows
protected int dowFormat
DOW_NAMES_SHORT, DOW_NAMES_LONG or DOW_NAMES_LETTER.
protected java.util.Locale locale
protected java.lang.String[] dowNames
protected boolean dowSelectionAllowed
protected boolean weekSelectionAllowed
protected boolean isoWeekNumbersEnabled
| Constructor Detail |
public DefaultWeekModel()
DOW_NAMES_SHORT format and no week or
day of week is selected.
| Method Detail |
public java.lang.String[] getDowNames()
Returns the names of the week days that are determined using the current locale and a format. This approach should solve most cases and for special needs one can just override it and provide some custom names.
getDowNames in interface WeekModelsetLocale(Locale),
setDowNamesFormat(int)
protected java.lang.String[] getDowNames(int format,
java.util.Locale locale)
throws java.lang.IllegalArgumentException
format - available formats are short,
long and one letterlocale - locale
String array.
The name of a week day can be accessed using as array index a
Calendar constant like Calendar.SUNDAY.
java.lang.IllegalArgumentException - if the format is not validpublic void setDowNamesFormat(int format)
format - format used to represent the names. Allowed values are
DOW_NAMES_SHORT, DOW_NAMES_LONG and DOW_NAMES_LETTERgetDowNames(),
setLocale(Locale)public int getDowNamesFormat()
DOW_NAMES_SHORT, DOW_NAMES_LONG or DOW_NAMES_LETTER.setDowNamesFormat(int)public void setLocale(java.util.Locale locale)
locale - locale that determines the week days names.getDowNames(),
setDowNamesFormat(int)public java.util.Locale getLocale()
setLocale(Locale)public int getSelectedMonth()
WeekModel
getSelectedMonth in interface WeekModelWeekModel.NO_SELECTED_MONTH if no
dow is selected.WeekModel.NO_SELECTED_MONTH,
WeekModel.getSelectedDow(),
WeekModel.setSelectedDow(int, int)public int getSelectedDow()
WeekModelCalendar.SUNDAY,
Calendar.MONDAY, etc. If no day of week is selected, then
the method will return WeekModel.NO_SELECTED_DOW.
getSelectedDow in interface WeekModelWeekModel.setSelectedDow(int, int),
WeekModel.NO_SELECTED_DOW
public void setSelectedDow(int month,
int dow)
WeekModel
setSelectedDow in interface WeekModeldow - day of week that is selected (Calendar.SUNDAY,
Calendar.MONDAY, etc) or WeekModel.NO_SELECTED_DOW if
no date should be selectedmonth - month to which the dow belongsWeekModel.NO_SELECTED_DOW,
WeekModel.NO_SELECTED_MONTHpublic int getDowFirst()
WeekModel
getDowFirst in interface WeekModelWeekModel.setDowFirst(int)public void setDowFirst(int day)
WeekModel
setDowFirst in interface WeekModelday - day of week that is a java.util.Calendar
constant like Calendar.MONDAYpublic int[] getDows()
WeekModel
getDows in interface WeekModelCalendar.MONDAY.WeekModel.getDowFirst()public int getSelectedWeek()
WeekModel
getSelectedWeek in interface WeekModelWeekModel.NO_SELECTED_WEEK if no
week is selected.WeekModel.NO_SELECTED_WEEK,
WeekModel.getSelectedYear(),
WeekModel.setSelectedWeek(int, int)public int getSelectedYear()
WeekModel
getSelectedYear in interface WeekModelWeekModel.NO_SELECTED_YEAR if no
year is selected.WeekModel.NO_SELECTED_YEAR,
WeekModel.getSelectedWeek(),
WeekModel.setSelectedWeek(int, int)
public void setSelectedWeek(int year,
int week)
WeekModel
setSelectedWeek in interface WeekModelyear - specified yearweek - specified weekWeekModel.NO_SELECTED_WEEK,
WeekModel.NO_SELECTED_YEARpublic boolean isDowSelectionAllowed()
WeekModel
isDowSelectionAllowed in interface WeekModeltrue if days of week may be selected and
false otherwiseWeekModel.setDowSelectionAllowed(boolean)public void setDowSelectionAllowed(boolean allowed)
WeekModelJMonth component if the respective day is
clicked in the header.
setDowSelectionAllowed in interface WeekModelallowed - if true, one may click on a day of week
to select it.public boolean isWeekSelectionAllowed()
WeekModel
isWeekSelectionAllowed in interface WeekModeltrue if weeks of week may be selected and
false otherwiseWeekModel.setWeekSelectionAllowed(boolean)public void setWeekSelectionAllowed(boolean allowed)
WeekModelJMonth component if the respective week number
is clicked.
setWeekSelectionAllowed in interface WeekModelallowed - if true, one may click on a week of year
to select it.
public int getWeekNumber(java.util.Date date,
java.util.TimeZone timezone)
Returns the week number for a certain date using the
Calendar.WEEK_OF_YEAR field value. The week number calculation
considers the locale and first day of week settings.
If ISO week numbering is enabled, then the week number will be computed according to the standard.
getWeekNumber in interface WeekModeldate - date for which the week number is computedtimezone - time zone used with the date to extract the week number
setWeekNumberISOFormatEnabled(boolean)public void setWeekNumberISOFormatEnabled(boolean enabled)
Specifies whether weeks are numbered according to the ISO 8601 standard which defines the numeric representations of date and time.
The standard defines the week 01 of a year as the first week that has the Thursday in this year, which is equivalent to the week that contains the fourth day of January. In other words, the first week of a new year is the week that has the majority of its days in the new year.
enabled - true if week numbers should follow the
standard and false otherwisegetWeekNumber(Date,TimeZone)public boolean isWeekNumberISOFormatEnabled()
true if enabled and false otherwisesetWeekNumberISOFormatEnabled(boolean)public void addWeekModelListener(WeekModelListener listener)
WeekModel
addWeekModelListener in interface WeekModellistener - the listener object that is informed about changes in this modelpublic void removeWeekModelListener(WeekModelListener listener)
WeekModel
removeWeekModelListener in interface WeekModellistener - the listener to be removedprotected void fireWeekChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
selected week changes.
protected void fireDowNamesChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
names of the days of week change.
protected void fireDowFirstChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
first day of week changes.
protected void fireDowChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
selected day of week changes.
protected void fireWeekNumbersChanged(WeekModelEvent evt)
DefaultWeekModel subclasses must call this method when the
week numbers numerotation changes.
|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Visit www.jdatepicker.com for further information or send us your suggestions.
Copyright © 2003-2007 Stand By Soft Ltd. All Rights Reserved.