edu.rit.numeric.plot
Class Ticks

java.lang.Object
  extended by edu.rit.numeric.plot.Ticks

public class Ticks
extends Object

Class Ticks provides information about tick marks to be drawn on a NumericalAxis.


Field Summary
static Font DEFAULT_LABEL_FONT
          The default tick label font (sanserif, plain, 12).
static double DEFAULT_LABEL_OFFSET
          The default offset from the tick mark to the tick label (5).
static Paint DEFAULT_LABEL_PAINT
          The default tick label paint (black).
static double DEFAULT_LENGTH
          The default tick mark length (5).
static Paint DEFAULT_PAINT
          The default tick mark paint (black).
static Stroke DEFAULT_STROKE
          The default tick mark stroke (solid, width=1).
protected  Font myLabelFont
          Font for drawing tick labels on the display, if any.
protected  DecimalFormat myLabelFormat
          Format for the tick labels, or null for no tick labels.
protected  double myLabelOffset
          Offset from the tick marks to the tick labels, if any.
protected  Paint myLabelPaint
          Paint for drawing tick labels on the display, if any.
protected  double myLabelScale
          Scale factor for the tick labels.
protected  double myLength
          Length of the tick marks on the display.
protected  Paint myPaint
          Paint for drawing tick marks on the display.
protected  Stroke myStroke
          Stroke for drawing tick marks on the display.
 
Constructor Summary
Ticks()
          Construct a new ticks information object.
Ticks(DecimalFormat theLabelFormat)
          Construct a new ticks information object.
Ticks(DecimalFormat theLabelFormat, double theLabelScale)
          Construct a new ticks information object.
Ticks(Stroke theStroke, Paint thePaint, double theLength, DecimalFormat theLabelFormat, double theLabelScale, Font theLabelFont, Paint theLabelPaint, double theLabelOffset)
          Construct a new ticks information object.
 
Method Summary
 void drawAbove(Graphics2D g2d)
          Draw a tick above.
 void drawAbove(Graphics2D g2d, double theLabelValue)
          Draw a tick above.
 void drawBelow(Graphics2D g2d)
          Draw a tick below.
 void drawBelow(Graphics2D g2d, double theLabelValue)
          Draw a tick below.
 void drawLeft(Graphics2D g2d)
          Draw a tick to the left.
 void drawLeft(Graphics2D g2d, double theLabelValue)
          Draw a tick to the left.
 void drawRight(Graphics2D g2d)
          Draw a tick to the right.
 void drawRight(Graphics2D g2d, double theLabelValue)
          Draw a tick to the right.
 Font getLabelFont()
          Returns the font for drawing tick labels on the display.
 DecimalFormat getLabelFormat()
          Returns the format for the tick labels.
 double getLabelOffset()
          Returns the offset from the tick marks to the tick labels.
 Paint getLabelPaint()
          Returns the paint for drawing tick labels on the display.
 double getLabelScale()
          Returns the scale factor for the tick labels.
 double getLength()
          Returns the length of the tick marks on the display.
 Paint getPaint()
          Returns the paint for drawing tick marks on the display.
 Stroke getStroke()
          Returns the stroke for drawing tick marks on the display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STROKE

public static final Stroke DEFAULT_STROKE
The default tick mark stroke (solid, width=1).


DEFAULT_PAINT

public static final Paint DEFAULT_PAINT
The default tick mark paint (black).


DEFAULT_LENGTH

public static final double DEFAULT_LENGTH
The default tick mark length (5).

See Also:
Constant Field Values

DEFAULT_LABEL_FONT

public static final Font DEFAULT_LABEL_FONT
The default tick label font (sanserif, plain, 12).


DEFAULT_LABEL_PAINT

public static final Paint DEFAULT_LABEL_PAINT
The default tick label paint (black).


DEFAULT_LABEL_OFFSET

public static final double DEFAULT_LABEL_OFFSET
The default offset from the tick mark to the tick label (5).

See Also:
Constant Field Values

myStroke

protected Stroke myStroke
Stroke for drawing tick marks on the display.


myPaint

protected Paint myPaint
Paint for drawing tick marks on the display.


myLength

protected double myLength
Length of the tick marks on the display.


myLabelFormat

protected DecimalFormat myLabelFormat
Format for the tick labels, or null for no tick labels.


myLabelScale

protected double myLabelScale
Scale factor for the tick labels.


myLabelFont

protected Font myLabelFont
Font for drawing tick labels on the display, if any.


myLabelPaint

protected Paint myLabelPaint
Paint for drawing tick labels on the display, if any.


myLabelOffset

protected double myLabelOffset
Offset from the tick marks to the tick labels, if any.

Constructor Detail

Ticks

public Ticks()
Construct a new ticks information object. The tick marks have the default stroke, the default paint, and the default length. There are no tick labels.


Ticks

public Ticks(DecimalFormat theLabelFormat)
Construct a new ticks information object. The tick marks have the default stroke, the default paint, and the default length. The tick labels have the given decimal format, no scaling, the default font, the default paint, and the default offset from the tick marks.

Parameters:
theLabelFormat - Format for the tick labels. If null, no tick labels are drawn.

Ticks

public Ticks(DecimalFormat theLabelFormat,
             double theLabelScale)
Construct a new ticks information object. The tick marks have the default stroke, the default paint, and the default length. The tick labels have the given decimal format, the given scaling, the default font, the default paint, and the default offset from the tick marks.

Parameters:
theLabelFormat - Format for the tick labels. If null, no tick labels are drawn.
theLabelScale - Scale factor for the tick labels. Each tick label's numerical value is divided by theLabelScale before being displayed. Use a value of 1.0 for no scaling.
Throws:
IllegalArgumentException - (unchecked exception) Thrown if theLabelFormat is non-null and theLabelScale is equal to 0.

Ticks

public Ticks(Stroke theStroke,
             Paint thePaint,
             double theLength,
             DecimalFormat theLabelFormat,
             double theLabelScale,
             Font theLabelFont,
             Paint theLabelPaint,
             double theLabelOffset)
Construct a new ticks information object. The tick marks have the given stroke, the given paint, and the given length. The tick labels have the given decimal format, the given scaling, the given font, the given paint, and the given offset from the tick marks.

Parameters:
theStroke - Stroke for drawing tick marks on the display.
thePaint - Paint for drawing tick marks on the display.
theLength - Length of the tick marks on the display.
theLabelFormat - Format for the tick labels. If null, no tick labels are drawn.
theLabelScale - Scale factor for the tick labels. Each tick label's numerical value is divided by theLabelScale before being displayed. Use a value of 1.0 for no scaling.
theLabelFont - Font for drawing tick labels on the display, if any. Ignored if no tick labels are to be drawn.
theLabelPaint - Paint for drawing tick labels on the display, if any. Ignored if no tick labels are to be drawn.
theLabelOffset - Offset from the tick marks to the tick labels, if any. Ignored if no tick labels are to be drawn.
Throws:
NullPointerException - (unchecked exception) Thrown if theStroke is null, thePaint is null, theLabelFormat is non-null and theLabelFont is null, or theLabelFormat is non-null and theLabelPaint is null.
IllegalArgumentException - (unchecked exception) Thrown if theLength is less than or equal to 0, theLabelFormat is non-null and theLabelScale is equal to 0, or theLabelFormat is non-null and theLabelOffset is less than or equal to 0.
Method Detail

getStroke

public Stroke getStroke()
Returns the stroke for drawing tick marks on the display.


getPaint

public Paint getPaint()
Returns the paint for drawing tick marks on the display.


getLength

public double getLength()
Returns the length of the tick marks on the display.


getLabelFormat

public DecimalFormat getLabelFormat()
Returns the format for the tick labels. If no tick labels are to be drawn, null is returned.


getLabelScale

public double getLabelScale()
Returns the scale factor for the tick labels. Each tick label's numerical value is divided by the scale factor before being displayed. If no tick labels are to be drawn, 1.0 is returned.


getLabelFont

public Font getLabelFont()
Returns the font for drawing tick labels on the display. If no tick labels are to be drawn, null is returned.


getLabelPaint

public Paint getLabelPaint()
Returns the paint for drawing tick labels on the display. If no tick labels are to be drawn, null is returned.


getLabelOffset

public double getLabelOffset()
Returns the offset from the tick marks to the tick labels. If no tick labels are to be drawn, 0 is returned.


drawLeft

public void drawLeft(Graphics2D g2d)
Draw a tick to the left. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going to the left. There is no tick label.

Parameters:
g2d - 2-D graphics context.

drawLeft

public void drawLeft(Graphics2D g2d,
                     double theLabelValue)
Draw a tick to the left. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going to the left. The tick label, if any, is drawn to the left of the tick mark with the given numerical value.

Parameters:
g2d - 2-D graphics context.
theLabelValue - Numerical value for the tick label, if any.

drawRight

public void drawRight(Graphics2D g2d)
Draw a tick to the right. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going to the right. There is no tick label.

Parameters:
g2d - 2-D graphics context.

drawRight

public void drawRight(Graphics2D g2d,
                      double theLabelValue)
Draw a tick to the right. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going to the right. The tick label, if any, is drawn to the right of the tick mark with the given numerical value.

Parameters:
g2d - 2-D graphics context.
theLabelValue - Numerical value for the tick label, if any.

drawBelow

public void drawBelow(Graphics2D g2d)
Draw a tick below. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going downwards. There is no tick label.

Parameters:
g2d - 2-D graphics context.

drawBelow

public void drawBelow(Graphics2D g2d,
                      double theLabelValue)
Draw a tick below. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going downwards. The tick label, if any, is drawn below the tick mark with the given numerical value.

Parameters:
g2d - 2-D graphics context.
theLabelValue - Numerical value for the tick label, if any.

drawAbove

public void drawAbove(Graphics2D g2d)
Draw a tick above. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going upwards. There is no tick label.

Parameters:
g2d - 2-D graphics context.

drawAbove

public void drawAbove(Graphics2D g2d,
                      double theLabelValue)
Draw a tick above. The tick mark is drawn in the given graphics context starting at coordinates (0, 0) and going upwards. The tick label, if any, is drawn above the tick mark with the given numerical value.

Parameters:
g2d - 2-D graphics context.
theLabelValue - Numerical value for the tick label, if any.


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