org.jfree.chart.axis
public class DateAxis extends ValueAxis implements Cloneable, Serializable
DateFormat
instance.
You can also create a Timeline and supply in the constructor to create an axis that only contains certain domain values. For example, this allows you to create a date axis that only contains working days.
Field Summary | |
---|---|
static Date | DEFAULT_ANCHOR_DATE The default anchor date. |
static double | DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS The default minimum auto range size. |
static DateRange | DEFAULT_DATE_RANGE The default axis range. |
static DateTickUnit | DEFAULT_DATE_TICK_UNIT The default date tick unit. |
Constructor Summary | |
---|---|
DateAxis()
Creates a date axis with no label. | |
DateAxis(String label)
Creates a date axis with the specified label.
| |
DateAxis(String label, TimeZone zone)
Creates a date axis. |
Method Summary | |
---|---|
protected void | autoAdjustRange()
Rescales the axis to ensure that all data is visible. |
Date | calculateHighestVisibleTickValue(DateTickUnit unit)
Calculates the value of the highest visible tick on the axis.
|
Date | calculateLowestVisibleTickValue(DateTickUnit unit)
Calculates the value of the lowest visible tick on the axis.
|
Object | clone()
Returns a clone of the object.
|
void | configure()
Configures the axis to work with the specified plot. |
static TickUnitSource | createStandardDateTickUnits()
Returns a collection of standard date tick units that uses the default
time zone. |
static TickUnitSource | createStandardDateTickUnits(TimeZone zone)
Returns a collection of standard date tick units. |
double | dateToJava2D(Date date, Rectangle2D area, RectangleEdge edge)
Translates a date to Java2D coordinates, based on the range displayed by
this axis for the specified data area.
|
AxisState | draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a
printer).
|
boolean | equals(Object obj)
Tests this axis for equality with an arbitrary object.
|
DateFormat | getDateFormatOverride()
Returns the date format override. |
Date | getMaximumDate()
Returns the latest date visible on the axis.
|
Date | getMinimumDate()
Returns the earliest date visible on the axis.
|
DateTickMarkPosition | getTickMarkPosition()
Returns the tick mark position (start, middle or end of the time period).
|
DateTickUnit | getTickUnit()
Returns the tick unit for the axis.
|
Timeline | getTimeline()
Returns the underlying timeline used by this axis.
|
TimeZone | getTimeZone()
Returns the time zone for the axis.
|
int | hashCode()
Returns a hash code for this object.
|
boolean | isHiddenValue(long millis)
Returns true if the axis hides this value, and
false otherwise.
|
double | java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge)
Translates a Java2D coordinate into the corresponding data value. |
protected Date | nextStandardDate(Date date, DateTickUnit unit)
Returns the first "standard" date (based on the specified field and
units).
|
protected Date | previousStandardDate(Date date, DateTickUnit unit)
Returns the previous "standard" date, for a given date and tick unit.
|
List | refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
|
protected List | refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Recalculates the ticks for the date axis.
|
protected List | refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Recalculates the ticks for the date axis.
|
protected void | selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Selects an appropriate tick value for the axis. |
protected void | selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Selects an appropriate tick size for the axis. |
protected void | selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Selects an appropriate tick size for the axis. |
void | setDateFormatOverride(DateFormat formatter)
Sets the date format override. |
void | setMaximumDate(Date maximumDate)
Sets the maximum date visible on the axis. |
void | setMinimumDate(Date date)
Sets the minimum date visible on the axis and sends an
AxisChangeEvent to all registered listeners.
|
void | setRange(Range range)
Sets the upper and lower bounds for the axis and sends an
AxisChangeEvent to all registered listeners. |
void | setRange(Range range, boolean turnOffAutoRange, boolean notify)
Sets the range for the axis, if requested, sends an
AxisChangeEvent to all registered listeners. |
void | setRange(Date lower, Date upper)
Sets the axis range and sends an AxisChangeEvent to all
registered listeners.
|
void | setRange(double lower, double upper)
Sets the axis range and sends an AxisChangeEvent to all
registered listeners.
|
void | setTickMarkPosition(DateTickMarkPosition position)
Sets the tick mark position (start, middle or end of the time period)
and sends an AxisChangeEvent to all registered listeners.
|
void | setTickUnit(DateTickUnit unit)
Sets the tick unit for the axis. |
void | setTickUnit(DateTickUnit unit, boolean notify, boolean turnOffAutoSelection)
Sets the tick unit attribute.
|
void | setTimeline(Timeline timeline)
Sets the underlying timeline to use for this axis.
|
void | setTimeZone(TimeZone zone)
Sets the time zone for the axis and sends an AxisChangeEvent to
all registered listeners.
|
double | valueToJava2D(double value, Rectangle2D area, RectangleEdge edge)
Translates the data value to the display coordinates (Java 2D User Space)
of the chart.
|
void | zoomRange(double lowerPercent, double upperPercent)
Zooms in on the current range.
|
Parameters: label the axis label (null
permitted).
Parameters: label the axis label (null
permitted). zone the time zone.
Parameters: unit date unit to use.
Returns: The value of the highest visible tick on the axis.
Parameters: unit date unit to use.
Returns: The value of the lowest visible tick on the axis.
Returns: A clone.
Throws: CloneNotSupportedException if some component of the axis does not support cloning.
Returns: A collection of standard date tick units.
Parameters: zone the time zone (null
not permitted).
Returns: A collection of standard date tick units.
Parameters: date the date. area the rectangle (in Java2D space) where the data is to be plotted. edge the axis location.
Returns: The coordinate corresponding to the supplied date.
Parameters: g2 the graphics device (null
not permitted). cursor the cursor location. plotArea the area within which the axes and data should be
drawn (null
not permitted). dataArea the area within which the data should be drawn
(null
not permitted). edge the location of the axis (null
not permitted). plotState collects information about the plot
(null
permitted).
Returns: The axis state (never null
).
Parameters: obj the object (null
permitted).
Returns: A boolean.
Returns: The formatter (possibly null
).
Returns: The date.
Returns: The date.
Returns: The position (never null
).
Note: if the autoTickUnitSelection
flag is
true
the tick unit may be changed while the axis is being
drawn, so in that case the return value from this method may be
irrelevant if the method is called before the axis has been drawn.
Returns: The tick unit (possibly null
).
See Also: setTickUnit isAutoTickUnitSelection
Returns: The timeline.
Returns: A hash code.
true
if the axis hides this value, and
false
otherwise.
Parameters: millis the data value.
Returns: A value.
Parameters: java2DValue the coordinate in Java2D space. area the rectangle (in Java2D space) where the data is to be plotted. edge the axis location.
Returns: A data value.
Parameters: date the reference date. unit the date tick unit.
Returns: The next "standard" date.
Parameters: date the reference date. unit the tick unit.
Returns: The previous "standard" date.
Parameters: g2 the graphics device. state the axis state. dataArea the area in which the plot should be drawn. edge the location of the axis.
Returns: A list of ticks.
Parameters: g2 the graphics device. dataArea the area in which the data is to be drawn. edge the location of the axis.
Returns: A list of ticks.
Parameters: g2 the graphics device. dataArea the area in which the plot should be drawn. edge the location of the axis.
Returns: A list of ticks.
Parameters: g2 the graphics device. dataArea the area defined by the axes. edge the axis location.
Parameters: g2 the graphics device. dataArea the area defined by the axes. edge the axis location.
Parameters: g2 the graphics device. dataArea the area in which the plot should be drawn. edge the axis location.
Parameters: formatter the date formatter (null
permitted).
Parameters: maximumDate the date (null
not permitted).
Parameters: date the date (null
not permitted).
Parameters: range the new range (null
not permitted).
false
(optional).
Parameters: range the range (null
not permitted). turnOffAutoRange a flag that controls whether or not the auto
range is turned off. notify a flag that controls whether or not listeners are
notified.
Parameters: lower the lower bound for the axis. upper the upper bound for the axis.
Parameters: lower the lower bound for the axis. upper the upper bound for the axis.
Parameters: position the position (null
not permitted).
false
, and registered listeners are notified that
the axis has been changed.
Parameters: unit the tick unit.
See Also: getTickUnit DateAxis
Parameters: unit the new tick unit. notify notify registered listeners? turnOffAutoSelection turn off auto selection?
See Also: getTickUnit
If the timeline is changed, an AxisChangeEvent is sent to all registered listeners.
Parameters: timeline the timeline.
Parameters: zone the time zone (null
not permitted).
Since: 1.0.4
See Also: getTimeZone
Parameters: value the date to be plotted. area the rectangle (in Java2D space) where the data is to be plotted. edge the axis location.
Returns: The coordinate corresponding to the supplied data value.
Parameters: lowerPercent the new lower bound. upperPercent the new upper bound.