edu.rit.numeric.plot.impl
Class LinearAxis
- java.lang.Object
-
- edu.rit.numeric.plot.impl.Axis
-
- edu.rit.numeric.plot.impl.NumericalAxis
-
- edu.rit.numeric.plot.impl.LinearAxis
-
public class LinearAxis extends NumericalAxis
Class LinearAxis provides a linear axis on a plot. The axis goes from a starting value to an ending value in a linear fashion.
-
-
Field Summary
-
Fields inherited from class edu.rit.numeric.plot.impl.Axis
DEFAULT_PAINT, DEFAULT_STROKE
-
-
Constructor Summary
Constructors Constructor and Description LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength)Construct a new linear axis.LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint)Construct a new linear axis.LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new linear axis.LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new linear axis.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static doubleautoscale(double max)Determine a pleasing scale for a linear 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
-
LinearAxis
public LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength)Construct a new linear axis. The axis is drawn with the default stroke (solid, width=1) and paint (black). There are no tick marks.- Parameters:
theStart- Starting value for this axis.theEnd- Ending value for this axis. It can be greater than or less than theStart.theMajorDivisionCount- Number of major divisions for this axis.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- 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 theMajorDivisionCount is less than 1. 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.
-
LinearAxis
public LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint)Construct a new linear axis. The axis is drawn with the given stroke and paint. There are no tick marks.- Parameters:
theStart- Starting value for this axis.theEnd- Ending value for this axis. It can be greater than or less than theStart.theMajorDivisionCount- Number of major divisions for this axis.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- 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 theMajorDivisionCount is less than 1. 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.
-
LinearAxis
public LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new linear 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- Starting value for this axis.theEnd- Ending value for this axis. It can be greater than or less than theStart.theMajorDivisionCount- Number of major divisions for this axis.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- 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 theMajorDivisionCount is less than 1. 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.
-
LinearAxis
public LinearAxis(double theStart, double theEnd, int theMajorDivisionCount, int theMinorDivisionCount, double theCrossing, double theLength, java.awt.Stroke theStroke, java.awt.Paint thePaint, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)Construct a new linear 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- Starting value for this axis.theEnd- Ending value for this axis. It can be greater than or less than theStart.theMajorDivisionCount- Number of major divisions for this axis.theMinorDivisionCount- Number of minor divisions per major division for this axis.theCrossing- 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 theMajorDivisionCount is less than 1. 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 double autoscale(double max)
Determine a pleasing scale for a linear axis. The input, max, is the largest value to be displayed along the axis. The output is the smallest number of the form 1x10k, 2x10k, or 5x10k, k an integer, that is greater than or equal to max. This can then be used as the maximum value for the axis.Note: The autoscale() method works for negative inputs. If max < 0, then autoscale(max) = -autoscale(-max).
Note: autoscale(0) = 0.
- Parameters:
max- Maximum value to be displayed along the axis.- Returns:
- Maximum value for the axis.
-
-
DMelt 3.0 © DataMelt by jWork.ORG