Package edu.hws.jcm.draw

# Class Axes

java.lang.Object
edu.hws.jcm.draw.Drawable
edu.hws.jcm.draw.Axes

All Implemented Interfaces:
  `Serializable`

public class Axes extends Drawable
A set of horizontal and vertical axes that look OK and have reasonable, labeled tick marks. The number and spacing of tick marks changes depending on the scale on the axes. (The heuristics for computing this could use some improvement.)

See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`BOTTOM`
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axs.
`static final int`
`CENTER`
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes.
`static final int`
`LEFT`
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis.
`static final int`
`RIGHT`
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis.
`static final int`
`SMART`
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes.
`static final int`
`TOP`
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axis.

### Fields inherited from class edu.hws.jcm.draw.Drawable

`canvas, coords`

## Constructor Summary

Constructors
Constructor
Description
`Axes()`
Creates axes with no names on the axes.
`Axes(String xLabel, String yLabel)`
Creates axes with given names on the axes.

## Method Summary

Modifier and Type
Method
Description
`void`
`draw(Graphics g, boolean coordsChanged)`
Draw the axes.
`Color`
`getAxesColor()`
Get the color that is used for drawing the axes, when they are drawn in their true position.
`Color`
`getLabelColor()`
Get the color that is used for drawing the labels on the x- and y-axes.
`Color`
`getLightAxesColor()`
Get the color that is used for drawing an axis, when it is drawn along an edge of the CoordinateRect instead of in its proper x- or y-position.
`int`
`getXAxisPosition()`
Get the positioning constant that tells where the x-axis is drawn.
`String`
`getXLabel()`
Get the label that appears on the x-axis.
`int`
`getYAxisPosition()`
Get the positioning constant that tells where the y-axis is drawn.
`String`
`getYLabel()`
Get the label that appears on the y-axis.
`void`
`setAxesColor(Color c)`
Set the color that is used for drawing the axes, when they are drawn in their true position.
`void`
`setLabelColor(Color c)`
Set the color that is used for drawing the labels (usually the names of the variables) on the x- and y-axes.
`void`
`setLightAxesColor(Color c)`
Get the color that is used for drawing an axis, when it is drawn along an edge of the CoordinateRect instead of in its proper x- or y-position.
`void`
`setXAxisPosition(int pos)`
Set the positioning constant that tells where the x-axis is drawn.
`void`
`setXLabel(String s)`
Set the label that appears on the x-axis.
`void`
`setYAxisPosition(int pos)`
Set the positioning constant that tells where the y-axis is drawn.
`void`
`setYLabel(String s)`
Set the label that appears on the y-axis.

### Methods inherited from class edu.hws.jcm.draw.Drawable

`getVisible, needsRedraw, setOwnerData, setVisible`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### TOP

public static final int TOP
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axis. The axis is placed at the top of the CoordinateRect.

See Also:
  - Constant Field Values

### BOTTOM

public static final int BOTTOM
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axs. The axis is placed at the bottom of the CoordinateRect.

See Also:
  - Constant Field Values

### LEFT

public static final int LEFT
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis. The axis is placed at the left edge of the CoordinateRect.

See Also:
  - Constant Field Values

### RIGHT

public static final int RIGHT
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis. The axis is placed at the right edge of the CoordinateRect.

See Also:
  - Constant Field Values

### CENTER

public static final int CENTER
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes. The axis is placed in the center of the CoordinateRect.

See Also:
  - Constant Field Values

### SMART

public static final int SMART
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes. The axis is placed at its true x- or y-position, if that lies within the range of values shown on the CoordinateRect. Otherwise, it is placed along an edge of the CoordinateRect. This is the default value for axis placement.

See Also:
  - Constant Field Values

## Constructor Details

### Axes

public Axes()
Creates axes with no names on the axes.

### Axes

public Axes(String xLabel, String yLabel)
Creates axes with given names on the axes.

Parameters:
  `xlabel` - Label for x axis. If the value is null, no label is drawn.
  `ylabel` - Label for y axis. If the value is null, no label is drawn.

## Method Details

### getAxesColor

public Color getAxesColor()
Get the color that is used for drawing the axes, when they are drawn in their true position.

### setAxesColor

public void setAxesColor(Color c)
Set the color that is used for drawing the axes, when they are drawn in their true position. The default is blue.

### getLightAxesColor

public Color getLightAxesColor()
Get the color that is used for drawing an axis, when it is drawn along an edge of the CoordinateRect instead of in its proper x- or y-position.

### setLightAxesColor

public void setLightAxesColor(Color c)
Get the color that is used for drawing an axis, when it is drawn along an edge of the CoordinateRect instead of in its proper x- or y-position. The default is a light blue.

### getLabelColor

public Color getLabelColor()
Get the color that is used for drawing the labels on the x- and y-axes.

### setLabelColor

public void setLabelColor(Color c)
Set the color that is used for drawing the labels (usually the names of the variables) on the x- and y-axes. The default is black.

### getXAxisPosition

public int getXAxisPosition()
Get the positioning constant that tells where the x-axis is drawn. This can be LEFT, RIGHT, CENTER, or SMART.

### setXAxisPosition

public void setXAxisPosition(int pos)
Set the positioning constant that tells where the x-axis is drawn. This can be LEFT, RIGHT, CENTER, or SMART. The default is SMART.

### getYAxisPosition

public int getYAxisPosition()
Get the positioning constant that tells where the y-axis is drawn. This can be TOP, BOTTOM, CENTER, or SMART.

### setYAxisPosition

public void setYAxisPosition(int pos)
Set the positioning constant that tells where the y-axis is drawn. This can be TOP, BOTTOM, CENTER, or SMART. The default is SMART.

### getXLabel

public String getXLabel()
Get the label that appears on the x-axis. If the value is null, no label appears.

### setXLabel

public void setXLabel(String s)
Set the label that appears on the x-axis. If the value is null, no label appears. This is the default.

### getYLabel

public String getYLabel()
Get the label that appears on the y-axis. If the value is null, no label appears.

### setYLabel

public void setYLabel(String s)
Set the label that appears on the y-axis. If the value is null, no label appears. This is the default.

### draw

public void draw(Graphics g, boolean coordsChanged)
Draw the axes. This is not meant to be called directly.

Specified by:
  `draw` in class `Drawable`
Parameters:
  `g` - The graphics context in which the Drawble is to be drawn. (The drawing can change the color in g, but should not permanently change font, painting mode, etc. Thus, every drawable is responsible for setting the color it wants to use.)
  `coordsChanged` - Indicates whether the CoordinateRect has changed.