visad
Class AxisScale

java.lang.Object
  extended by visad.AxisScale
All Implemented Interfaces:
Serializable

public class AxisScale
extends Object
implements Serializable

Class which defines the scales displayed along the spatial axes of a display. Each ScalarMap that has a DisplayScalar of the X, Y, or Z axis will have a non-null AxisScale.

Author:
Don Murray
See Also:
ScalarMap.getAxisScale(), Serialized Form

Field Summary
static int PRIMARY
          identifier for primary label side of axis
static int QUATERNARY
          identifier for quaternary label side of axis
static int SECONDARY
          identifier for secondary label side of axis
static int TERTIARY
          identifier for tertiary label side of axis
static int X_AXIS
          X_AXIS identifier
static int Y_AXIS
          Y_AXIS identifier
static int Z_AXIS
          Z_AXIS identifier
 
Constructor Summary
AxisScale(ScalarMap map)
          Construct a new AxisScale for the given ScalarMap
 
Method Summary
 void createStandardLabels(double max, double min, double base, double increment)
          Creates a hashtable that will draw text labels starting at the starting point specified using the increment field.
 int getAxis()
          Get axis that the scale will be displayed on.
 int getAxisOrdinal()
          Get the position of this AxisScale on the Axis (first, second, third).
 boolean getBaseLineVisible()
          Determine whether the base line for the scale should be visible
 Color getColor()
          Get the color of this axis scale.
 Font getFont()
          Get the font used for rendering the labels
 boolean getGridLinesVisible()
          Get the visibility of the grid lines
 String getLabel()
          Deprecated. Get the label of the AxisScale.
 boolean getLabelAllTicks()
          Return whether all major ticks are to be labeled.
 VisADTriangleArray getLabelArray()
          Get the labels rendered with a font to pass to the renderer.
 boolean getLabelBothSides()
          See if both sides are labeled
 int getLabelSize()
          Gets the size of the labels.
 Hashtable getLabelTable()
          Get the Hashtable used for labels
 double getMajorTickSpacing()
          This method returns the major tick spacing.
 double getMinorTickSpacing()
          This method returns the minor tick spacing.
 NumberFormat getNumberFormat()
          Get the formatting for labels.
 VisADLineArray getScaleArray()
          Get the Scale to pass to the renderer.
 boolean getScreenBased()
          return screenBased mode
 int getSide()
          Get the alignment for the axis
 boolean getSnapToBox()
          Determine whether this property is set.
 int getTickOrientation()
          Get the orientation for the ticks along the axis
 boolean getTicksVisible()
          See if ticks are visible
 String getTitle()
          Get the title of the AxisScale.
 boolean isLabelRelief()
          Checks if is label has relief.
 boolean isVisible()
          Get the visibility of the AxisScale
 boolean makeScale()
          Create the scale.
 boolean makeScale(boolean twoD, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, double scale, double offset, double line, double[] dataRange)
          inner logic of makeScale with no references to display, displayRenderer or scalarMap, allwoing more flexible placement of scales
 boolean makeScreenBasedScale(double xmin, double ymin, double xmax, double ymax, double XTMIN, double YTMIN, double XTMAX, double YTMAX)
          Create the scale for screen based.
 void setAutoComputeTicks(boolean b)
          Allow the AxisScale to automatically compute the desired majorTickSpacing based on the range of the ScalarMap.
 void setBaseLineVisible(boolean visible)
          Set visibility of base line.
 void setColor(Color color)
          Set the color of this axis scale.
 void setColor(float[] color)
          Set the color of this axis scale.
 void setFont(Font font)
          Set the font used for rendering the labels
 void setFont(HersheyFont font)
          Set the font used for rendering the labels
 void setGridLinesVisible(boolean show)
          Set the visibility of the grid lines; Grid lines are placed at major tick marks.
 void setLabel(String label)
          Deprecated. Set the label to be used for this axis. The default is the ScalarName of the ScalarMap.
 void setLabelAllTicks(boolean labelAll)
          Set whether all major ticks should be labeled.
 void setLabelBothSides(boolean both)
          Set whether both sides are labeled.
 void setLabelRelief(boolean labelRelief)
          Sets the label relief.
 void setLabelSize(int size)
          Sets the size of the labels.
 void setLabelTable(Hashtable labels)
          Used to specify what label will be drawn at any given value.
 void setMajorTicks(double[] majorTicks)
          Set major tick marks.
 void setMajorTickSpacing(double spacing)
          Set major tick mark spacing.
 void setMinorTicks(double[] minorTicks)
          Set minor tick marks.
 void setMinorTickSpacing(double spacing)
          Set minor tick mark spacing.
 void setNumberFormat(NumberFormat format)
          Set the formatting for all labels
 void setScreenBased(boolean sb)
          set screenBased mode true indicates axis is stationary relative to screen
 void setSide(int side)
          Set side for axis (PRIMARY, SECONDARY)
 void setSnapToBox(boolean b)
          Toggle whether the scale is along the box edge or not
 void setTickBase(double base)
          Sets the base value for tick marks.
 void setTickOrientation(int orient)
          Set orientation of tick marks along the axis line.
 void setTicksVisible(boolean visible)
          Set whether ticks are visible
 void setTitle(String title)
          Set the title to be used for this axis.
 void setVisible(boolean visible)
          Set the visibility of the AxisScale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_AXIS

public static final int X_AXIS
X_AXIS identifier

See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
Y_AXIS identifier

See Also:
Constant Field Values

Z_AXIS

public static final int Z_AXIS
Z_AXIS identifier

See Also:
Constant Field Values

PRIMARY

public static final int PRIMARY
identifier for primary label side of axis

See Also:
Constant Field Values

SECONDARY

public static final int SECONDARY
identifier for secondary label side of axis

See Also:
Constant Field Values

TERTIARY

public static final int TERTIARY
identifier for tertiary label side of axis

See Also:
Constant Field Values

QUATERNARY

public static final int QUATERNARY
identifier for quaternary label side of axis

See Also:
Constant Field Values
Constructor Detail

AxisScale

public AxisScale(ScalarMap map)
          throws VisADException
Construct a new AxisScale for the given ScalarMap

Parameters:
map - ScalarMap to monitor. Must be mapped to one of Display.XAxis, Display.YAxis, Display.ZAxis
Throws:
VisADException - bad ScalarMap or other VisAD problem
Method Detail

getAxisOrdinal

public int getAxisOrdinal()
Get the position of this AxisScale on the Axis (first, second, third).

Returns:
position from the axis (first = 0, second = 1, etc)

setLabel

public void setLabel(String label)
Deprecated. Set the label to be used for this axis. The default is the ScalarName of the ScalarMap.

Parameters:
label - label to be used
See Also:
setTitle(String)

getLabel

public String getLabel()
Deprecated. Get the label of the AxisScale.

Returns:
label
See Also:
getTitle()

setTitle

public void setTitle(String title)
Set the title to be used for this axis. The default is the ScalarName of the ScalarMap.

Parameters:
title - title to be used

getTitle

public String getTitle()
Get the title of the AxisScale.

Returns:
title

getAxis

public int getAxis()
Get axis that the scale will be displayed on.

Returns:
axis (X_AXIS, Y_AXIS or Z_AXIS)

getScaleArray

public VisADLineArray getScaleArray()
Get the Scale to pass to the renderer.

Returns:
VisADLineArray representing the scale

getLabelArray

public VisADTriangleArray getLabelArray()
Get the labels rendered with a font to pass to the renderer.

Returns:
VisADTriangleArray representing the labels

setScreenBased

public void setScreenBased(boolean sb)
set screenBased mode true indicates axis is stationary relative to screen


getScreenBased

public boolean getScreenBased()
return screenBased mode

Returns:
true if axis is stationary relative to screen

makeScreenBasedScale

public boolean makeScreenBasedScale(double xmin,
                                    double ymin,
                                    double xmax,
                                    double ymax,
                                    double XTMIN,
                                    double YTMIN,
                                    double XTMAX,
                                    double YTMAX)
                             throws VisADException
Create the scale for screen based.

Returns:
true if scale was successfully created, otherwise false
Throws:
VisADException

makeScale

public boolean makeScale()
                  throws VisADException
Create the scale.

Returns:
true if scale was successfully created, otherwise false
Throws:
VisADException

makeScale

public boolean makeScale(boolean twoD,
                         double xmin,
                         double ymin,
                         double zmin,
                         double xmax,
                         double ymax,
                         double zmax,
                         double scale,
                         double offset,
                         double line,
                         double[] dataRange)
                  throws VisADException
inner logic of makeScale with no references to display, displayRenderer or scalarMap, allwoing more flexible placement of scales

Throws:
VisADException

getColor

public Color getColor()
Get the color of this axis scale.

Returns:
Color of the scale.

setColor

public void setColor(Color color)
Set the color of this axis scale.

Parameters:
color - Color to use

setColor

public void setColor(float[] color)
Set the color of this axis scale.

Parameters:
color - array of red, green, and blue values in the range (0.0 - 1.0). color must be float[3].

setMajorTickSpacing

public void setMajorTickSpacing(double spacing)
Set major tick mark spacing. The number that is passed-in represents the distance, measured in values, between each major tick mark. If you have a ScalarMap with a range from 0 to 50 and the major tick spacing is set to 10, you will get major ticks next to the following values: 0, 10, 20, 30, 40, 50. This value will always be used unless you call setAutoComputeTicks with a true value.

Parameters:
spacing - spacing between major tick marks (must be > 0)
See Also:
getMajorTickSpacing(), setAutoComputeTicks(boolean)

setMajorTicks

public void setMajorTicks(double[] majorTicks)
Set major tick marks. Tick marks will be placed at the values on the axis.

Parameters:
majorTicks - the tick values

setMinorTicks

public void setMinorTicks(double[] minorTicks)
Set minor tick marks. Tick marks will be placed at the values on the axis.

Parameters:
minorTicks - the tick values

getMajorTickSpacing

public double getMajorTickSpacing()
This method returns the major tick spacing. The number that is returned represents the distance, measured in values, between each major tick mark.

Returns:
the number of values between major ticks
See Also:
setMajorTickSpacing(double)

setMinorTickSpacing

public void setMinorTickSpacing(double spacing)
Set minor tick mark spacing. The number that is passed-in represents the distance, measured in values, between each minor tick mark. If you have a ScalarMap with a range from 0 to 50 and the minor tick spacing is set to 10, you will get minor ticks next to the following values: 0, 10, 20, 30, 40, 50. This value will always be used unless you call setAutoComputeTicks with a true value.

Parameters:
spacing - spacing between minor tick marks (must be > 0)
See Also:
getMinorTickSpacing(), setAutoComputeTicks(boolean)

getMinorTickSpacing

public double getMinorTickSpacing()
This method returns the minor tick spacing. The number that is returned represents the distance, measured in values, between each minor tick mark.

Returns:
the number of values between minor ticks
See Also:
setMinorTickSpacing(double)

setAutoComputeTicks

public void setAutoComputeTicks(boolean b)
Allow the AxisScale to automatically compute the desired majorTickSpacing based on the range of the ScalarMap.

Parameters:
b - if true, have majorTickSpacing automatically computed.

createStandardLabels

public void createStandardLabels(double max,
                                 double min,
                                 double base,
                                 double increment)
Creates a hashtable that will draw text labels starting at the starting point specified using the increment field. If you call createStandardLabels(100, 0, 2.0, 10.0), then it will make labels for the values 2, 12, 22, 32, etc.

Throws:
IllegalArgumentException - if min > max, or increment is greater than max-min
See Also:
setLabelTable(java.util.Hashtable)

setLabelTable

public void setLabelTable(Hashtable labels)
                   throws VisADException
Used to specify what label will be drawn at any given value. The key-value pairs are of this format: { Double value, java.lang.String}

Parameters:
labels - map of value/label pairs
Throws:
VisADException - invalid hashtable
See Also:
getLabelTable()

getLabelTable

public Hashtable getLabelTable()
Get the Hashtable used for labels


setFont

public void setFont(Font font)
Set the font used for rendering the labels

Parameters:
font - new font to use

setFont

public void setFont(HersheyFont font)
Set the font used for rendering the labels

Parameters:
font - new font to use

getFont

public Font getFont()
Get the font used for rendering the labels

Returns:
font use or null if using default text plot

setBaseLineVisible

public void setBaseLineVisible(boolean visible)
Set visibility of base line.

Parameters:
visible - true to display (default), false to turn off

getBaseLineVisible

public boolean getBaseLineVisible()
Determine whether the base line for the scale should be visible

Returns:
true if line is visible, otherwise false;

setSnapToBox

public void setSnapToBox(boolean b)
Toggle whether the scale is along the box edge or not

Parameters:
b - true to snap to the box

getSnapToBox

public boolean getSnapToBox()
Determine whether this property is set.

Returns:
true if property is set, otherwise false;

setLabelSize

public void setLabelSize(int size)
Sets the size of the labels. You can use this to change the label size when a Font is not being used. If a Font is being used and you call setLabelSize(), a new Font is created using the old Font name and style, but with the new size.

Parameters:
size - font size to use
See Also:
setFont(java.awt.Font)

getLabelSize

public int getLabelSize()
Gets the size of the labels.

Returns:
relative size of labels

setTickBase

public void setTickBase(double base)
Sets the base value for tick marks. This only applies when setMajorTickSpacing or setMinorTickSpacing have been called.

Parameters:
base - base value for drawing tick marks. For example, if your scale ranges from -4 to 18 and you set the major tick spacing to 5, you will get ticks at -4, 1, 6, 11, and 16 by default. If you set the tick base value to 0, you will get ticks at 0, 5, 10, 15.

setSide

public void setSide(int side)
Set side for axis (PRIMARY, SECONDARY)

Parameters:
side - side for axis to appear on

getSide

public int getSide()
Get the alignment for the axis

Returns:
axis alignment (PRIMARY or SECONDARY)

setTickOrientation

public void setTickOrientation(int orient)
Set orientation of tick marks along the axis line.

Parameters:
orient - (PRIMARY or SECONDARY)

getTickOrientation

public int getTickOrientation()
Get the orientation for the ticks along the axis

Returns:
tick orientation (PRIMARY or SECONDARY)

setNumberFormat

public void setNumberFormat(NumberFormat format)
Set the formatting for all labels

Parameters:
format - format string

getNumberFormat

public NumberFormat getNumberFormat()
Get the formatting for labels. May be null (if not set)

Returns:
format used for labeling

setVisible

public void setVisible(boolean visible)
Set the visibility of the AxisScale

Parameters:
visible - true to display the AxisScale

isVisible

public boolean isVisible()
Get the visibility of the AxisScale

Returns:
true if AxisScale is being rendered

setGridLinesVisible

public void setGridLinesVisible(boolean show)
Set the visibility of the grid lines; Grid lines are placed at major tick marks.

Parameters:
show - true to display the grid lines

getGridLinesVisible

public boolean getGridLinesVisible()
Get the visibility of the grid lines

Returns:
true if grid lines are being rendered

setLabelBothSides

public void setLabelBothSides(boolean both)
Set whether both sides are labeled.

Parameters:
both - true to label both sides

getLabelBothSides

public boolean getLabelBothSides()
See if both sides are labeled

Returns:
true if labelling is on both sides

setTicksVisible

public void setTicksVisible(boolean visible)
Set whether ticks are visible

Parameters:
visible - true to show ticks

getTicksVisible

public boolean getTicksVisible()
See if ticks are visible

Returns:
true if labeling is on both sides

setLabelAllTicks

public void setLabelAllTicks(boolean labelAll)
Set whether all major ticks should be labeled. The default is to only label the first and last major tick. This setting is ignored if user labels are being used or if user manually calls createStandardLabels or setLabelTable

Parameters:
labelAll - true to label all (major) ticks. Overridden
See Also:
getLabelAllTicks(), createStandardLabels(double, double, double, double), setLabelTable(Hashtable)

getLabelAllTicks

public boolean getLabelAllTicks()
Return whether all major ticks are to be labeled.

Returns:
true if ticks are to be labeled.

isLabelRelief

public boolean isLabelRelief()
Checks if is label has relief.

Returns:
true, if is label has relief

setLabelRelief

public void setLabelRelief(boolean labelRelief)
Sets the label relief.

Parameters:
labelRelief - the new label relief