public class TimeGranularityDatelineModel extends AbstractDatelineModel<TimeGranularity>
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
datelineWidth, granularity, selectedTimeSpan, spreadsheetCellWidth, timeSpan, timeZone, zoom
Constructor and Description |
---|
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,
TimeZone zone)
Constructs a new dateline model.
|
TimeGranularityDatelineModel(Dateline dateline,
ITimeSpan timeSpan,
TimeZone zone)
Constructs a new dateline model.
|
Modifier and Type | Method and Description |
---|---|
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.
|
List<GridLine> |
getGrid(int x1,
int x2,
boolean major)
Returns a list of grid line coordinates for the given coordinate
interval.
|
MessageFormat |
getHalfYearFormat()
Returns the format used for displaying the halfs of a year.
|
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).
|
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.
|
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).
|
String |
getMinorDateString(TimeGranularity level,
long date)
Returns a string representation of a time point based on the given time
granularity.
|
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.
|
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(MessageFormat format)
Sets the format used for displaying the halfs of a year.
|
void |
setMajorDateFormat(TimeGranularity granularity,
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,
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(MessageFormat format)
Sets the format used for displaying the quarters of a year.
|
addDatelineModelListener, fireDatelineModelChangeEvent, fireDatelineModelWillChangeEvent, getDatelineWidth, getGranularity, getSelectedTimeSpan, getSpreadsheetCellWidth, getTimeSpan, getTimeZone, getZoom, removeDatelineModelListener, setGranularity, setSelectedTimeSpan, setSpreadsheetCellWidth, setTimeSpan, setTimeZone, setZoom
public TimeGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan, TimeGranularity tg, 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 modelDatelineModelException
- 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 granularityDatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic TimeGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan, 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 modelDatelineModelException
- 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 belongsDatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic int getGap()
public void setGap(int gap)
gap
- the text gap in pixelpublic 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 linesGridLayer
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 spanpublic int getTimeLocation(long time)
IDatelineModel
IDatelineModel.getTimeAt(int)
method (example: x = getTimeLocation(getTimeAt(x))
).time
- the time for which to return a coordinateIDatelineModel.getTimeAt(int)
public long getTimeAt(int x)
x
- intgetTimeAt(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 datelinepublic long getTimeDuration(int width)
width
- the width (in pixel) for which to return the durationprotected 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 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 representationpublic 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 representationpublic MessageFormat getQuarterYearFormat()
DateFormat
object.public void setQuarterYearFormat(MessageFormat format)
DateFormat
object.format
- the format used for displaying the quarters of a yearpublic MessageFormat getHalfYearFormat()
DateFormat
object.public void setHalfYearFormat(MessageFormat format)
DateFormat
object.format
- the format used for displaying the halfs of a yearpublic DateFormat getMajorDateFormat(TimeGranularity granularity)
granularity
- the time granularity for which to return a date formatting
objectpublic void setMajorDateFormat(TimeGranularity granularity, DateFormat format) throws DatelineModelException
granularity
- the time granularity for which to return a date formatting
objectformat
- a date formatter for the given time granularityDatelineModelException
- if the dateline width becomes too large because of the new
formatpublic DateFormat getMinorDateFormat(TimeGranularity granularity)
granularity
- the time granularity for which to return a date formatting
objectgetQuarterYearFormat()
,
getHalfYearFormat()
public void setMinorDateFormat(TimeGranularity granularity, DateFormat format) throws DatelineModelException
granularity
- the time granularity for which to return a date formatting
objectformat
- a date formatter for the given time granularityDatelineModelException
- if the dateline width becomes too large because of the new
formatsetQuarterYearFormat(MessageFormat)
,
setHalfYearFormat(MessageFormat)
public void requestVisibleTimeSpan(ITimeSpan span) throws DatelineModelException
IDatelineModel
span
- the requested time spanDatelineModelException
- if the model can not satisfy the requestpublic String getTimeString(long time)
IDatelineModel
time
- the time for which to return a textual representationCopyright © 2006–2016 Dirk Lemmermann Software & Consulting. All rights reserved.