edu.rit.numeric.plot.impl
Class LogarithmicAxis
- java.lang.Object
-
- edu.rit.numeric.plot.impl.Axis
-
- edu.rit.numeric.plot.impl.NumericalAxis
-
- edu.rit.numeric.plot.impl.LogarithmicAxis
-
public class LogarithmicAxis extends NumericalAxis
Class LogarithmicAxis provides a logarithmic axis on a plot. The axis goes from a starting value to an ending value in a logarithmic fashion. The starting and ending values must be integer powers of 10. Each major division corresponds to one decade (factor of 10). Each major division may be subdivided into any number of minor divisions; the minor divisions are distributed linearly between the upper and lower bounds of the major division.
-
-
Field Summary
-
Fields inherited from class edu.rit.numeric.plot.impl.Axis
DEFAULT_PAINT, DEFAULT_STROKE
-
-
Constructor Summary
Constructors Constructor and Description LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength)Construct a new logarithmic axis.LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint)Construct a new logarithmic axis.LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new logarithmic axis.LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new logarithmic axis.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static int[]autoscale(double min, double max)Determine a scale for a logarithmic axis.doublegetCrossing()Returns the value of the point where the perpendicular axis crosses this axis.doublegetDisplayDistance(double value)Returns the distance on the display from the start of this axis to the given value.doublegetEnd()Returns the ending value of this axis.doublegetMajorDivision(int i)Returns the value of the given major division.intgetMajorDivisionCount()Returns the number of major divisions on this axis.doublegetMinorDivision(int i)Returns the value of the given minor division.intgetMinorDivisionCount()Returns the number of minor divisions on this axis.doublegetStart()Returns the starting value of this axis.booleanincludesValue(double value)Returns true if the given value falls within the bounds of this axis, false otherwise.-
Methods inherited from class edu.rit.numeric.plot.impl.NumericalAxis
drawHorizontal, drawVertical, getTicksAboveOrRight, getTicksBelowOrLeft
-
-
-
-
Constructor Detail
-
LogarithmicAxis
public LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength)Construct a new logarithmic axis. The axis is drawn with the default stroke (solid, width=1) and paint (black). There are no tick marks.- Parameters:
theStart- Base-10 logarithm of the starting value for this axis.theEnd- Base-10 logarithm of the ending value for this axis. It can be greater than or less than theStart.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- Base-10 logarithm of the point at which the perpendicular axis crosses this axis.theLength- Length of this axis on the display.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theStart equals theEnd. Thrown if theMinorDivisionCount is less than 1. Thrown if theCrossing does not fall between theStart and theEnd inclusive. Thrown if theLength is less than or equal to 0.
-
LogarithmicAxis
public LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint)Construct a new logarithmic axis. The axis is drawn with the given stroke and paint. There are no tick marks.- Parameters:
theStart- Base-10 logarithm of the starting value for this axis.theEnd- Base-10 logarithm of the ending value for this axis. It can be greater than or less than theStart.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- Base-10 logarithm of the point at which the perpendicular axis crosses this axis.theLength- Length of this axis on the display.theStroke- Stroke for drawing this axis on the display.thePaint- Paint for drawing this axis on the display.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theStroke is null or thePaint is null.java.lang.IllegalArgumentException- (unchecked exception) Thrown if theStart equals theEnd. Thrown if theMinorDivisionCount is less than 1. Thrown if theCrossing does not fall between theStart and theEnd inclusive. Thrown if theLength is less than or equal to 0.
-
LogarithmicAxis
public LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new logarithmic axis. The axis is drawn with the default stroke (solid, width=1) and paint (black). There are tick marks on either or both sides of the axis.- Parameters:
theStart- Base-10 logarithm of the starting value for this axis.theEnd- Base-10 logarithm of the ending value for this axis. It can be greater than or less than theStart.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- Base-10 logarithm of the point at which the perpendicular axis crosses this axis.theLength- Length of this axis on the display.theTicksBelowOrLeft- Ticks to draw below or to the left of the axis (for a horizontal or vertical axis, respectively). If null, no ticks are drawn below or to the left.theTicksAboveOrRight- Ticks to draw above or to the right of the axis (for a horizontal or vertical axis, respectively). If null, no ticks are drawn above or to the right.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theStart equals theEnd. Thrown if theMinorDivisionCount is less than 1. Thrown if theCrossing does not fall between theStart and theEnd inclusive. Thrown if theLength is less than or equal to 0.
-
LogarithmicAxis
public LogarithmicAxis(int theStart, int theEnd, int theMinorDivisionCount, int theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new logarithmic axis. The axis is drawn with the given stroke and paint. There are tick marks on either or both sides of the axis.- Parameters:
theStart- Base-10 logarithm of the starting value for this axis.theEnd- Base-10 logarithm of the ending value for this axis. It can be greater than or less than theStart.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- Base-10 logarithm of the point at which the perpendicular axis crosses this axis.theLength- Length of this axis on the display.theStroke- Stroke for drawing this axis on the display.thePaint- Paint for drawing this axis on the display.theTicksBelowOrLeft- Ticks to draw below or to the left of the axis (for a horizontal or vertical axis, respectively). If null, no ticks are drawn below or to the left.theTicksAboveOrRight- Ticks to draw above or to the right of the axis (for a horizontal or vertical axis, respectively). If null, no ticks are drawn above or to the right.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theStroke is null or thePaint is null.java.lang.IllegalArgumentException- (unchecked exception) Thrown if theStart equals theEnd. Thrown if theMinorDivisionCount is less than 1. Thrown if theCrossing does not fall between theStart and theEnd inclusive. Thrown if theLength is less than or equal to 0.
-
-
Method Detail
-
getStart
public double getStart()
Returns the starting value of this axis. The starting value is the value at the left or bottom end of the axis for a horizontal or vertical orientation, respectively.- Specified by:
getStartin classNumericalAxis
-
getEnd
public double getEnd()
Returns the ending value of this axis. The ending value is the value at the right or top end of the axis for a horizontal or vertical orientation, respectively. Note that the ending value may be greater than or less than the starting value.- Specified by:
getEndin classNumericalAxis
-
includesValue
public boolean includesValue(double value)
Returns true if the given value falls within the bounds of this axis, false otherwise.- Specified by:
includesValuein classNumericalAxis
-
getDisplayDistance
public double getDisplayDistance(double value)
Returns the distance on the display from the start of this axis to the given value.- Specified by:
getDisplayDistancein classNumericalAxis
-
getMajorDivisionCount
public int getMajorDivisionCount()
Returns the number of major divisions on this axis.- Specified by:
getMajorDivisionCountin classNumericalAxis
-
getMajorDivision
public double getMajorDivision(int i)
Returns the value of the given major division.- Specified by:
getMajorDivisionin classNumericalAxis- Parameters:
i- Major division index in the range 0 .. getMajorDivisionCount().
-
getMinorDivisionCount
public int getMinorDivisionCount()
Returns the number of minor divisions on this axis.- Specified by:
getMinorDivisionCountin classNumericalAxis
-
getMinorDivision
public double getMinorDivision(int i)
Returns the value of the given minor division.- Specified by:
getMinorDivisionin classNumericalAxis- Parameters:
i- Minor division index in the range 0 .. getMinorDivisionCount().
-
getCrossing
public double getCrossing()
Returns the value of the point where the perpendicular axis crosses this axis.- Specified by:
getCrossingin classNumericalAxis
-
autoscale
public static int[] autoscale(double min, double max)Determine a scale for a logarithmic axis. The inputs, min and max, are the smallest and largest values to be displayed along the axis; both must be greater than 0. The output is an array of two integers containing the smallest and the largest exponent of 10 that encompasses the range min through max. These values can then be used to construct an instance of class LogarithmicAxis.- Parameters:
min- Minimum value to be displayed along the axis.max- Maximum value to be displayed along the axis.- Returns:
- Array of minimum and maximum exponents of 10 for the axis.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if min <= 0 or max <= 0.
-
-
DMelt 3.0 © DataMelt by jWork.ORG