com.jrefinery.chart
Class VerticalLogarithmicAxis

java.lang.Object
  |
  +--com.jrefinery.chart.Axis
        |
        +--com.jrefinery.chart.ValueAxis
              |
              +--com.jrefinery.chart.NumberAxis
                    |
                    +--com.jrefinery.chart.VerticalNumberAxis
                          |
                          +--com.jrefinery.chart.VerticalLogarithmicAxis
All Implemented Interfaces:
AxisConstants, VerticalAxis

public class VerticalLogarithmicAxis
extends VerticalNumberAxis

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

Author:
MD

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 com.jrefinery.chart.NumberAxis
DEFAULT_AUTO_RANGE_INCLUDES_ZERO, DEFAULT_AUTO_RANGE_STICKY_ZERO, DEFAULT_TICK_UNIT
 
Fields inherited from class com.jrefinery.chart.ValueAxis
DEFAULT_AUTO_RANGE, DEFAULT_AUTO_RANGE_MINIMUM_SIZE, DEFAULT_CROSSHAIR_PAINT, DEFAULT_CROSSHAIR_STROKE, DEFAULT_CROSSHAIR_VISIBLE, DEFAULT_GRID_LINE_PAINT, DEFAULT_GRID_LINE_STROKE, DEFAULT_LOWER_BOUND, DEFAULT_LOWER_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_BOUND, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNT
 
Fields inherited from class com.jrefinery.chart.Axis
fixedDimension, label, labelFont, labelInsets, labelPaint, plot, tickLabelFont, tickLabelInsets, tickLabelPaint, tickLabelsVisible, tickMarkPaint, tickMarkStroke, tickMarksVisible, ticks, visible
 
Fields inherited from interface com.jrefinery.chart.AxisConstants
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_PAINT, DEFAULT_TICK_STROKE
 
Constructor Summary
VerticalLogarithmicAxis()
          Constructs a vertical logarithmic axis, using default values where necessary.
VerticalLogarithmicAxis(java.lang.String label)
          Constructs a vertical logarithmic axis, using default values where necessary.
VerticalLogarithmicAxis(java.lang.String label, java.awt.Font labelFont, double lowerBound, double upperBound)
          Constructs a vertical logarithmic axis.
VerticalLogarithmicAxis(java.lang.String label, java.awt.Font labelFont, java.awt.Paint labelPaint, java.awt.Insets labelInsets, boolean labelDrawnVertical, boolean tickLabelsVisible, java.awt.Font tickLabelFont, java.awt.Paint tickLabelPaint, java.awt.Insets tickLabelInsets, boolean tickMarksVisible, java.awt.Stroke tickMarkStroke, java.awt.Paint tickMarkPaint, boolean autoRange, java.lang.Number autoRangeMinimumSize, boolean autoRangeIncludesZero, double lowerBound, double upperBound, boolean inverted, boolean autoTickUnitSelection, NumberTickUnit tickUnit, boolean gridLinesVisible, java.awt.Stroke gridStroke, java.awt.Paint gridPaint, double anchorValue, boolean crosshairVisible, double crosshairValue, java.awt.Stroke crosshairStroke, java.awt.Paint crosshairPaint, boolean log10TickLabelsFlag, boolean allowNegativesFlag)
          Constructs a vertical number axis.
 
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.
 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.
 boolean getLog10TickLabelsFlag()
          Returns the 'log10TickLabelsFlag' flag; true for "10^n"-style tick labels, false for regular numeric labels.
 void refreshTicks(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea)
          Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
 void setAllowNegativesFlag(boolean flag)
          Sets the 'allowNegativesFlag' flag; true to allow negative values in data, false to be able to plot positive values arbitrarily close to zero.
 void setLog10TickLabelsFlag(boolean flag)
          Sets the 'log10TickLabelsFlag' flag; true for "10^n"-style tick labels, false for regular numeric labels.
 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 dataArea)
          Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified dataArea.
 double translateValueToJava2D(double value, java.awt.geom.Rectangle2D dataArea)
          Converts a data value to a coordinate in Java2D space, assuming that the axis runs along one edge of the specified plot area.
 
Methods inherited from class com.jrefinery.chart.VerticalNumberAxis
configure, draw, isCompatiblePlot, isVerticalLabel, reserveAxisArea, reserveWidth, selectAutoTickUnit, setVerticalLabel
 
Methods inherited from class com.jrefinery.chart.NumberAxis
autoRangeIncludesZero, autoRangeStickyZero, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, getTickUnit, isInverted, setAutoRangeIncludesZero, setAutoRangeStickyZero, setInverted, setTickUnit, setTickUnitAttribute
 
Methods inherited from class com.jrefinery.chart.ValueAxis
centerRange, getAnchorValue, getAutoRangeMinimumSize, getAutoTickIndex, getCrosshairPaint, getCrosshairStroke, getCrosshairValue, getFixedAutoRange, getGridPaint, getGridStroke, getLowerMargin, getMaximumAxisValue, getMinimumAxisValue, getRange, getStandardTickUnits, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isCrosshairLockedOnData, isCrosshairVisible, isGridLinesVisible, resizeRange, resizeRange, setAnchoredRange, setAnchorValue, setAnchorValueAttribute, setAutoRange, setAutoRangeAttribute, setAutoRangeMinimumSize, setAutoRangeMinimumSizeAttribute, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelectionAttribute, setCrosshairLockedOnData, setCrosshairPaint, setCrosshairStroke, setCrosshairValue, setCrosshairValue, setCrosshairValueAttribute, setCrosshairVisible, setFixedAutoRange, setGridLinesVisible, setGridPaint, setGridStroke, setLowerMargin, setMaximumAxisValue, setMinimumAxisValue, setRange, setRangeAboutValue, setRangeAttribute, setStandardTickUnits, setUpperMargin
 
Methods inherited from class com.jrefinery.chart.Axis
addChangeListener, getFixedDimension, getLabel, getLabelFont, getLabelInsets, getLabelPaint, getMaxTickLabelWidth, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkPaint, getTickMarkStroke, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, removeChangeListener, setFixedDimension, setLabel, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, 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.
Constructor Detail

VerticalLogarithmicAxis

public VerticalLogarithmicAxis()
Constructs a vertical logarithmic axis, using default values where necessary.

VerticalLogarithmicAxis

public VerticalLogarithmicAxis(java.lang.String label)
Constructs a vertical logarithmic axis, using default values where necessary.
Parameters:
label - the axis label (null permitted).

VerticalLogarithmicAxis

public VerticalLogarithmicAxis(java.lang.String label,
                               java.awt.Font labelFont,
                               double lowerBound,
                               double upperBound)
Constructs a vertical logarithmic axis.
Parameters:
label - the axis label (null permitted).
labelFont - the font for displaying the axis label.
lowerBound - the lowest value shown on the axis.
upperBound - the highest value shown on the axis.

VerticalLogarithmicAxis

public VerticalLogarithmicAxis(java.lang.String label,
                               java.awt.Font labelFont,
                               java.awt.Paint labelPaint,
                               java.awt.Insets labelInsets,
                               boolean labelDrawnVertical,
                               boolean tickLabelsVisible,
                               java.awt.Font tickLabelFont,
                               java.awt.Paint tickLabelPaint,
                               java.awt.Insets tickLabelInsets,
                               boolean tickMarksVisible,
                               java.awt.Stroke tickMarkStroke,
                               java.awt.Paint tickMarkPaint,
                               boolean autoRange,
                               java.lang.Number autoRangeMinimumSize,
                               boolean autoRangeIncludesZero,
                               double lowerBound,
                               double upperBound,
                               boolean inverted,
                               boolean autoTickUnitSelection,
                               NumberTickUnit tickUnit,
                               boolean gridLinesVisible,
                               java.awt.Stroke gridStroke,
                               java.awt.Paint gridPaint,
                               double anchorValue,
                               boolean crosshairVisible,
                               double crosshairValue,
                               java.awt.Stroke crosshairStroke,
                               java.awt.Paint crosshairPaint,
                               boolean log10TickLabelsFlag,
                               boolean allowNegativesFlag)
Constructs a vertical number axis.
Parameters:
label - the axis label (null permitted).
labelFont - the font for displaying the axis label.
labelPaint - the paint used to draw the axis label.
labelInsets - determines the amount of blank space around the label.
labelDrawnVertical - flag indicating whether or not the label is drawn vertically.
tickLabelsVisible - flag indicating whether or not the tick labels are visible.
tickLabelFont - the font used to display tick labels.
tickLabelPaint - the paint used to draw tick labels.
tickLabelInsets - determines the amount of blank space around tick labels.
tickMarksVisible - flag indicating whether or not tick marks are visible.
tickMarkStroke - the paint used to draw tick marks (if visible).
tickMarkPaint - the stroke used to draw tick marks (if visible).
autoRange - flag indicating whether the axis is automatically scaled to fit the data.
autoRangeMinimumSize - the smallest range allowed when the axis range is calculated to fit the data.
autoRangeIncludesZero - a flag indicating whether zero *must* be displayed on the axis.
lowerBound - the lowest value shown on the axis.
upperBound - the highest value shown on the axis.
inverted - a flag indicating whether the axis is normal or inverted (inverted means running from positive to negative).
autoTickUnitSelection - a flag indicating whether or not the tick units are selected automatically.
tickUnit - the tick unit.
gridLinesVisible - flag indicating whether grid lines are visible for this axis.
gridStroke - the pen/brush used to display grid lines (if visible).
gridPaint - the color used to display grid lines (if visible).
anchorValue - the anchor value.
crosshairVisible - whether to show a crosshair.
crosshairValue - the value at which to draw an optional crosshair (null permitted).
crosshairStroke - the pen/brush used to draw the crosshair.
crosshairPaint - the color used to draw the crosshair.
log10TickLabelsFlag - true for "10^n"-style tick labels, false for normal numeric tick labels.
allowNegativesFlag - negatives allowed?
Method Detail

setLog10TickLabelsFlag

public void setLog10TickLabelsFlag(boolean flag)
Sets the 'log10TickLabelsFlag' flag; true for "10^n"-style tick labels, false for regular numeric labels.
Parameters:
flag - the flag.

getLog10TickLabelsFlag

public boolean getLog10TickLabelsFlag()
Returns the 'log10TickLabelsFlag' flag; true for "10^n"-style tick labels, false for regular numeric labels.
Returns:
the flag.

setAllowNegativesFlag

public void setAllowNegativesFlag(boolean flag)
Sets the 'allowNegativesFlag' flag; true to allow negative values in data, false to be able to plot positive values arbitrarily close to zero.
Parameters:
flag - 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 range.

setupSmallLogFlag

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

translateValueToJava2D

public double translateValueToJava2D(double value,
                                     java.awt.geom.Rectangle2D dataArea)
Converts a data value to a coordinate in Java2D space, assuming that the axis runs along one edge of the specified plot area.

Note that it is possible for the coordinate to fall outside the dataArea.

Overrides:
translateValueToJava2D in class VerticalNumberAxis
Parameters:
value - The data value.
dataArea - The area for plotting the data.
Returns:
The Java2D coordinate.

translateJava2DtoValue

public double translateJava2DtoValue(float java2DValue,
                                     java.awt.geom.Rectangle2D dataArea)
Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified dataArea.
Overrides:
translateJava2DtoValue in class VerticalNumberAxis
Parameters:
java2DValue - The coordinate in Java2D space.
dataArea - 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 VerticalNumberAxis

refreshTicks

public void refreshTicks(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D plotArea,
                         java.awt.geom.Rectangle2D dataArea)
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 VerticalNumberAxis
Parameters:
g2 - The graphics device.
plotArea - The area in which the plot and the axes should be drawn.
dataArea - The area in which the plot should be drawn.

switchedLog10

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

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 - the value.
Returns:
the adjusted value.