org.jfree.chart.axis
Class HorizontalLogarithmicAxis

java.lang.Object
  |
  +--org.jfree.chart.axis.Axis
        |
        +--org.jfree.chart.axis.ValueAxis
              |
              +--org.jfree.chart.axis.NumberAxis
                    |
                    +--org.jfree.chart.axis.HorizontalNumberAxis
                          |
                          +--org.jfree.chart.axis.HorizontalLogarithmicAxis
All Implemented Interfaces:
AxisConstants, HorizontalAxis, java.io.Serializable
Direct Known Subclasses:
HorizontalLogarithmicColorBarAxis

public class HorizontalLogarithmicAxis
extends HorizontalNumberAxis
implements java.io.Serializable

A logarithmic value axis, for values displayed horizontally. Display of positive values arbitrarily close to zero is supported, as well as negative values (if 'allowNegativesFlag' flag set).

Author:
Eric Thomas
See Also:
Serialized Form

Field Summary
static double LOG10_VALUE
          Useful constant for log(10).
static double SMALL_LOG_VALUE
          Smallest arbitrarily-close-to-zero value allowed.
 
Fields inherited from class org.jfree.chart.axis.HorizontalNumberAxis
DEFAULT_VERTICAL_TICK_LABELS
 
Fields inherited from class org.jfree.chart.axis.NumberAxis
DEFAULT_AUTO_RANGE_INCLUDES_ZERO, DEFAULT_AUTO_RANGE_STICKY_ZERO, DEFAULT_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
 
Fields inherited from interface org.jfree.chart.axis.AxisConstants
BOTTOM, DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, 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, LEFT, RIGHT, TOP
 
Constructor Summary
HorizontalLogarithmicAxis(java.lang.String label)
          Constructs a horizontal logarithmic axis, using default attribute values where necessary.
 
Method Summary
 double adjustedLog10(double val)
          Returns an adjusted log10 value for graphing purposes.
 void autoAdjustRange()
          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 getAllowNegativesFlag()
          Returns the 'allowNegativesFlag' flag; true to allow negative values in data, false to be able to plot positive values arbitrarily close to zero.
 void refreshTicks(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D dataArea, int location)
          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 setRange(Range range)
          Overridden version that calls original and then sets up flag for log axis processing.
protected  void setupSmallLogFlag()
          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 translateJava2DtoValue(float java2DValue, java.awt.geom.Rectangle2D plotArea)
          Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified plotArea.
 double translateValueToJava2D(double value, java.awt.geom.Rectangle2D plotArea)
          Converts a data value to a coordinate in Java2D space, assuming that the axis runs along one edge of the specified plotArea.
 
Methods inherited from class org.jfree.chart.axis.HorizontalNumberAxis
configure, draw, getMarkerBand, isCompatiblePlot, isVerticalTickLabels, reserveHeight, reserveHeight, selectAutoTickUnit, setMarkerBand, setVerticalTickLabels
 
Methods inherited from class org.jfree.chart.axis.NumberAxis
autoRangeIncludesZero, autoRangeStickyZero, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, getNumberFormatOverride, getTickUnit, setAutoRangeIncludesZero, setAutoRangeStickyZero, setNumberFormatOverride, setTickUnit, setTickUnit
 
Methods inherited from class org.jfree.chart.axis.ValueAxis
centerRange, getAnchorValue, getAutoRangeMinimumSize, getAutoTickIndex, getFixedAutoRange, getLowerMargin, getMaximumAxisValue, getMinimumAxisValue, getRange, getStandardTickUnits, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, resizeRange, resizeRange, setAnchoredRange, setAnchorValue, setAnchorValueAttribute, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setFixedAutoRange, setInverted, setLowerMargin, setMaximumAxisValue, setMinimumAxisValue, setRange, setRangeAboutValue, setRangeAttribute, setStandardTickUnits, setUpperMargin
 
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, drawHorizontalLabel, drawVerticalLabel, equals, getFixedDimension, getLabel, getLabelFont, getLabelInsets, getLabelPaint, getMaxTickLabelWidth, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, getTicks, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, removeChangeListener, setFixedDimension, setLabel, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG10_VALUE

public static final double LOG10_VALUE
Useful constant for log(10).


SMALL_LOG_VALUE

public static final double SMALL_LOG_VALUE
Smallest arbitrarily-close-to-zero value allowed.

See Also:
Constant Field Values
Constructor Detail

HorizontalLogarithmicAxis

public HorizontalLogarithmicAxis(java.lang.String label)
Constructs a horizontal logarithmic axis, using default attribute values where necessary.

Parameters:
label - the axis label (null permitted).
Method Detail

setAllowNegativesFlag

public 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.

Parameters:
flgVal - the new value of the flag.

getAllowNegativesFlag

public boolean 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.

setRange

public void setRange(Range range)
Overridden version that calls original and then sets up flag for log axis processing.

Overrides:
setRange in class ValueAxis
Parameters:
range - the new range.

setupSmallLogFlag

protected void setupSmallLogFlag()
Sets up flag for log axis processing.


translateValueToJava2D

public double translateValueToJava2D(double value,
                                     java.awt.geom.Rectangle2D plotArea)
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:
translateValueToJava2D in class HorizontalNumberAxis
Parameters:
value - the data value.
plotArea - the area for plotting the data.
Returns:
the Java2D coordinate.

translateJava2DtoValue

public double translateJava2DtoValue(float java2DValue,
                                     java.awt.geom.Rectangle2D plotArea)
Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified plotArea.

Overrides:
translateJava2DtoValue in class HorizontalNumberAxis
Parameters:
java2DValue - the coordinate in Java2D space.
plotArea - the area in which the data is plotted.
Returns:
the data value.

autoAdjustRange

public void autoAdjustRange()
Rescales the axis to ensure that all data is visible.

Overrides:
autoAdjustRange in class HorizontalNumberAxis

computeLogCeil

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.).

Parameters:
upper - a double value above which a ceiling will be calcualted.
Returns:
10N with N ... { 1 .. MAX_LONG }.

computeLogFloor

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.).

Parameters:
lower - a double value below which a floor will be calcualted.
Returns:
10N with N ... { 1 .. MAX_LONG }.

refreshTicks

public void refreshTicks(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D drawArea,
                         java.awt.geom.Rectangle2D dataArea,
                         int location)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).

Overrides:
refreshTicks in class HorizontalNumberAxis
Parameters:
g2 - the graphics device.
drawArea - the area in which the plot and the axes should be drawn.
dataArea - the area in which the plot should be drawn.
location - the location of the axis.

switchedLog10

protected double switchedLog10(double val)
Returns the log10 value, depending on if values between 0 and 1 are being plotted.

Parameters:
val - value for which log10 should be calculated.
Returns:
log10(val).

adjustedLog10

public double adjustedLog10(double val)
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).