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.
Modifier and Type | Field and Description |
---|---|
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
Deprecated.
As pointed out in bug #977, the SimpleDateFormat in this
object uses Calendar which is not thread safe...so you should
avoid reusing this instance and create a new instance as required.
|
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
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_AXIS_LINE_PAINT, DEFAULT_AXIS_LINE_STROKE, DEFAULT_AXIS_VISIBLE, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE, DEFAULT_TICK_MARKS_VISIBLE
Constructor and Description |
---|
DateAxis()
Creates a date axis with no label.
|
DateAxis(String label)
Creates a date axis with the specified label.
|
DateAxis(String label,
TimeZone zone)
Deprecated.
From 1.0.11 onwards, use
DateAxis(String, TimeZone,
Locale) instead, to explicitly set the locale. |
DateAxis(String label,
TimeZone zone,
Locale locale)
Creates a date axis.
|
Modifier and Type | Method and Description |
---|---|
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)
Deprecated.
Since 1.0.11, use
createStandardDateTickUnits(
TimeZone, Locale) to explicitly set the locale as well as the
time zone. |
static TickUnitSource |
createStandardDateTickUnits(TimeZone zone,
Locale locale)
Returns a collection of standard date tick units.
|
double |
dateToJava2D(Date date,
Rectangle2D area,
org.jfree.ui.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,
org.jfree.ui.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.
|
Locale |
getLocale()
Returns the locale for this axis.
|
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,
org.jfree.ui.RectangleEdge edge)
Translates a Java2D coordinate into the corresponding data value.
|
List |
refreshTicks(Graphics2D g2,
AxisState state,
Rectangle2D dataArea,
org.jfree.ui.RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
|
void |
setDateFormatOverride(DateFormat formatter)
Sets the date format override and sends an
AxisChangeEvent to
all registered listeners. |
void |
setLocale(Locale locale)
Sets the locale for the axis and sends a change event to all registered
listeners.
|
void |
setMaximumDate(Date maximumDate)
Sets the maximum date visible on the axis and sends an
AxisChangeEvent to all registered listeners. |
void |
setMinimumDate(Date date)
Sets the minimum date visible on the axis and 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 |
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 and, if requested, sends an
AxisChangeEvent to all registered listeners. |
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,
org.jfree.ui.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 (zoom-in stops once the axis length
reaches the equivalent of one millisecond).
|
centerRange, getAutoRangeMinimumSize, getDefaultAutoRange, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getMinorTickCount, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, lengthToJava2D, pan, reserveSpace, resizeRange, resizeRange, resizeRange2, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMinorTickCount, setNegativeArrowVisible, setPositiveArrowVisible, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels
addChangeListener, createAttributedLabel, getAttributedLabel, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelFont, getLabelInsets, getLabelLocation, getLabelPaint, getMinorTickMarkInsideLength, getMinorTickMarkOutsideLength, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isMinorTickMarksVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, removeChangeListener, setAttributedLabel, setAttributedLabel, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelInsets, setLabelLocation, setLabelPaint, setMinorTickMarkInsideLength, setMinorTickMarkOutsideLength, setMinorTickMarksVisible, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
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 Date DEFAULT_ANCHOR_DATE
public DateAxis()
public DateAxis(String label)
label
- the axis label (null
permitted).public DateAxis(String label, TimeZone zone)
DateAxis(String, TimeZone,
Locale)
instead, to explicitly set the locale.label
- the axis label (null
permitted).zone
- the time zone.SegmentedTimeline
public DateAxis(String label, TimeZone zone, Locale locale)
label
- the axis label (null
permitted).zone
- the time zone.locale
- the locale (null
not permitted).SegmentedTimeline
public TimeZone getTimeZone()
null
).setTimeZone(TimeZone)
public void setTimeZone(TimeZone zone)
AxisChangeEvent
to
all registered listeners.zone
- the time zone (null
not permitted).getTimeZone()
public Locale getLocale()
null
).public void setLocale(Locale locale)
locale
- the new locale (null
not permitted).public Timeline getTimeline()
public void setTimeline(Timeline timeline)
AxisChangeEvent
is sent to all registered listeners.timeline
- the timeline.public DateTickUnit getTickUnit()
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.
null
).setTickUnit(DateTickUnit)
,
ValueAxis.isAutoTickUnitSelection()
public void setTickUnit(DateTickUnit unit)
false
, and registered listeners are notified that
the axis has been changed.unit
- the tick unit.getTickUnit()
,
setTickUnit(DateTickUnit, boolean, boolean)
public void setTickUnit(DateTickUnit unit, boolean notify, boolean turnOffAutoSelection)
AxisChangeEvent
to all registered listeners.unit
- the new tick unit.notify
- notify registered listeners?turnOffAutoSelection
- turn off auto selection?getTickUnit()
public DateFormat getDateFormatOverride()
null
).public void setDateFormatOverride(DateFormat formatter)
AxisChangeEvent
to
all registered listeners. If this is non-null, then it will be
used to format the dates on the axis.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).ValueAxis.getRange()
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.ValueAxis.getRange()
public void setRange(Date lower, 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.ValueAxis.getRange()
,
ValueAxis.setRange(Range)
public Date getMinimumDate()
setMinimumDate(Date)
,
getMaximumDate()
public void setMinimumDate(Date date)
AxisChangeEvent
to all registered listeners. If
date
is on or after the current maximum date for
the axis, the maximum date will be shifted to preserve the current
length of the axis.date
- the date (null
not permitted).getMinimumDate()
,
setMaximumDate(Date)
public Date getMaximumDate()
setMaximumDate(Date)
,
getMinimumDate()
public void setMaximumDate(Date maximumDate)
AxisChangeEvent
to all registered listeners. If
maximumDate
is on or before the current minimum date for
the axis, the minimum date will be shifted to preserve the current
length of the axis.maximumDate
- the date (null
not permitted).getMinimumDate()
,
setMinimumDate(Date)
public DateTickMarkPosition getTickMarkPosition()
null
).public void setTickMarkPosition(DateTickMarkPosition position)
AxisChangeEvent
to all registered listeners.position
- the position (null
not permitted).public void configure()
public boolean isHiddenValue(long millis)
true
if the axis hides this value, and
false
otherwise.millis
- the data value.public double valueToJava2D(double value, Rectangle2D area, org.jfree.ui.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.ValueAxis.java2DToValue(double, Rectangle2D, RectangleEdge)
public double dateToJava2D(Date date, Rectangle2D area, org.jfree.ui.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, Rectangle2D area, org.jfree.ui.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.ValueAxis.valueToJava2D(double, Rectangle2D, RectangleEdge)
public Date calculateLowestVisibleTickValue(DateTickUnit unit)
unit
- date unit to use.public Date calculateHighestVisibleTickValue(DateTickUnit unit)
unit
- date unit to use.public static TickUnitSource createStandardDateTickUnits()
ValueAxis.setStandardTickUnits(TickUnitSource)
method inherited
from the ValueAxis
class).public static TickUnitSource createStandardDateTickUnits(TimeZone zone, Locale locale)
ValueAxis.setStandardTickUnits(TickUnitSource)
method inherited
from the ValueAxis
class).zone
- the time zone (null
not permitted).locale
- the locale (null
not permitted).public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
refreshTicks
in class Axis
g2
- the graphics device.state
- the axis state.dataArea
- the area in which the plot should be drawn.edge
- the location of the axis.public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, org.jfree.ui.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)
public boolean equals(Object obj)
public int hashCode()
public Object clone() throws CloneNotSupportedException
clone
in interface org.jfree.util.PublicCloneable
clone
in class ValueAxis
CloneNotSupportedException
- if some component of the axis does
not support cloning.public static TickUnitSource createStandardDateTickUnits(TimeZone zone)
createStandardDateTickUnits(
TimeZone, Locale)
to explicitly set the locale as well as the
time zone.ValueAxis.setStandardTickUnits(TickUnitSource)
method inherited
from the ValueAxis
class).zone
- the time zone (null
not permitted).Jas4pp 1.5 © Java Analysis Studio for Particle Physics