| java.lang.Object edu.hws.jcm.draw.Drawable edu.hws.jcm.draw.Axes
Axes | public class Axes extends Drawable (Code) | | 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.)
|
Field Summary | |
final public static int | BOTTOM A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axs. | final public static int | CENTER A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes. | final public static int | LEFT A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis. | final public static int | RIGHT A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis. | final public static 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. | final public static int | TOP A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axis. |
Constructor Summary | |
public | Axes() Creates axes with no names on the axes. | public | Axes(String xLabel, String yLabel) Creates axes with given names on the axes.
Parameters: xlabel - Label for x axis. |
Method Summary | |
public void | draw(Graphics g, boolean coordsChanged) Draw the axes. | double | fudge(double x) Translated directly from the Pascal version of xFunctions. | public Color | getAxesColor() Get the color that is used for drawing the axes, when they are drawn in their true position. | public Color | getLabelColor() Get the color that is used for drawing the labels on the x- and y-axes. | 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. | public int | getXAxisPosition() Get the positioning constant that tells where the x-axis is drawn. | public String | getXLabel() Get the label that appears on the x-axis. | public int | getYAxisPosition() Get the positioning constant that tells where the y-axis is drawn. | public String | getYLabel() Get the label that appears on the y-axis. | public void | setAxesColor(Color c) Set the color that is used for drawing the axes, when they are drawn in their true position. | 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. | 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. | public void | setXAxisPosition(int pos) Set the positioning constant that tells where the x-axis is drawn. | public void | setXLabel(String s) Set the label that appears on the x-axis. | public void | setYAxisPosition(int pos) Set the positioning constant that tells where the y-axis is drawn. | public void | setYLabel(String s) Set the label that appears on the y-axis. | void | setup(FontMetrics fm, double xmin, double xmax, double ymin, double ymax, int left, int top, int width, int height, int gap) |
BOTTOM | final public static int BOTTOM(Code) | | 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.
|
CENTER | final public static int CENTER(Code) | | 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.
|
LEFT | final public static int LEFT(Code) | | 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.
|
RIGHT | final public static int RIGHT(Code) | | 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.
|
SMART | final public static int SMART(Code) | | 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.
|
TOP | final public static int TOP(Code) | | 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.
|
Axes | public Axes()(Code) | | Creates axes with no names on the axes.
|
Axes | public Axes(String xLabel, String yLabel)(Code) | | Creates axes with given names on the axes.
Parameters: xlabel - Label for x axis. If the value is null, no label is drawn. Parameters: ylabel - Label for y axis. If the value is null, no label is drawn. |
draw | public void draw(Graphics g, boolean coordsChanged)(Code) | | Draw the axes. This is not meant to be called directly.
|
fudge | double fudge(double x)(Code) | | Translated directly from the Pascal version of xFunctions.
Move x to a more "rounded" value; used for labeling axes.
Parameters: x - the x coordinate used for labeling axes the rounded value of x |
getAxesColor | public Color getAxesColor()(Code) | | Get the color that is used for drawing the axes, when they are drawn in their true position.
|
getLabelColor | public Color getLabelColor()(Code) | | Get the color that is used for drawing the labels on the x- and y-axes.
|
getLightAxesColor | public Color getLightAxesColor()(Code) | | 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.
|
getXAxisPosition | public int getXAxisPosition()(Code) | | Get the positioning constant that tells where the x-axis is drawn. This can be LEFT, RIGHT, CENTER, or SMART.
|
getXLabel | public String getXLabel()(Code) | | Get the label that appears on the x-axis. If the value is null, no label appears.
|
getYAxisPosition | public int getYAxisPosition()(Code) | | Get the positioning constant that tells where the y-axis is drawn. This can be TOP, BOTTOM, CENTER, or SMART.
|
getYLabel | public String getYLabel()(Code) | | Get the label that appears on the y-axis. If the value is null, no label appears.
|
setAxesColor | public void setAxesColor(Color c)(Code) | | Set the color that is used for drawing the axes, when they are drawn in their true position.
The default is blue.
|
setLabelColor | public void setLabelColor(Color c)(Code) | | 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.
|
setLightAxesColor | public void setLightAxesColor(Color c)(Code) | | 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.
|
setXAxisPosition | public void setXAxisPosition(int pos)(Code) | | Set the positioning constant that tells where the x-axis is drawn. This can be LEFT, RIGHT, CENTER, or SMART.
The default is SMART.
|
setXLabel | public void setXLabel(String s)(Code) | | Set the label that appears on the x-axis. If the value is null, no label appears. This is the default.
|
setYAxisPosition | public void setYAxisPosition(int pos)(Code) | | Set the positioning constant that tells where the y-axis is drawn. This can be TOP, BOTTOM, CENTER, or SMART.
The default is SMART.
|
setYLabel | public void setYLabel(String s)(Code) | | Set the label that appears on the y-axis. If the value is null, no label appears. This is the default.
|
setup | void setup(FontMetrics fm, double xmin, double xmax, double ymin, double ymax, int left, int top, int width, int height, int gap)(Code) | | |
|
|