Package org.jfree.chart.axis
Class LogAxis
java.lang.Object
org.jfree.chart.axis.Axis
org.jfree.chart.axis.ValueAxis
org.jfree.chart.axis.LogAxis
- All Implemented Interfaces:
Serializable
,Cloneable
,PublicCloneable
A numerical axis that uses a logarithmic scale. The class is an
alternative to the
LogarithmicAxis
class.- See Also:
-
Field Summary
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_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNT
Fields inherited from class org.jfree.chart.axis.Axis
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adjusts the axis range to match the data range that the axis is required to display.double
calculateLog
(double value) Calculates the log of the given value, using the current base.double
calculateValue
(double log) Calculates the value from a given log.void
Configures the axis.protected AttributedString
createTickLabel
(double value) Creates a tick label for the specified value based on the current tick unit (used for formatting the exponent).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
Tests this axis for equality with an arbitrary object.protected double
Estimates the maximum tick label height.protected double
estimateMaximumTickLabelWidth
(Graphics2D g2, TickUnit unit) Estimates the maximum width of the tick labels, assuming the specified tick unit is used.double
exponentLengthToJava2D
(double length, Rectangle2D area, RectangleEdge edge) Converts a length in data coordinates into the corresponding length in Java2D coordinates.double
getBase()
Returns the base for the logarithm calculation.Returns the formatter used to format the base value of the logarithmic scale when it is displayed numerically.Returns the symbol used to represent the base of the logarithmic scale for the axis.Returns the number format override.double
Returns the smallest value represented by the axis.Returns the current tick unit.int
hashCode()
Returns a hash code for this instance.double
java2DToValue
(double java2DValue, Rectangle2D area, RectangleEdge edge) Converts a Java2D coordinate to an axis value, assuming that the axis is aligned to the specifiededge
of thearea
.void
pan
(double percent) Slides the axis range by the specified percentage.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) Returns a list of ticks for an axis at the top or bottom of the chart.protected List
refreshTicksVertical
(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) Returns a list of ticks for an axis at the left or right of the chart.void
resizeRange
(double percent) Increases or decreases the axis range by the specified percentage about the central value and sends anAxisChangeEvent
to all registered listeners.void
resizeRange
(double percent, double anchorValue) Increases or decreases the axis range by the specified percentage about the specified anchor value and sends anAxisChangeEvent
to all registered listeners.void
resizeRange2
(double percent, double anchorValue) Resizes the axis length to the specified percentage of the current range and sends a change event to all registered listeners.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 value for the axis.protected void
selectVerticalAutoTickUnit
(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) Selects an appropriate tick value for the axis.void
setBase
(double base) Sets the base for the logarithm calculation and sends a change event to all registered listeners.void
setBaseFormatter
(Format formatter) Sets the formatter used to format the base value of the logarithmic scale when it is displayed numerically and sends a change event to all registered listeners.void
setBaseSymbol
(String symbol) Sets the symbol used to represent the base value of the logarithmic scale and sends a change event to all registered listeners.void
setNumberFormatOverride
(NumberFormat formatter) Sets the number format override and sends a change event to all registered listeners.void
setSmallestValue
(double value) Sets the smallest value represented by the axis and sends a change event to all registered listeners.void
setTickUnit
(NumberTickUnit unit) Sets the tick unit for the axis and sends anAxisChangeEvent
to all registered listeners.void
setTickUnit
(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect) Sets the tick unit for the axis and, if requested, sends anAxisChangeEvent
to all registered listeners.double
valueToJava2D
(double value, Rectangle2D area, RectangleEdge edge) Converts a value on the axis scale to a Java2D coordinate relative to the givenarea
, based on the axis running along the specifiededge
.void
zoomRange
(double lowerPercent, double upperPercent) Zooms in on the current range.Methods inherited from class org.jfree.chart.axis.ValueAxis
calculateAnchorPoint, centerRange, clone, drawAxisLine, drawTickMarksAndLabels, findMaximumTickLabelHeight, findMaximumTickLabelWidth, getAutoRangeMinimumSize, getAutoTickIndex, getDefaultAutoRange, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getMinorTickCount, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, lengthToJava2D, reserveSpace, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMinorTickCount, setNegativeArrowVisible, setPositiveArrowVisible, setRange, setRange, setRange, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, createAndAddEntity, createAttributedLabel, drawAttributedLabel, drawLabel, fireChangeEvent, getAttributedLabel, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelEnclosure, getLabelFont, getLabelInsets, getLabelLocation, getLabelPaint, getMinorTickMarkInsideLength, getMinorTickMarkOutsideLength, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isMinorTickMarksVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, labelAnchorH, labelAnchorV, labelLocationX, labelLocationY, notifyListeners, 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
-
Constructor Details
-
LogAxis
public LogAxis()Creates a newLogAxis
with no label. -
LogAxis
Creates a newLogAxis
with the given label.- Parameters:
label
- the axis label (null
permitted).
-
-
Method Details
-
getBase
Returns the base for the logarithm calculation. The default value is10.0
.- Returns:
- The base for the logarithm calculation.
- See Also:
-
setBase
Sets the base for the logarithm calculation and sends a change event to all registered listeners.- Parameters:
base
- the base value (must be > 1.0).- See Also:
-
getBaseSymbol
Returns the symbol used to represent the base of the logarithmic scale for the axis. If this isnull
(the default) then the numerical value of the base is displayed.- Returns:
- The base symbol (possibly
null
).
-
setBaseSymbol
Sets the symbol used to represent the base value of the logarithmic scale and sends a change event to all registered listeners.- Parameters:
symbol
- the symbol (null
permitted).
-
getBaseFormatter
Returns the formatter used to format the base value of the logarithmic scale when it is displayed numerically. The default value isnew DecimalFormat("0")
.- Returns:
- The base formatter (never
null
).
-
setBaseFormatter
Sets the formatter used to format the base value of the logarithmic scale when it is displayed numerically and sends a change event to all registered listeners.- Parameters:
formatter
- the formatter (null
not permitted).
-
getSmallestValue
Returns the smallest value represented by the axis.- Returns:
- The smallest value represented by the axis.
- See Also:
-
setSmallestValue
Sets the smallest value represented by the axis and sends a change event to all registered listeners.- Parameters:
value
- the value.- See Also:
-
getTickUnit
Returns the current tick unit.- Returns:
- The current tick unit.
- See Also:
-
setTickUnit
Sets the tick unit for the axis and sends anAxisChangeEvent
to all registered listeners. A side effect of calling this method is that the "auto-select" feature for tick units is switched off (you can restore it using theValueAxis.setAutoTickUnitSelection(boolean)
method).- Parameters:
unit
- the new tick unit (null
not permitted).- See Also:
-
setTickUnit
Sets the tick unit for the axis and, if requested, sends anAxisChangeEvent
to all registered listeners. In addition, an option is provided to turn off the "auto-select" feature for tick units (you can restore it using theValueAxis.setAutoTickUnitSelection(boolean)
method).- Parameters:
unit
- the new tick unit (null
not permitted).notify
- notify listeners?turnOffAutoSelect
- turn off the auto-tick selection?- See Also:
-
getNumberFormatOverride
Returns the number format override. If this is non-null
, then it will be used to format the numbers on the axis.- Returns:
- The number formatter (possibly
null
). - See Also:
-
setNumberFormatOverride
Sets the number format override and sends a change event to all registered listeners. If this is non-null
, then it will be used to format the numbers on the axis.- Parameters:
formatter
- the number formatter (null
permitted).- See Also:
-
calculateLog
Calculates the log of the given value, using the current base.- Parameters:
value
- the value.- Returns:
- The log of the given value.
- See Also:
-
calculateValue
Calculates the value from a given log.- Parameters:
log
- the log value.- Returns:
- The value with the given log.
- See Also:
-
java2DToValue
Converts a Java2D coordinate to an axis value, assuming that the axis is aligned to the specifiededge
of thearea
.- Specified by:
java2DToValue
in classValueAxis
- Parameters:
java2DValue
- the Java2D coordinate.area
- the area for plotting data (null
not permitted).edge
- the edge that the axis is aligned to (null
not permitted).- Returns:
- A value along the axis scale.
- See Also:
-
valueToJava2D
Converts a value on the axis scale to a Java2D coordinate relative to the givenarea
, based on the axis running along the specifiededge
.- Specified by:
valueToJava2D
in classValueAxis
- Parameters:
value
- the data value.area
- the area (null
not permitted).edge
- the edge (null
not permitted).- Returns:
- The Java2D coordinate corresponding to
value
. - See Also:
-
configure
Configures the axis. This method is typically called when an axis is assigned to a new plot. -
autoAdjustRange
Adjusts the axis range to match the data range that the axis is required to display.- Specified by:
autoAdjustRange
in classValueAxis
-
draw
public 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).- Specified by:
draw
in classAxis
- Parameters:
g2
- the graphics device (null
not permitted).cursor
- the cursor location (determines where to draw the axis).plotArea
- the area within which the axes and plot should be drawn.dataArea
- the area within which the data should be drawn.edge
- the axis location (null
not permitted).plotState
- collects information about the plot (null
permitted).- Returns:
- The axis state (never
null
).
-
refreshTicks
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).- Specified by:
refreshTicks
in classAxis
- 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.
-
refreshTicksHorizontal
Returns a list of ticks for an axis at the top or bottom of the chart.- Parameters:
g2
- the graphics device (null
not permitted).dataArea
- the data area (null
not permitted).edge
- the edge (null
not permitted).- Returns:
- A list of ticks.
-
refreshTicksVertical
Returns a list of ticks for an axis at the left or right of the chart.- Parameters:
g2
- the graphics device (null
not permitted).dataArea
- the data area (null
not permitted).edge
- the edge that the axis is aligned to (null
not permitted).- Returns:
- A list of ticks.
-
selectAutoTickUnit
Selects an appropriate tick value for the axis. The strategy is to display as many ticks as possible (selected from an array of 'standard' tick units) without the labels overlapping.- Parameters:
g2
- the graphics device (null
not permitted).dataArea
- the area defined by the axes (null
not permitted).edge
- the axis location (null
not permitted).
-
selectHorizontalAutoTickUnit
protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) Selects an appropriate tick value for the axis. The strategy is to display as many ticks as possible (selected from an array of 'standard' tick units) without the labels overlapping.- Parameters:
g2
- the graphics device.dataArea
- the area defined by the axes.edge
- the axis location.
-
exponentLengthToJava2D
Converts a length in data coordinates into the corresponding length in Java2D coordinates.- Parameters:
length
- the length.area
- the plot area.edge
- the edge along which the axis lies.- Returns:
- The length in Java2D coordinates.
-
selectVerticalAutoTickUnit
Selects an appropriate tick value for the axis. The strategy is to display as many ticks as possible (selected from an array of 'standard' tick units) without the labels overlapping.- Parameters:
g2
- the graphics device.dataArea
- the area in which the plot should be drawn.edge
- the axis location.
-
createTickLabel
Creates a tick label for the specified value based on the current tick unit (used for formatting the exponent).- Parameters:
value
- the value.- Returns:
- The label.
-
estimateMaximumTickLabelHeight
Estimates the maximum tick label height.- Parameters:
g2
- the graphics device.- Returns:
- The maximum height.
-
estimateMaximumTickLabelWidth
Estimates the maximum width of the tick labels, assuming the specified tick unit is used.Rather than computing the string bounds of every tick on the axis, we just look at two values: the lower bound and the upper bound for the axis. These two values will usually be representative.
- Parameters:
g2
- the graphics device.unit
- the tick unit to use for calculation.- Returns:
- The estimated maximum width of the tick labels.
-
zoomRange
Zooms in on the current range. -
pan
Slides the axis range by the specified percentage. -
resizeRange
Increases or decreases the axis range by the specified percentage about the central value and sends anAxisChangeEvent
to all registered listeners.To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).
- Overrides:
resizeRange
in classValueAxis
- Parameters:
percent
- the resize factor.- See Also:
-
resizeRange
Description copied from class:ValueAxis
Increases or decreases the axis range by the specified percentage about the specified anchor value and sends anAxisChangeEvent
to all registered listeners.To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).
- Overrides:
resizeRange
in classValueAxis
- Parameters:
percent
- the resize factor.anchorValue
- the new central value after the resize.- See Also:
-
resizeRange2
Resizes the axis length to the specified percentage of the current range and sends a change event to all registered listeners. Ifpercent
is greater than 1.0 (100 percent) then the axis range is increased (which has the effect of zooming out), while if thepercent
is less than 1.0 the axis range is decreased (which has the effect of zooming in). The resize occurs around an anchor value (which may not be in the center of the axis). This is used to support mouse wheel zooming around an arbitrary point on the plot.
This method is overridden to perform the percentage calculations on the log values (which are linear for this axis).- Overrides:
resizeRange2
in classValueAxis
- Parameters:
percent
- the percentage (must be greater than zero).anchorValue
- the anchor value.- See Also:
-
equals
Tests this axis for equality with an arbitrary object. -
hashCode
Returns a hash code for this instance.
-