Class LogAxis3D

All Implemented Interfaces:
Serializable, EventListener, Axis3D, ValueAxis3D, ChartElement, MarkerChangeListener

public class LogAxis3D extends AbstractValueAxis3D implements ValueAxis3D
A numerical axis with a logarithmic scale.

NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
Since:
1.2
See Also:
  • Field Details

  • Constructor Details

    • LogAxis3D

      public LogAxis3D(String label)
      Creates a new log axis with a default base of 10.
      Parameters:
      label - the axis label (null permitted).
  • Method Details

    • getBase

      public double getBase()
      Returns the logarithmic base value. The default value is 10.
      Returns:
      The logarithmic base value.
    • setBase

      public void setBase(double base)
      Sets the logarithmic base value and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      base - the base value.
    • getBaseSymbol

      Returns the base symbol, used in tick labels for the axis. A typical value would be "e" when using a natural logarithm scale. If this is null, the tick labels will display the numerical base value. The default value is null.
      Returns:
      The base symbol (possibly null).
    • setBaseSymbol

      public void setBaseSymbol(String symbol)
      Sets the base symbol and sends an Axis3DChangeEvent to all registered listeners. If you set this to null, the tick labels will display a numerical representation of the base value.
      Parameters:
      symbol - the base symbol (null permitted).
    • getBaseFormatter

      Returns the formatter used for the log base value when it is displayed in tick labels. The default value is NumberFormat("0").
      Returns:
      The base formatter (never null).
    • setBaseFormatter

      public void setBaseFormatter(NumberFormat formatter)
      Sets the formatter for the log base value and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      formatter - the formatter (null not permitted).
    • getSmallestValue

      public double getSmallestValue()
      Returns the smallest positive data value that will be represented on the axis. This will be used as the lower bound for the axis if the data range contains any value from 0.0 up to this value.
      Returns:
      The smallest value.
    • setSmallestValue

      public void setSmallestValue(double smallestValue)
      Sets the smallest positive data value that will be represented on the axis and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      smallestValue - the value (must be positive).
    • getTickSelector

      Returns the tick selector for the axis.
      Returns:
      The tick selector (possibly null).
    • setTickSelector

      public void setTickSelector(TickSelector selector)
      Sets the tick selector and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      selector - the selector (null permitted).
    • getTickSize

      public double getTickSize()
      Returns the tick size to be used when the tick selector is null.
      Returns:
      The tick size.
    • setTickSize

      public void setTickSize(double tickSize)
      Sets the tick size and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      tickSize - the new tick size.
    • getTickLabelFormatter

      Returns the tick label formatter. The default value is DecimalFormat("0.0").
      Returns:
      The tick label formatter (never null).
    • setTickLabelFormatter

      public void setTickLabelFormatter(Format formatter)
      Sets the formatter for the tick labels and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      formatter - the formatter (null not permitted).
    • setRange

      public void setRange(Range range)
      Sets the range for the axis. This method is overridden to check that the range does not contain negative values, and to update the log values for the range.
      Specified by:
      setRange in interface Axis3D
      Overrides:
      setRange in class AbstractValueAxis3D
      Parameters:
      range - the range (nul not permitted).
    • setRange

      public void setRange(double min, double max)
      Sets the range for the axis. This method is overridden to check that the range does not contain negative values, and to update the log values for the range.
      Specified by:
      setRange in interface Axis3D
      Overrides:
      setRange in class AbstractValueAxis3D
      Parameters:
      min - the lower bound for the range.
      max - the upper bound for the range.
    • updateRange

      protected void updateRange(Range range)
      Description copied from class: AbstractValueAxis3D
      Updates the axis range (used by the auto-range calculation) without notifying listeners.
      Overrides:
      updateRange in class AbstractValueAxis3D
      Parameters:
      range - the new range.
    • calculateLog

      public final double calculateLog(double value)
      Calculates the log of the given value, using the current base.
      Parameters:
      value - the value (negatives not permitted).
      Returns:
      The log of the given value.
      See Also:
    • calculateValue

      public final double calculateValue(double log)
      Calculates the value from a given log value.
      Parameters:
      log - the log value.
      Returns:
      The value with the given log.
      See Also:
    • translateToWorld

      public double translateToWorld(double value, double length)
      Translates a data value to a world coordinate, assuming that the axis begins at the origin and has the specified length.
      Specified by:
      translateToWorld in interface Axis3D
      Parameters:
      value - the data value.
      length - the axis length in world coordinates.
      Returns:
      The world coordinate of this data value on the axis.
    • draw

      public void draw(Graphics2D g2, Point2D startPt, Point2D endPt, Point2D opposingPt, List<TickData> tickData, RenderingInfo info, boolean hinting)
      Draws the axis.
      Specified by:
      draw in interface Axis3D
      Specified by:
      draw in class AbstractAxis3D
      Parameters:
      g2 - the graphics target (null not permitted).
      startPt - the starting point.
      endPt - the ending point.
      opposingPt - an opposing point (labels will be on the other side of the line).
      tickData - the tick data (including anchor points calculated by the 3D engine).
      info - an object to be populated with rendering info (null permitted).
      hinting - perform element hinting?
    • adjustedDataRange

      protected Range adjustedDataRange(Range range)
      Adjusts the range by adding the lower and upper margins on the logarithmic range.
      Specified by:
      adjustedDataRange in class AbstractValueAxis3D
      Parameters:
      range - the range (nul not permitted).
      Returns:
      The adjusted range.
    • selectTick

      public double selectTick(Graphics2D g2, Point2D pt0, Point2D pt1, Point2D opposingPt)
      Selects a standard tick unit on the logarithmic range.
      Specified by:
      selectTick in interface ValueAxis3D
      Parameters:
      g2 - the graphics target (null not permitted).
      pt0 - the starting point.
      pt1 - the ending point.
      opposingPt - an opposing point.
      Returns:
      The tick unit (log increment).
    • generateTickData

      public List<TickData> generateTickData(double tickUnit)
      Generates tick data for the axis, assuming the specified tick unit (a log increment in this case). If the tick unit is Double.NaN then ticks will be added for the bounds of the axis only.
      Specified by:
      generateTickData in interface ValueAxis3D
      Parameters:
      tickUnit - the tick unit.
      Returns:
      A list of tick data items.
    • hashCode

      public int hashCode()
      Description copied from class: AbstractAxis3D
      Returns a hash code for this instance.
      Overrides:
      hashCode in class AbstractAxis3D
      Returns:
      A hash code.
    • equals

      public boolean equals(Object obj)
      Description copied from class: AbstractAxis3D
      Tests this instance for equality with an arbitrary object.
      Overrides:
      equals in class AbstractValueAxis3D
      Parameters:
      obj - the object to test against (null permitted).
      Returns:
      A boolean.