|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jfree.chart.axis.Axis
org.jfree.chart.axis.ValueAxis
org.jfree.chart.axis.DateAxis
The base class for axes that display dates. You will find it easier to
understand how this axis works if you bear in mind that it really
displays/measures integer (or long) data, where the integers are
milliseconds since midnight, 1-Jan-1970. When displaying tick labels, the
millisecond values are converted back to dates using a
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 java.util.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. |
Fields inherited from class org.jfree.chart.axis.ValueAxis |
DEFAULT_AUTO_RANGE, DEFAULT_AUTO_RANGE_MINIMUM_SIZE, DEFAULT_AUTO_TICK_UNIT_SELECTION, DEFAULT_INVERTED, DEFAULT_LOWER_BOUND, DEFAULT_LOWER_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_BOUND, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNT |
Constructor Summary | |
DateAxis()
Creates a date axis with no label. |
|
DateAxis(java.lang.String label)
Creates a date axis with the specified label. |
|
DateAxis(java.lang.String label,
java.util.TimeZone zone)
Creates a date axis. |
Method Summary | |
protected void |
autoAdjustRange()
Rescales the axis to ensure that all data is visible. |
java.util.Date |
calculateHighestVisibleTickValue(DateTickUnit unit)
Calculates the value of the highest visible tick on the axis. |
java.util.Date |
calculateLowestVisibleTickValue(DateTickUnit unit)
Calculates the value of the lowest visible tick on the axis. |
java.lang.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(java.util.TimeZone zone)
Returns a collection of standard date tick units. |
double |
dateToJava2D(java.util.Date date,
java.awt.geom.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(java.awt.Graphics2D g2,
double cursor,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge,
PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a printer). |
boolean |
equals(java.lang.Object obj)
Tests an object for equality with this instance. |
java.text.DateFormat |
getDateFormatOverride()
Returns the date format override. |
java.util.Date |
getMaximumDate()
Returns the latest date visible on the axis. |
java.util.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. |
boolean |
isHiddenValue(long millis)
Returns true if the axis hides this value, and
false otherwise. |
double |
java2DToValue(double java2DValue,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Translates a Java2D coordinate into the corresponding data value. |
protected java.util.Date |
nextStandardDate(java.util.Date date,
DateTickUnit unit)
Returns the first "standard" date (based on the specified field and units). |
protected java.util.Date |
previousStandardDate(java.util.Date date,
DateTickUnit unit)
Returns the previous "standard" date, for a given date and tick unit. |
java.util.List |
refreshTicks(java.awt.Graphics2D g2,
AxisState state,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.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 java.util.List |
refreshTicksHorizontal(java.awt.Graphics2D g2,
double cursor,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge)
Recalculates the ticks for the date axis. |
protected java.util.List |
refreshTicksVertical(java.awt.Graphics2D g2,
double cursor,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge)
Recalculates the ticks for the date axis. |
protected void |
selectAutoTickUnit(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D drawArea,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge)
Selects an appropriate tick value for the axis. |
protected void |
selectHorizontalAutoTickUnit(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D drawArea,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge)
Selects an appropriate tick size for the axis. |
protected void |
selectVerticalAutoTickUnit(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D drawArea,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge)
Selects an appropriate tick size for the axis. |
void |
setDateFormatOverride(java.text.DateFormat formatter)
Sets the date format override. |
void |
setMaximumDate(java.util.Date maximumDate)
Sets the maximum date visible on the axis. |
void |
setMinimumDate(java.util.Date date)
Sets the minimum date visible on the axis and sends an AxisChangeEvent to all registered listeners. |
void |
setRange(java.util.Date lower,
java.util.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 |
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 |
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 without any other side effects. |
void |
setTimeline(Timeline timeline)
Sets the underlying timeline to use for this axis. |
double |
valueToJava2D(double value,
java.awt.geom.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. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final DateRange DEFAULT_DATE_RANGE
public static final double DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS
public static final DateTickUnit DEFAULT_DATE_TICK_UNIT
public static final java.util.Date DEFAULT_ANCHOR_DATE
Constructor Detail |
public DateAxis()
public DateAxis(java.lang.String label)
label
- the axis label (null
permitted).public DateAxis(java.lang.String label, java.util.TimeZone zone)
label
- the axis label (null
permitted).zone
- the time zone.SegmentedTimeline
Method Detail |
public Timeline getTimeline()
public void setTimeline(Timeline timeline)
If the timeline is changed, an AxisChangeEvent
is sent to all
registered listeners.
timeline
- the timeline.public DateTickUnit getTickUnit()
null
).public void setTickUnit(DateTickUnit unit)
false
, and registered listeners are notified that
the axis has been changed.
unit
- the tick unit.public void setTickUnit(DateTickUnit unit, boolean notify, boolean turnOffAutoSelection)
unit
- the new tick unit.notify
- notify registered listeners?turnOffAutoSelection
- turn off auto selection?public java.text.DateFormat getDateFormatOverride()
null
).public void setDateFormatOverride(java.text.DateFormat formatter)
formatter
- the date formatter (null
permitted).public void setRange(Range range)
AxisChangeEvent
to all registered listeners. As a side-effect,
the auto-range flag is set to false.
setRange
in class ValueAxis
range
- the new range (null
not permitted).public void setRange(Range range, boolean turnOffAutoRange, boolean notify)
AxisChangeEvent
to all registered listeners. As a side-effect,
the auto-range flag is set to false
(optional).
setRange
in class ValueAxis
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.public void setRange(java.util.Date lower, java.util.Date upper)
AxisChangeEvent
to all
registered listeners.
lower
- the lower bound for the axis.upper
- the upper bound for the axis.public void setRange(double lower, double upper)
AxisChangeEvent
to all
registered listeners.
setRange
in class ValueAxis
lower
- the lower bound for the axis.upper
- the upper bound for the axis.public java.util.Date getMinimumDate()
public void setMinimumDate(java.util.Date date)
AxisChangeEvent
to all registered listeners.
date
- the date (null
not permitted).public java.util.Date getMaximumDate()
public void setMaximumDate(java.util.Date maximumDate)
AxisChangeEvent
is sent to all registered listeners.
maximumDate
- the date (null
not permitted).public DateTickMarkPosition getTickMarkPosition()
null
).public void setTickMarkPosition(DateTickMarkPosition position)
AxisChangeEvent
to all registered listeners.
position
- the position (null
not permitted).public void configure()
configure
in class Axis
public boolean isHiddenValue(long millis)
true
if the axis hides this value, and
false
otherwise.
millis
- the data value.
public double valueToJava2D(double value, java.awt.geom.Rectangle2D area, RectangleEdge edge)
valueToJava2D
in class ValueAxis
value
- the date to be plotted.area
- the rectangle (in Java2D space) where the data is to be
plotted.edge
- the axis location.
public double dateToJava2D(java.util.Date date, java.awt.geom.Rectangle2D area, RectangleEdge edge)
date
- the date.area
- the rectangle (in Java2D space) where the data is to be
plotted.edge
- the axis location.
public double java2DToValue(double java2DValue, java.awt.geom.Rectangle2D area, RectangleEdge edge)
java2DToValue
in class ValueAxis
java2DValue
- the coordinate in Java2D space.area
- the rectangle (in Java2D space) where the data is to be
plotted.edge
- the axis location.
public java.util.Date calculateLowestVisibleTickValue(DateTickUnit unit)
unit
- date unit to use.
public java.util.Date calculateHighestVisibleTickValue(DateTickUnit unit)
unit
- date unit to use.
protected java.util.Date previousStandardDate(java.util.Date date, DateTickUnit unit)
date
- the reference date.unit
- the tick unit.
protected java.util.Date nextStandardDate(java.util.Date date, DateTickUnit unit)
date
- the reference date.unit
- the date tick unit.
public static TickUnitSource createStandardDateTickUnits()
ValueAxis.setStandardTickUnits(TickUnitSource)
method inherited
from the ValueAxis
class).
public static TickUnitSource createStandardDateTickUnits(java.util.TimeZone zone)
ValueAxis.setStandardTickUnits(TickUnitSource)
method inherited
from the ValueAxis
class).
zone
- the time zone (null
not permitted).
protected void autoAdjustRange()
autoAdjustRange
in class ValueAxis
protected void selectAutoTickUnit(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge)
g2
- the graphics device.drawArea
- the area in which the plot and axes should be drawn.dataArea
- the area defined by the axes.edge
- the axis location.protected void selectHorizontalAutoTickUnit(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge)
g2
- the graphics device.drawArea
- the area in which the plot and axes should be drawn.dataArea
- the area defined by the axes.edge
- the axis location.protected void selectVerticalAutoTickUnit(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge)
g2
- the graphics device.drawArea
- the area in which the plot and axes should be drawn.dataArea
- the area in which the plot should be drawn.edge
- the axis location.public java.util.List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge)
refreshTicks
in class Axis
g2
- the graphics device.state
- the axis state.plotArea
- the area in which the plot and the axes should be drawn.dataArea
- the area in which the plot should be drawn.edge
- the location of the axis.
protected java.util.List refreshTicksHorizontal(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge)
g2
- the graphics device.cursor
- the cursor location.plotArea
- the area in which the axes and data are to be drawn.dataArea
- the area in which the data is to be drawn.edge
- the location of the axis.
protected java.util.List refreshTicksVertical(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge)
g2
- the graphics device.cursor
- the cursor location.plotArea
- the area in which the plot and the axes should be drawn.dataArea
- the area in which the plot should be drawn.edge
- the location of the axis.
public AxisState draw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState)
draw
in class Axis
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).
null
).public void zoomRange(double lowerPercent, double upperPercent)
zoomRange
in class ValueAxis
lowerPercent
- the new lower bound.upperPercent
- the new upper bound.public boolean equals(java.lang.Object obj)
equals
in class ValueAxis
obj
- the object to test.
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class ValueAxis
java.lang.CloneNotSupportedException
- if some component of the axis does
not support cloning.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |