Package edu.hws.jcm.draw
Class Axes
java.lang.Object
edu.hws.jcm.draw.Drawable
edu.hws.jcm.draw.Axes
- All Implemented Interfaces:
Serializable
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axs.static final int
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes.static final int
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis.static final int
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis.static final int
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes.static final int
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axis. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draw the axes.Get the color that is used for drawing the axes, when they are drawn in their true position.Get the color that is used for drawing the labels on the x- and y-axes.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
Get the positioning constant that tells where the x-axis is drawn.Get the label that appears on the x-axis.int
Get the positioning constant that tells where the y-axis is drawn.Get the label that appears on the y-axis.void
Set the color that is used for drawing the axes, when they are drawn in their true position.void
Set the color that is used for drawing the labels (usually the names of the variables) on the x- and y-axes.void
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
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
Set the label that appears on the y-axis.Methods inherited from class edu.hws.jcm.draw.Drawable
getVisible, needsRedraw, setOwnerData, setVisible
-
Field Details
-
TOP
public static final int TOPA 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:
-
BOTTOM
public static final int BOTTOMA 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:
-
LEFT
public static final int LEFTA 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:
-
RIGHT
public static final int RIGHTA 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:
-
CENTER
public static final int CENTERA 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:
-
SMART
public static final int SMARTA 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:
-
-
Constructor Details
-
Axes
public Axes()Creates axes with no names on the axes. -
Axes
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
Get the color that is used for drawing the axes, when they are drawn in their true position. -
setAxesColor
Set the color that is used for drawing the axes, when they are drawn in their true position. The default is blue. -
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
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
Get the color that is used for drawing the labels on the x- and y-axes. -
setLabelColor
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
Get the label that appears on the x-axis. If the value is null, no label appears. -
setXLabel
Set the label that appears on the x-axis. If the value is null, no label appears. This is the default. -
getYLabel
Get the label that appears on the y-axis. If the value is null, no label appears. -
setYLabel
Set the label that appears on the y-axis. If the value is null, no label appears. This is the default. -
draw
Draw the axes. This is not meant to be called directly.- Specified by:
draw
in classDrawable
- 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.
-