Package org.jfree.chart.axis
Class LogarithmicAxis
java.lang.Object
org.jfree.chart.axis.Axis
org.jfree.chart.axis.ValueAxis
org.jfree.chart.axis.NumberAxis
org.jfree.chart.axis.LogarithmicAxis
- All Implemented Interfaces:
Serializable
,Cloneable
,PublicCloneable
A numerical axis that uses a logarithmic scale.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Flag set true to allow negative values in data.protected boolean
True to make 'autoAdjustRange()' select "10^n" values.protected boolean
Flag set true for "1e#"-style tick labels.static final double
Useful constant for log(10).protected boolean
Flag set true for "10^n"-style tick labels.protected final NumberFormat
Number formatter for generating numeric strings.static final double
Smallest arbitrarily-close-to-zero value allowed.protected boolean
Helper flag for log axis processing.protected boolean
Flag set true make axis throw exception if any values are <= 0 and 'allowNegativesFlag' is false.Fields inherited from class org.jfree.chart.axis.NumberAxis
DEFAULT_AUTO_RANGE_INCLUDES_ZERO, DEFAULT_AUTO_RANGE_STICKY_ZERO, DEFAULT_TICK_UNIT, DEFAULT_VERTICAL_TICK_LABELS
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 TypeMethodDescriptiondouble
adjustedLog10
(double val) Returns an adjusted log10 value for graphing purposes.double
adjustedPow10
(double val) Returns an adjusted power of 10 value for graphing purposes.void
Rescales the axis to ensure that all data is visible.protected double
computeLogCeil
(double upper) Returns the smallest (closest to negative infinity) double value that is not less than the argument, is equal to a mathematical integer and satisfying the condition that log base 10 of the value is an integer (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.).protected double
computeLogFloor
(double lower) Returns the largest (closest to positive infinity) double value that is not greater than the argument, is equal to a mathematical integer and satisfying the condition that log base 10 of the value is an integer (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.).boolean
Returns the 'allowNegativesFlag' flag; true to allow negative values in data, false to be able to plot positive values arbitrarily close to zero.boolean
Returns the 'autoRangeNextLogFlag' flag.boolean
Returns the 'expTickLabelsFlag' flag.boolean
Returns the 'log10TickLabelsFlag' flag.boolean
Returns the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' is false then this axis will throw a runtime exception if any of its values are less than or equal to zero; if false then the axis will adjust for values less than or equal to zero as needed.double
java2DToValue
(double java2DValue, Rectangle2D plotArea, RectangleEdge edge) Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified plotArea.protected String
makeTickLabel
(double val) Converts the given value to a tick label string.protected String
makeTickLabel
(double val, boolean forceFmtFlag) Converts the given value to a tick label string.protected List
refreshTicksHorizontal
(Graphics2D g2, 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
refreshTicksVertical
(Graphics2D g2, 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).void
setAllowNegativesFlag
(boolean flgVal) Sets the 'allowNegativesFlag' flag; true to allow negative values in data, false to be able to plot positive values arbitrarily close to zero.void
setAutoRangeNextLogFlag
(boolean flag) Sets the 'autoRangeNextLogFlag' flag.void
setExpTickLabelsFlag
(boolean flgVal) Sets the 'expTickLabelsFlag' flag.void
setLog10TickLabelsFlag
(boolean flag) Sets the 'log10TickLabelsFlag' flag.void
Overridden version that calls original and then sets up flag for log axis processing.void
setStrictValuesFlag
(boolean flgVal) Sets the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' is false then this axis will throw a runtime exception if any of its values are less than or equal to zero; if false then the axis will adjust for values less than or equal to zero as needed.protected void
Sets up the number formatter object according to the 'expTickLabelsFlag' flag.protected void
Sets up flag for log axis processing.protected double
switchedLog10
(double val) Returns the log10 value, depending on if values between 0 and 1 are being plotted.double
switchedPow10
(double val) Returns a power of 10, depending on if values between 0 and 1 are being plotted.double
valueToJava2D
(double value, Rectangle2D plotArea, RectangleEdge edge) Converts a data value to a coordinate in Java2D space, assuming that the axis runs along one edge of the specified plotArea.void
zoomRange
(double lowerPercent, double upperPercent) Zooms in on the current range.Methods inherited from class org.jfree.chart.axis.NumberAxis
calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, clone, configure, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, draw, equals, estimateMaximumTickLabelHeight, estimateMaximumTickLabelWidth, getAutoRangeIncludesZero, getAutoRangeStickyZero, getMarkerBand, getNumberFormatOverride, getRangeType, getTickUnit, hashCode, refreshTicks, selectAutoTickUnit, selectHorizontalAutoTickUnit, selectVerticalAutoTickUnit, setAutoRangeIncludesZero, setAutoRangeStickyZero, setMarkerBand, setNumberFormatOverride, setRangeType, setTickUnit, setTickUnit
Methods inherited from class org.jfree.chart.axis.ValueAxis
calculateAnchorPoint, centerRange, 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, pan, reserveSpace, resizeRange, resizeRange, resizeRange2, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMinorTickCount, setNegativeArrowVisible, setPositiveArrowVisible, 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
-
Field Details
-
LOG10_VALUE
Useful constant for log(10). -
SMALL_LOG_VALUE
Smallest arbitrarily-close-to-zero value allowed.- See Also:
-
allowNegativesFlag
Flag set true to allow negative values in data. -
strictValuesFlag
Flag set true make axis throw exception if any values are <= 0 and 'allowNegativesFlag' is false. -
numberFormatterObj
Number formatter for generating numeric strings. -
expTickLabelsFlag
Flag set true for "1e#"-style tick labels. -
log10TickLabelsFlag
Flag set true for "10^n"-style tick labels. -
autoRangeNextLogFlag
True to make 'autoAdjustRange()' select "10^n" values. -
smallLogFlag
Helper flag for log axis processing.
-
-
Constructor Details
-
LogarithmicAxis
Creates a new axis.- Parameters:
label
- the axis label.
-
-
Method Details
-
setAllowNegativesFlag
Sets the 'allowNegativesFlag' flag; true to allow negative values in data, false to be able to plot positive values arbitrarily close to zero.- Parameters:
flgVal
- the new value of the flag.
-
getAllowNegativesFlag
Returns the 'allowNegativesFlag' flag; true to allow negative values in data, false to be able to plot positive values arbitrarily close to zero.- Returns:
- The flag.
-
setStrictValuesFlag
Sets the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' is false then this axis will throw a runtime exception if any of its values are less than or equal to zero; if false then the axis will adjust for values less than or equal to zero as needed.- Parameters:
flgVal
- true for strict enforcement.
-
getStrictValuesFlag
Returns the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' is false then this axis will throw a runtime exception if any of its values are less than or equal to zero; if false then the axis will adjust for values less than or equal to zero as needed.- Returns:
true
if strict enforcement is enabled.
-
setExpTickLabelsFlag
Sets the 'expTickLabelsFlag' flag. If the 'log10TickLabelsFlag' is false then this will set whether or not "1e#"-style tick labels are used. The default is to use regular numeric tick labels.- Parameters:
flgVal
- true for "1e#"-style tick labels, false for log10 or regular numeric tick labels.
-
getExpTickLabelsFlag
Returns the 'expTickLabelsFlag' flag.- Returns:
true
for "1e#"-style tick labels,false
for log10 or regular numeric tick labels.
-
setLog10TickLabelsFlag
Sets the 'log10TickLabelsFlag' flag. The default value is false.- Parameters:
flag
- true for "10^n"-style tick labels, false for "1e#"-style or regular numeric tick labels.
-
getLog10TickLabelsFlag
Returns the 'log10TickLabelsFlag' flag.- Returns:
true
for "10^n"-style tick labels,false
for "1e#"-style or regular numeric tick labels.
-
setAutoRangeNextLogFlag
Sets the 'autoRangeNextLogFlag' flag. This determines whether or not the 'autoAdjustRange()' method will select the next "10^n" values when determining the upper and lower bounds. The default value is false.- Parameters:
flag
-true
to make the 'autoAdjustRange()' method select the next "10^n" values,false
to not.
-
getAutoRangeNextLogFlag
Returns the 'autoRangeNextLogFlag' flag.- Returns:
true
if the 'autoAdjustRange()' method will select the next "10^n" values,false
if not.
-
setRange
Overridden version that calls original and then sets up flag for log axis processing. -
setupSmallLogFlag
Sets up flag for log axis processing. Set true if negative values not allowed and the lower bound is between 0 and 10. -
setupNumberFmtObj
Sets up the number formatter object according to the 'expTickLabelsFlag' flag. -
switchedLog10
Returns the log10 value, depending on if values between 0 and 1 are being plotted. If negative values are not allowed and the lower bound is between 0 and 10 then a normal log is returned; otherwise the returned value is adjusted if the given value is less than 10.- Parameters:
val
- the value.- Returns:
- log10(val).
- See Also:
-
switchedPow10
Returns a power of 10, depending on if values between 0 and 1 are being plotted. If negative values are not allowed and the lower bound is between 0 and 10 then a normal power is returned; otherwise the returned value is adjusted if the given value is less than 1.- Parameters:
val
- the value.- Returns:
- 10val.
- See Also:
-
adjustedLog10
Returns an adjusted log10 value for graphing purposes. The first adjustment is that negative values are changed to positive during the calculations, and then the answer is negated at the end. The second is that, for values less than 10, an increasingly large (0 to 1) scaling factor is added such that at 0 the value is adjusted to 1, resulting in a returned result of 0.- Parameters:
val
- value for which log10 should be calculated.- Returns:
- An adjusted log10(val).
- See Also:
-
adjustedPow10
Returns an adjusted power of 10 value for graphing purposes. The first adjustment is that negative values are changed to positive during the calculations, and then the answer is negated at the end. The second is that, for values less than 1, a progressive logarithmic offset is subtracted such that at 0 the returned result is also 0.- Parameters:
val
- value for which power of 10 should be calculated.- Returns:
- An adjusted 10val.
- See Also:
-
computeLogFloor
Returns the largest (closest to positive infinity) double value that is not greater than the argument, is equal to a mathematical integer and satisfying the condition that log base 10 of the value is an integer (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.).- Parameters:
lower
- a double value below which a floor will be calcualted.- Returns:
- 10N with N .. { 1 ... }
-
computeLogCeil
Returns the smallest (closest to negative infinity) double value that is not less than the argument, is equal to a mathematical integer and satisfying the condition that log base 10 of the value is an integer (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.).- Parameters:
upper
- a double value above which a ceiling will be calcualted.- Returns:
- 10N with N .. { 1 ... }
-
autoAdjustRange
Rescales the axis to ensure that all data is visible.- Overrides:
autoAdjustRange
in classNumberAxis
-
valueToJava2D
Converts a data value to a coordinate in Java2D space, assuming that the axis runs along one edge of the specified plotArea. Note that it is possible for the coordinate to fall outside the plotArea.- Overrides:
valueToJava2D
in classNumberAxis
- Parameters:
value
- the data value.plotArea
- the area for plotting the data.edge
- the axis location.- Returns:
- The Java2D coordinate.
- See Also:
-
java2DToValue
Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified plotArea.- Overrides:
java2DToValue
in classNumberAxis
- Parameters:
java2DValue
- the coordinate in Java2D space.plotArea
- the area in which the data is plotted.edge
- the axis location.- Returns:
- The data value.
- See Also:
-
zoomRange
Zooms in on the current range. -
refreshTicksHorizontal
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).- Overrides:
refreshTicksHorizontal
in classNumberAxis
- 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.
-
refreshTicksVertical
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).- Overrides:
refreshTicksVertical
in classNumberAxis
- 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.
-
makeTickLabel
Converts the given value to a tick label string.- Parameters:
val
- the value to convert.forceFmtFlag
- true to force the number-formatter object to be used.- Returns:
- The tick label string.
-
makeTickLabel
Converts the given value to a tick label string.- Parameters:
val
- the value to convert.- Returns:
- The tick label string.
-