All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class graph.Axis

java.lang.Object
   |
   +----graph.Axis

public class Axis
extends Object
This class controls the look and feel of axes. It is designed to be used in conjunction with the Graph2D class and DataSet class for plotting 2D graphs. To work with the other classes a system of registration is used. The axes have to be attached to the controlling Graph2D class and the DataSet's have to be attached to both the Graph2D class and the Axis class. This way the 3 main classes Graph2D, Axis and DataSet know of each others existence. This does not mean the classes cannot be used independently, they can but in this mode nothing is automated, the user must code everything manually MCC 6/9/97 Changed SpecialFunction.log10 to internal log10

Version:
LB1.12 MCC 3/19/97
Author:
Leigh Brookshaw modified by Michael Cross

Variable Index

 o amax
The position in pixels of the maximum point of the axis line
 o amin
The position in pixels of the minimum point of the axis line
 o axiscolor
Color of the Axis.
 o BOTTOM
Constant flagging Axis position on the graph.
 o changed
True if axes have changed.
 o data_window
Before the Axis can be positioned correctly and drawn the data window needs to be calculated and passed to the Axis.
 o dataset
Vector containing a list of attached DataSets
 o drawgrid
If true draw a grid positioned on major ticks over the graph
 o drawzero
If true draw a line positioned on the Zero label tick mark.
 o exponent
Textline class to hold the label's exponent (if it has one).
 o force_end_labels
Rescale the axis so that labels fall at the end of the Axis.
 o g2d
The graph canvas this axis is attached to (if it is attached to any)
 o gridcolor
Color of the grid
 o guess_label_number
Initial guess for the number of labels required
 o HORIZONTAL
Constant flagging Horizontal Axis
 o label
Textline class to hold the labels before printing.
 o label_count
The number of labels required
 o label_exponent
The label exponent
 o label_start
The starting value of the labels
 o label_step
The increment between labels
 o label_string
String to contain the labels.
 o label_value
The actual values of the axis labels
 o LEFT
Constant flagging Axis position on the graph.
 o major_tic_size
Size in pixels of the major tick marks
 o manualRange
If true the axis range must be manually set by setting the Axis.minimum and Axis.maximum variables.
 o max_label_width
The width of the maximum label.
 o maximum
Maximum data value of the axis.
 o minimum
Minimum data value of the axis.
 o minor_tic_count
Number of minor tick marks between major tick marks
 o minor_tic_size
Size in pixels of the minor tick marks
 o NUMBER_OF_TICS
The first guess on the number of Labeled Major tick marks.
 o orientation
The orientation of the axis.
 o position
The position of the axis.
 o redraw
Default value true.
 o RIGHT
Constant flagging Axis position on the graph.
 o title
Textline class to contain the title of the axis.
 o TOP
Constant flagging Axis position on the graph.
 o VERTICAL
Constant flagging Vertical Axis
 o width
The width of the Axis.
 o zerocolor
Color of the line at the Zero label

Constructor Index

 o Axis()
Instantiate the class.
 o Axis(int)
Instantiate the class.

Method Index

 o attachDataSet(DataSet)
Attach a DataSet for the Axis to manage.
 o attachXdata(DataSet)
Attach a DataSet to a Horizontal Axis
 o attachYdata(DataSet)
Attach a DataSet to a Vertical Axis
 o calculateGridLabels()
calculate the labels
 o detachAll()
Detach All attached dataSets.
 o detachDataSet(DataSet)
Detach an attached DataSet
 o drawAxis(Graphics)
Draw the axis using the passed Graphics context.
 o drawHAxis(Graphics)
Draw a Horizontal Axis.
 o drawVAxis(Graphics)
Draw a Vertical Axis.
 o getAxisPos()
Return the position of the Axis.
 o getAxisWidth(Graphics)
Return the width of the axis.
 o getDataMax()
Return the maximum value of All datasets attached to the axis.
 o getDataMin()
Return the minimum value of All datasets attached to the axis.
 o getDouble(int)
Return the data value equivalent of the passed pixel position.
 o getInteger(double)
Return the pixel equivalent of the passed data value.
 o isVertical()
If the Axis is Vertical return true.
 o positionAxis(int, int, int, int)
Position the axis at the passed coordinates.
 o resetRange()
Reset the range of the axis (the minimum and maximum values) to the default data values.
 o setExponentColor(Color)
Set the color of the exponent
 o setExponentFont(Font)
Set the font of the exponent
 o setLabelColor(Color)
Set the color of the labels
 o setLabelFont(Font)
Set the font of the labels.
 o setManualRange(boolean)
Is the range of the axis to be set automatically (based on the data) or manually by setting the values Axis.minimum and Axis.maximum?
 o setPosition(int)
Set the axis position.
 o setTitleColor(Color)
Set the color of the title
 o setTitleFont(Font)
Set the font of the title
 o setTitleRotation(int)
Set the title rotation angle.
 o setTitleText(String)
Set the title of the axis

Variables

 o HORIZONTAL
 static final int HORIZONTAL
Constant flagging Horizontal Axis

 o VERTICAL
 static final int VERTICAL
Constant flagging Vertical Axis

 o LEFT
 public static final int LEFT
Constant flagging Axis position on the graph. Left side => Vertical

 o RIGHT
 public static final int RIGHT
Constant flagging Axis position on the graph. Right side => Vertical

 o TOP
 public static final int TOP
Constant flagging Axis position on the graph. Top side => Horizontal

 o BOTTOM
 public static final int BOTTOM
Constant flagging Axis position on the graph. Bottom side => Horizontal

 o NUMBER_OF_TICS
 static final int NUMBER_OF_TICS
The first guess on the number of Labeled Major tick marks.

 o drawgrid
 public boolean drawgrid
If true draw a grid positioned on major ticks over the graph

 o drawzero
 public boolean drawzero
If true draw a line positioned on the Zero label tick mark.

 o gridcolor
 public Color gridcolor
Color of the grid

 o zerocolor
 public Color zerocolor
Color of the line at the Zero label

 o redraw
 public boolean redraw
Default value true. Normally never changed. If set false the Axis draw method exits without drawing the axis.

See Also:
drawAxis
 o force_end_labels
 public boolean force_end_labels
Rescale the axis so that labels fall at the end of the Axis. Default value false.

 o changed
 public boolean changed
True if axes have changed. Added by MCC.

 o major_tic_size
 public int major_tic_size
Size in pixels of the major tick marks

 o minor_tic_size
 public int minor_tic_size
Size in pixels of the minor tick marks

 o minor_tic_count
 public int minor_tic_count
Number of minor tick marks between major tick marks

 o axiscolor
 public Color axiscolor
Color of the Axis.

 o minimum
 public double minimum
Minimum data value of the axis. This is the value used to scale data into the data window. This is the value to alter to force a rescaling of the data window.

 o maximum
 public double maximum
Maximum data value of the axis. This is the value used to scale data into the data window. This is the value to alter to force a rescaling of the data window.

 o data_window
 public Dimension data_window
Before the Axis can be positioned correctly and drawn the data window needs to be calculated and passed to the Axis.

 o g2d
 public Graph2D g2d
The graph canvas this axis is attached to (if it is attached to any)

See Also:
Graph2D
 o amin
 protected Point amin
The position in pixels of the minimum point of the axis line

 o amax
 protected Point amax
The position in pixels of the maximum point of the axis line

 o orientation
 protected int orientation
The orientation of the axis. Either Axis.HORIZONTAL or Axis.VERTICAL

 o position
 protected int position
The position of the axis. Either Axis.LEFT, Axis.RIGHT, Axis.TOP, or Axis.BOTTOM

 o width
 protected int width
The width of the Axis. Where width for a horizontal axis is really the height

 o title
 protected RTextLine title
Textline class to contain the title of the axis.

 o label
 protected RTextLine label
Textline class to hold the labels before printing.

 o exponent
 protected RTextLine exponent
Textline class to hold the label's exponent (if it has one).

 o max_label_width
 protected int max_label_width
The width of the maximum label. Used to position a Vertical Axis.

 o dataset
 protected Vector dataset
Vector containing a list of attached DataSets

 o label_string
 protected String label_string[]
String to contain the labels.

 o label_value
 protected float label_value[]
The actual values of the axis labels

 o label_start
 protected double label_start
The starting value of the labels

 o label_step
 protected double label_step
The increment between labels

 o label_exponent
 protected int label_exponent
The label exponent

 o label_count
 protected int label_count
The number of labels required

 o guess_label_number
 protected int guess_label_number
Initial guess for the number of labels required

 o manualRange
 protected boolean manualRange
If true the axis range must be manually set by setting the Axis.minimum and Axis.maximum variables. The default is false. The default action is for the axis range to be calculated everytime a dataset is attached.

Constructors

 o Axis
 public Axis()
Instantiate the class. The defalt type is a Horizontal axis positioned at the bottom of the graph.

 o Axis
 public Axis(int p)
Instantiate the class. Setting the position.

Parameters:
p - Set the axis position. Must be one of Axis.BOTTOM, Axis.TOP, Axis.LEFT, Axis.RIGHT, Axis.HORIZONTAL or Axis.VERTICAL. If one of the latter two are used then Axis.BOTTOM or Axis.LEFT is assumed.

Methods

 o setPosition
 public void setPosition(int p)
Set the axis position.

Parameters:
p - Must be one of Axis.BOTTOM, Axis.TOP, Axis.LEFT, Axis.RIGHT, Axis.HORIZONTAL or Axis.VERTICAL. If one of the latter two are used then Axis.BOTTOM or Axis.LEFT is assumed.
 o attachDataSet
 public void attachDataSet(DataSet d)
Attach a DataSet for the Axis to manage.

Parameters:
d - dataSet to attach
See Also:
DataSet
 o detachDataSet
 public void detachDataSet(DataSet d)
Detach an attached DataSet

Parameters:
d - dataSet to detach
See Also:
DataSet
 o detachAll
 public void detachAll()
Detach All attached dataSets.

 o getDataMin
 public double getDataMin()
Return the minimum value of All datasets attached to the axis.

Returns:
Data minimum
 o getDataMax
 public double getDataMax()
Return the maximum value of All datasets attached to the axis.

Returns:
Data maximum
 o getInteger
 public int getInteger(double v)
Return the pixel equivalent of the passed data value. Using the position of the axis and the maximum and minimum values convert the data value into a pixel value

Parameters:
v - data value to convert
Returns:
equivalent pixel value
See Also:
getDouble
 o getDouble
 public double getDouble(int i)
Return the data value equivalent of the passed pixel position. Using the position of the axis and the maximum and minimum values convert the pixel position into a data value

Parameters:
i - pixel value
Returns:
equivalent data value
See Also:
getInteger
 o resetRange
 public void resetRange()
Reset the range of the axis (the minimum and maximum values) to the default data values. MCC: Modified to test for change in range.

 o getAxisPos
 public int getAxisPos()
Return the position of the Axis.

Returns:
One of Axis.LEFT, Axis.RIGHT, Axis.TOP, or Axis.BOTTOM.
 o isVertical
 public boolean isVertical()
If the Axis is Vertical return true.

 o getAxisWidth
 public int getAxisWidth(Graphics g)
Return the width of the axis.

Parameters:
g - graphics context.
 o positionAxis
 public boolean positionAxis(int xmin,
                             int xmax,
                             int ymin,
                             int ymax)
Position the axis at the passed coordinates. The coordinates should match the type of axis.

Parameters:
xmin - The minimum X pixel
xmax - The maximum X pixel. These should be equal if the axis is vertical
ymin - The minimum Y pixel
ymax - The maximum Y pixel. These should be equal if the axis is horizontal
Returns:
true if there are no inconsistencies.
 o drawAxis
 public void drawAxis(Graphics g)
Draw the axis using the passed Graphics context.

Parameters:
g - Graphics context for drawing
 o setTitleText
 public void setTitleText(String s)
Set the title of the axis

Parameters:
s - string containing text.
 o setTitleColor
 public void setTitleColor(Color c)
Set the color of the title

Parameters:
c - Color of the title.
 o setTitleFont
 public void setTitleFont(Font f)
Set the font of the title

Parameters:
c - Title font.
 o setTitleRotation
 public void setTitleRotation(int a)
Set the title rotation angle. Only multiples of 90 degrees allowed.

Parameters:
a - Title rotation angle in degrees.
 o setLabelColor
 public void setLabelColor(Color c)
Set the color of the labels

Parameters:
c - Color of the labels.
 o setLabelFont
 public void setLabelFont(Font f)
Set the font of the labels.

Parameters:
f - font.
 o setExponentColor
 public void setExponentColor(Color c)
Set the color of the exponent

Parameters:
c - Color.
 o setExponentFont
 public void setExponentFont(Font f)
Set the font of the exponent

Parameters:
f - font.
 o setManualRange
 public void setManualRange(boolean b)
Is the range of the axis to be set automatically (based on the data) or manually by setting the values Axis.minimum and Axis.maximum?

Parameters:
b - boolean value.
 o drawHAxis
 protected void drawHAxis(Graphics g)
Draw a Horizontal Axis.

Parameters:
g - Graphics context.
 o drawVAxis
 protected void drawVAxis(Graphics g)
Draw a Vertical Axis.

Parameters:
g - Graphics context.
 o attachXdata
 protected void attachXdata(DataSet d)
Attach a DataSet to a Horizontal Axis

Parameters:
d - dataset to attach.
 o attachYdata
 protected void attachYdata(DataSet d)
Attach a DataSet to a Vertical Axis

Parameters:
d - dataset to attach.
 o calculateGridLabels
 protected void calculateGridLabels()
calculate the labels


All Packages  Class Hierarchy  This Package  Previous  Next  Index