edu.rit.numeric.plot
Class NumericalAxis

java.lang.Object
  extended by edu.rit.numeric.plot.Axis
      extended by edu.rit.numeric.plot.NumericalAxis
Direct Known Subclasses:
LinearAxis, LogarithmicAxis

public abstract class NumericalAxis
extends Axis

Class NumericalAxis is the abstract base class for a numerical axis on a plot. A numerical axis represents a numerical quantity; it is divided into major divisions; each major division is divided into minor divisions. A numerical axis may have tick marks at the major and minor divisions. A numerical axis may have tick labels at the major divisions.


Field Summary
protected  Ticks myTicksAboveOrRight
          Ticks above or to the right of the axis.
protected  Ticks myTicksBelowOrLeft
          Ticks below or to the left of the axis.
 
Fields inherited from class edu.rit.numeric.plot.Axis
DEFAULT_PAINT, DEFAULT_STROKE, myLength, myPaint, myStroke
 
Constructor Summary
protected NumericalAxis(double theLength, Stroke theStroke, Paint thePaint, Ticks theTicksBelowOrLeft, Ticks theTicksAboveOrRight)
          Construct a new numerical axis.
 
Method Summary
 void drawHorizontal(Graphics2D g2d)
          Draw this axis in the given graphics context starting at coordinates (0, 0) and moving horizontally to the right.
 void drawVertical(Graphics2D g2d)
          Draw this axis in the given graphics context starting at coordinates (0, 0) and moving vertically up.
abstract  double getCrossing()
          Returns the value of the point where the perpendicular axis crosses this axis.
abstract  double getDisplayDistance(double value)
          Returns the distance on the display from the start of this axis to the given value.
abstract  double getEnd()
          Returns the ending value of this axis.
abstract  double getMajorDivision(int i)
          Returns the value of the given major division.
abstract  int getMajorDivisionCount()
          Returns the number of major divisions on this axis.
abstract  double getMinorDivision(int i)
          Returns the value of the given minor division.
abstract  int getMinorDivisionCount()
          Returns the number of minor divisions on this axis.
abstract  double getStart()
          Returns the starting value of this axis.
 Ticks getTicksAboveOrRight()
          Returns the ticks above or to the right of this axis.
 Ticks getTicksBelowOrLeft()
          Returns the ticks below or to the left of this axis.
abstract  boolean includesValue(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.Axis
autoscale, getLength, getPaint, getStroke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myTicksBelowOrLeft

protected Ticks myTicksBelowOrLeft
Ticks below or to the left of the axis.


myTicksAboveOrRight

protected Ticks myTicksAboveOrRight
Ticks above or to the right of the axis.

Constructor Detail

NumericalAxis

protected NumericalAxis(double theLength,
                        Stroke theStroke,
                        Paint thePaint,
                        Ticks theTicksBelowOrLeft,
                        Ticks theTicksAboveOrRight)
Construct a new numerical axis. The axis is drawn with the given length, stroke, paint, and ticks.

Parameters:
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:
NullPointerException - (unchecked exception) Thrown if theStroke is null or thePaint is null.
IllegalArgumentException - (unchecked exception) Thrown if theLength is less than or equal to 0.
Method Detail

getTicksBelowOrLeft

public Ticks getTicksBelowOrLeft()
Returns the ticks below or to the left of this axis.


getTicksAboveOrRight

public Ticks getTicksAboveOrRight()
Returns the ticks above or to the right of this axis.


drawHorizontal

public void drawHorizontal(Graphics2D g2d)
Draw this axis in the given graphics context starting at coordinates (0, 0) and moving horizontally to the right.

Specified by:
drawHorizontal in class Axis
Parameters:
g2d - 2-D graphics context.

drawVertical

public void drawVertical(Graphics2D g2d)
Draw this axis in the given graphics context starting at coordinates (0, 0) and moving vertically up.

Specified by:
drawVertical in class Axis
Parameters:
g2d - 2-D graphics context.

includesValue

public abstract boolean includesValue(double value)
Returns true if the given value falls within the bounds of this axis, false otherwise.


getDisplayDistance

public abstract double getDisplayDistance(double value)
Returns the distance on the display from the start of this axis to the given value.


getStart

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


getEnd

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


getMajorDivisionCount

public abstract int getMajorDivisionCount()
Returns the number of major divisions on this axis.


getMajorDivision

public abstract double getMajorDivision(int i)
Returns the value of the given major division.

Parameters:
i - Major division index in the range 0 .. getMajorDivisionCount().

getMinorDivisionCount

public abstract int getMinorDivisionCount()
Returns the number of minor divisions on this axis.


getMinorDivision

public abstract double getMinorDivision(int i)
Returns the value of the given minor division.

Parameters:
i - Minor division index in the range 0 .. getMinorDivisionCount().

getCrossing

public abstract double getCrossing()
Returns the value of the point where the perpendicular axis crosses this axis.



Copyright © 2005 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.