public class SimpleGranularityDatelineModel extends AbstractDatelineModel<SimpleGranularity>
SimpleGranularity
enumerator. The model returns major time points that are always ten times
larger than the minor time points. So if the minor times are 1, 2, 3, ...
then the major times are 10, 20, 30, 40, 50, ...SimpleGranularity
,
SimpleGranularityDatelineRenderer
,
SimpleGranularityGridPolicy
datelineWidth, granularity, selectedTimeSpan, spreadsheetCellWidth, timeSpan, timeZone, zoom
Constructor and Description |
---|
SimpleGranularityDatelineModel(Dateline dateline)
Constructs a new dateline model.
|
SimpleGranularityDatelineModel(Dateline dateline,
ITimeSpan timeSpan,
SimpleGranularity sg)
Constructs a new dateline model.
|
SimpleGranularityDatelineModel(Dateline dateline,
ITimeSpan timeSpan,
SimpleGranularity sg,
TimeZone timeZone)
Constructs a new dateline model.
|
SimpleGranularityDatelineModel(Dateline dateline,
SimpleGranularity sg)
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.
|
String |
getMajorDateString(SimpleGranularity granularity,
long time)
Returns a text representation for the given major time point and
granularity.
|
SimpleGranularity |
getMajorSimpleGranularity()
Returns the currently shown major granularity, which gets
determined by invoking
SimpleGranularity.next() on the current
granularity. |
String |
getMinorDateString(SimpleGranularity granularity,
long time)
Returns a text representation for the given minor time point and
granularity.
|
long |
getTimeAt(int x)
Returns the time for the given x-coordinate.
|
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.
|
addDatelineModelListener, fireDatelineModelChangeEvent, fireDatelineModelWillChangeEvent, getDatelineWidth, getGranularity, getSelectedTimeSpan, getSpreadsheetCellWidth, getTimeSpan, getTimeZone, getZoom, removeDatelineModelListener, setGranularity, setSelectedTimeSpan, setSpreadsheetCellWidth, setTimeSpan, setTimeZone, setZoom
public SimpleGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan, SimpleGranularity sg, TimeZone timeZone) throws DatelineModelException
dateline
- the dateline to which the model belongstimeSpan
- the total time span covered (the planning horizon)sg
- the initial simple granularitytimeZone
- the time zone represented by the modelDatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic SimpleGranularityDatelineModel(Dateline dateline, ITimeSpan timeSpan, SimpleGranularity sg) throws DatelineModelException
TimeZone.getDefault()
dateline
- the dateline to which the model belongstimeSpan
- the total time span covered (the planning horizon)sg
- the initial simple granularityDatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic SimpleGranularityDatelineModel(Dateline dateline, SimpleGranularity sg) throws DatelineModelException
TimeZone.getDefault()
dateline
- the dateline to which the model belongssg
- the initial simple granularityDatelineModelException
- if the requested time span can not be visualized with the
requested granularitypublic SimpleGranularityDatelineModel(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 SimpleGranularity getMajorSimpleGranularity()
SimpleGranularity.next()
on the current
granularity.protected void calculateDatelineWidth() throws DatelineModelException
AbstractDatelineModel
calculateDatelineWidth
in class AbstractDatelineModel<SimpleGranularity>
DatelineModelException
- if the calculated width exceeds the maximum width that is
equal to Integer.MAX_VALUE
public 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 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)
IDatelineModel
x
- the x-coordinate for which to return a time pointIDatelineModel.getTimeLocation(long)
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 void requestVisibleTimeSpan(ITimeSpan span) throws DatelineModelException
IDatelineModel
span
- the requested time spanDatelineModelException
- if the model can not satisfy the requestpublic String getMajorDateString(SimpleGranularity granularity, long time)
granularity
- the granularity in which the given time point will be
displayedtime
- the time point in need of a text representationpublic String getMinorDateString(SimpleGranularity granularity, long time)
granularity
- the granularity in which the given time point will be
displayedtime
- the time point in need of a text representationpublic int getGap()
public void setGap(int gap)
gap
- the text gap in pixelpublic String getTimeString(long time)
IDatelineModel
time
- the time for which to return a textual representationCopyright © 2006–2016 Dirk Lemmermann Software & Consulting. All rights reserved.