|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.dlsc.flexgantt.model.dateline.AbstractDatelineModel<TimeGranularity> com.dlsc.flexgantt.swing.timeline.TimeGranularityDatelineModel
public class TimeGranularityDatelineModel
A dateline model implementation based on the TimeGranularity
enumerator. The model tries to return major time points that are intuitive
for the current minor time points. If, for example, the minor time points are
days (Mo, Tu, We, ...) then the major time points will be the beginning of
each week (Jan 1st, Jan 8th, Jan 15th, ...).
TimeGranularity
,
TimeGranularityDatelineRenderer
,
TimeGranularityGridPolicy
Field Summary |
---|
Fields inherited from class com.dlsc.flexgantt.model.dateline.AbstractDatelineModel |
---|
datelineWidth, granularity, selectedTimeSpan, timeSpan, timeZone, zoom |
Constructor Summary | |
---|---|
TimeGranularityDatelineModel(Dateline dateline)
Constructs a new dateline model. |
|
TimeGranularityDatelineModel(Dateline dateline,
ITimeSpan timeSpan)
Constructs a new dateline model. |
|
TimeGranularityDatelineModel(Dateline dateline,
ITimeSpan timeSpan,
TimeGranularity tg)
Constructs a new dateline model. |
|
TimeGranularityDatelineModel(Dateline dateline,
ITimeSpan timeSpan,
TimeGranularity tg,
java.util.TimeZone zone)
Constructs a new dateline model. |
|
TimeGranularityDatelineModel(Dateline dateline,
ITimeSpan timeSpan,
java.util.TimeZone zone)
Constructs a new dateline model. |
Method Summary | |
---|---|
protected void |
calculateDatelineWidth()
Calculates the required width of the dateline based on the total time span and some additional information that needs to be provided by the subclasses. |
int |
getGap()
The gap (in pixel) that will be added twice to each granularity width so that there will be some space between the text and the grid lines. |
java.util.List<GridLine> |
getGrid(int x1,
int x2,
boolean major)
Returns a list of grid line coordinates for the given coordinate interval. |
java.text.MessageFormat |
getHalfYearFormat()
Returns the format used for displaying the halfs of a year. |
java.text.DateFormat |
getMajorDateFormat(TimeGranularity granularity)
Returns the date formatter used for the given time granularity, when formatting time in the major part of the dateline (the upper part). |
java.lang.String |
getMajorDateString(TimeGranularity level,
long date)
Returns a string representation of a time point based on the given time granularity. |
TimeGranularity |
getMajorTimeGranularity()
Returns the major time granularity, which is based on the currently used (minor) time granularity. |
java.text.DateFormat |
getMinorDateFormat(TimeGranularity granularity)
Returns the date formatter used for the given time granularity, when formatting time in the minor part of the dateline (the lower part). |
java.lang.String |
getMinorDateString(TimeGranularity level,
long date)
Returns a string representation of a time point based on the given time granularity. |
java.text.MessageFormat |
getQuarterYearFormat()
Returns the format used for displaying the quarters of a year. |
long |
getTimeAt(int x)
Returns the time unit specified by the given pixel location. |
long |
getTimeDuration(int width)
Returns the duration in milliseconds represented by the given width. |
TimeGranularity |
getTimeGranularity(ITimeSpan span,
int width)
Returns a suitable time granularity that can be used to display the given time span in the given width. |
int |
getTimeLocation(long time)
Returns the location of the given time point. |
ITimeSpan |
getTimeSpanAt(int x,
boolean major)
Returns the time span that gets defined by the grid lines to the left and the right of the given x-coordinate. |
java.lang.String |
getTimeString(long time)
Returns a textual representation for the givent time point. |
void |
requestVisibleTimeSpan(ITimeSpan span)
A request that asks the model to change its settings in such a way that the requested time span will become visible in the viewport on the right-hand side of the Gantt chart. |
void |
setGap(int gap)
Sets the gap (in pixel) that will be added twice to each granularity width so that there will be some space between the text and the grid lines. |
void |
setHalfYearFormat(java.text.MessageFormat format)
Sets the format used for displaying the halfs of a year. |
void |
setMajorDateFormat(TimeGranularity granularity,
java.text.DateFormat format)
Sets the date formatter used for the given time granularity, when formatting time in the major part of the dateline (the upper part). |
void |
setMinorDateFormat(TimeGranularity granularity,
java.text.DateFormat format)
Sets the date formatter used for the given time granularity, when formatting time in the minor part of the dateline (the lower part). |
void |
setQuarterYearFormat(java.text.MessageFormat format)
Sets the format used for displaying the quarters of a year. |
Methods inherited from class com.dlsc.flexgantt.model.dateline.AbstractDatelineModel |
---|
addDatelineModelListener, fireDatelineModelChangeEvent, fireDatelineModelWillChangeEvent, getDatelineWidth, getGranularity, getSelectedTimeSpan, getTimeSpan, getTimeZone, getZoom, removeDatelineModelListener, setGranularity, setSelectedTimeSpan, setTimeSpan, setTimeZone, setZoom |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TimeGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan, TimeGranularity tg, java.util.TimeZone zone) throws DatelineModelException
dateline
- the dateline to which the model belongstimeSpan
- the total time span covered (the planning horizon)tg
- the initial time granularityzone
- the time zone represented by the model
DatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic TimeGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan, TimeGranularity tg) throws DatelineModelException
TimeZone.getDefault()
dateline
- the dateline to which the model belongstimeSpan
- the total time span covered (the planning horizon)tg
- the initial time granularity
DatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic TimeGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan, java.util.TimeZone zone) throws DatelineModelException
TimeGranularity.DAY_SHORT
and the time
zone defaults to TimeZone.getDefault()
dateline
- the dateline to which the model belongstimeSpan
- the total time span covered (the planning horizon)zone
- the time zone represented by the model
DatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic TimeGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan) throws DatelineModelException
TimeZone.getDefault()
dateline
- the dateline to which the model belongstimeSpan
- the total time span covered (the planning horizon)
DatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic TimeGranularityDatelineModel(Dateline dateline) throws DatelineModelException
SimpleGranularity.ONE
, and the time zone
defaults to TimeZone.getDefault()
dateline
- the dateline to which the model belongs
DatelineModelException
- if the requested time span can not be visualized with the
requested granularityMethod Detail |
---|
public int getGap()
public void setGap(int gap)
gap
- the text gap in pixelpublic java.util.List<GridLine> getGrid(int x1, int x2, boolean major)
IDatelineModel
x1
- the start coordinatex2
- the end coordinatemajor
- if TRUE the method needs to return the major grid lines
GridLayer
public TimeGranularity getMajorTimeGranularity()
public TimeGranularity getTimeGranularity(ITimeSpan span, int width)
span
- the time span in need of renderingwidth
- the available width for displaying the given time span
public int getTimeLocation(long time)
IDatelineModel
IDatelineModel.getTimeAt(int)
method (example: x = getTimeLocation(getTimeAt(x))
).
time
- the time for which to return a coordinate
IDatelineModel.getTimeAt(int)
public long getTimeAt(int x)
x
- int
getTimeAt(int)
public ITimeSpan getTimeSpanAt(int x, boolean major)
IDatelineModel
x
- the location for which to return a time spanmajor
- a flag controlling whether to return the time span of the
major or the minor part of the dateline
public long getTimeDuration(int width)
width
- the width (in pixel) for which to return the duration
protected void calculateDatelineWidth() throws DatelineModelException
AbstractDatelineModel
calculateDatelineWidth
in class AbstractDatelineModel<TimeGranularity>
DatelineModelException
- if the calculated width exceeds the maximum width that is
equal to Integer.MAX_VALUE
public java.lang.String getMajorDateString(TimeGranularity level, long date)
TimeGranularity.YEAR
then
the text will be something like "2006", "2007", etc...
level
- the time granularity shown in the major part of the datelinedate
- the date for which to return a text representation
public java.lang.String getMinorDateString(TimeGranularity level, long date)
TimeGranularity.MONTH_SHORT
then the text will be something like
"Jan", "Feb", "Mar", etc...
level
- the time granularity shown in the minor part of the datelinedate
- the date for which to return a text representation
public java.text.MessageFormat getQuarterYearFormat()
DateFormat
object.
public void setQuarterYearFormat(java.text.MessageFormat format)
DateFormat
object.
format
- the format used for displaying the quarters of a yearpublic java.text.MessageFormat getHalfYearFormat()
DateFormat
object.
public void setHalfYearFormat(java.text.MessageFormat format)
DateFormat
object.
format
- the format used for displaying the halfs of a yearpublic java.text.DateFormat getMajorDateFormat(TimeGranularity granularity)
granularity
- the time granularity for which to return a date formatting
object
public void setMajorDateFormat(TimeGranularity granularity, java.text.DateFormat format)
granularity
- the time granularity for which to return a date formatting
objectformat
- a date formatter for the given time granularitypublic java.text.DateFormat getMinorDateFormat(TimeGranularity granularity)
granularity
- the time granularity for which to return a date formatting
object
getQuarterYearFormat()
,
getHalfYearFormat()
public void setMinorDateFormat(TimeGranularity granularity, java.text.DateFormat format)
granularity
- the time granularity for which to return a date formatting
objectformat
- a date formatter for the given time granularitysetQuarterYearFormat(MessageFormat)
,
setHalfYearFormat(MessageFormat)
public void requestVisibleTimeSpan(ITimeSpan span) throws DatelineModelException
IDatelineModel
span
- the requested time span
DatelineModelException
- if the model can not satisfy the requestpublic java.lang.String getTimeString(long time)
IDatelineModel
time
- the time for which to return a textual representation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |