gov.noaa.pmel.sgt
Class Axis

java.lang.Object
  extended by gov.noaa.pmel.sgt.Axis
All Implemented Interfaces:
Selectable
Direct Known Subclasses:
SpaceAxis, TimeAxis

public abstract class Axis
extends java.lang.Object
implements Selectable

Abstract base class for Cartesian axes. Cartesian axes are designed to be used with the CartesianGraph class. Axes and AxisTransforms can be registed with an Axis. This allows changes in both the physical range and user range to be immediatedly updated for the registered AxisTransforms and axes.

Cartesian axes can have their user coordinates be double values or time (as GeoDate objects). These have been separated into two child objects.

Since:
1.0
Version:
$Revision$, $Date$
Author:
Donald Denbo
See Also:
SpaceAxis, TimeAxis

Field Summary
static int AUTO
           
static int BOTH_SIDES
          Draw the tics on both sides of the axes.
protected  CartesianGraph graph_
           
static int HORIZONTAL
          Draw a horizontal axis.
protected  java.awt.Color labelColor_
           
protected  java.awt.Font labelFont_
           
protected  java.lang.String labelFormat_
           
protected  double labelHeight_
           
protected  int labelInterval_
           
protected  int labelPosition_
           
protected  double largeTicHeight_
           
protected  java.awt.Color lineColor_
           
static int NEGATIVE_SIDE
          Place the label and/or tic on the negative side of the axis.
static int NO_LABEL
          Do not draw a label and/or tic.
protected  int numSmallTics_
           
protected  int orientation_
           
static int POSITIVE_SIDE
          Place the label and/or tic on the positive side of the axis.
protected  Range2D pRange_
           
protected  java.util.Vector registeredAxes_
           
protected  java.util.Vector registeredTransforms_
           
protected  boolean selectable_
           
protected  boolean selected_
           
protected  int sigDigits_
           
protected  double smallTicHeight_
           
protected  boolean space_
           
protected  double thickTicWidth_
           
protected  int ticPosition_
           
protected  SGLabel title_
           
static int VERTICAL
          Draw a vertical axis.
protected  boolean visible_
           
 
Constructor Summary
Axis()
          Default constructor for Axis.
Axis(java.lang.String id)
          Constructor for Axis.
 
Method Summary
 void clear(Axis axis)
          Unregister an axis.
 void clear(AxisTransform trns)
          Unregister an AxisTransform.
 void clearAllRegisteredAxes()
          Unregister all axes.
 void clearAllRegisteredTransforms()
          Unregister all AxisTransforms.
abstract  Axis copy()
          Create a copy of the axis.
protected  void drawThickXTic(java.awt.Graphics g, double xp, double yp, double ticHeight)
           
protected  void drawThickYTic(java.awt.Graphics g, double xp, double yp, double ticHeight)
           
protected  void drawXTic(java.awt.Graphics g, double xp, double yp, double ticHeight)
           
protected  void drawYTic(java.awt.Graphics g, double xp, double yp, double ticHeight)
           
abstract  java.awt.Rectangle getBounds()
          Get the bounding box for the axis in device units.
 CartesianGraph getGraph()
          Get the Graph associated with the axis.
 java.lang.String getId()
          Get the axis identifier.
 java.awt.Color getLabelColor()
          Get the label color.
 java.awt.Font getLabelFont()
          Get the label font.
 double getLabelHeightP()
          Get the label height.
 int getLabelPosition()
          Get the label position.
 double getLargeTicHeightP()
          Get the large tic height.
 java.awt.Color getLineColor()
          Get the line color.
 int getNumberRegisteredAxes()
          Get the number of currently registered axes.
 int getNumberRegisteredTransforms()
          Get the number of currently registered transforms.
 int getNumberSmallTics()
          Get the number of small tics between large tics.
 int getOrientation()
          Get axis orientation
 AbstractPane getPane()
          Get the parent pane.
 Range2D getRangeP()
          Get the physical range.
 double getSmallTicHeightP()
          Get the small tic height.
abstract  SoTPoint getSoTLocationU()
          Get current axis location.
abstract  SoTRange getSoTRangeU()
          Get user range.
 double getThickTicWidthP()
          Get the thick tic width.
 int getTicPosition()
          Get the tic position.
 SGLabel getTitle()
          Get the axis title.
 boolean isSelectable()
          Determines if the axis is selectable.
 boolean isSelected()
          Determines if the axis has been selected.
 boolean isSpace()
          Tests if axis is space.
 boolean isTime()
          Tests if axis is time.
 boolean isVisible()
          Determines if the axis is visible.
 void modified(java.lang.String mess)
          Used internally by sgt.
 void register(Axis axis)
          Register an axis.
 void register(AxisTransform trns)
          Register an AxisTransform.
 void setId(java.lang.String id)
          Set the axis identifier.
 void setLabelColor(java.awt.Color color)
          Set the label color.
 void setLabelFont(java.awt.Font fnt)
          Set the label font.
 void setLabelHeightP(double lhgt)
          Set the label height in physical units.
 void setLabelPosition(int labp)
          Set the label position.
 void setLargeTicHeightP(double lthgt)
          Set the large tic height in physical units.
 void setLineColor(java.awt.Color color)
          Set the line and tick color.
abstract  void setLocationU(SoTPoint pt)
          Set the axis location.
 void setNumberSmallTics(int nstic)
          Set the number of small tics between large tics.
 void setOrientation(int or)
          Set axis orientation.
 void setRangeP(Range2D pr)
          Set the physical range.
abstract  void setRangeU(SoTRange range)
          Set user range.
 void setSelectable(boolean select)
          Set the selectable state.
 void setSelected(boolean sel)
          Sets the selected property.
 void setSmallTicHeightP(double sthgt)
          Set the small tic height in physical units.
 void setThickTicWidthP(double wid)
          Set the thick tic width in physical units.
 void setTicPosition(int tpos)
          Set the tic position.
 void setTitle(SGLabel title)
          Set the axis title.
 void setVisible(boolean visible)
          Set the visibility state.
 java.lang.String toString()
          Get a String representation of the Axis.
protected abstract  void updateRegisteredAxes()
           
protected abstract  void updateRegisteredTransforms()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

graph_

protected CartesianGraph graph_

registeredAxes_

protected java.util.Vector registeredAxes_

registeredTransforms_

protected java.util.Vector registeredTransforms_

lineColor_

protected java.awt.Color lineColor_

numSmallTics_

protected int numSmallTics_

largeTicHeight_

protected double largeTicHeight_

smallTicHeight_

protected double smallTicHeight_

thickTicWidth_

protected double thickTicWidth_

ticPosition_

protected int ticPosition_

labelPosition_

protected int labelPosition_

labelInterval_

protected int labelInterval_

labelFont_

protected java.awt.Font labelFont_

labelColor_

protected java.awt.Color labelColor_

labelHeight_

protected double labelHeight_

sigDigits_

protected int sigDigits_

labelFormat_

protected java.lang.String labelFormat_

title_

protected SGLabel title_

pRange_

protected Range2D pRange_

space_

protected boolean space_

orientation_

protected int orientation_

selected_

protected boolean selected_

selectable_

protected boolean selectable_

visible_

protected boolean visible_

POSITIVE_SIDE

public static final int POSITIVE_SIDE
Place the label and/or tic on the positive side of the axis. The right side of VERTICAL axes and the top of HORIZONTAL axes.

See Also:
Constant Field Values

NEGATIVE_SIDE

public static final int NEGATIVE_SIDE
Place the label and/or tic on the negative side of the axis. The left side of VERTICAL axes and the bottom of HORIZONTAL axes.

See Also:
Constant Field Values

NO_LABEL

public static final int NO_LABEL
Do not draw a label and/or tic.

See Also:
Constant Field Values

BOTH_SIDES

public static final int BOTH_SIDES
Draw the tics on both sides of the axes.

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
Draw a horizontal axis.

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Draw a vertical axis.

See Also:
Constant Field Values

AUTO

public static final int AUTO
See Also:
Constant Field Values
Constructor Detail

Axis

public Axis()
Default constructor for Axis.


Axis

public Axis(java.lang.String id)
Constructor for Axis. Sets the axis identifier and initializes the defaults. Default values are:
    numberSmallTics = 0
    largeTicHeightP = 0.1
    smallTicHeightP = 0.05
     thickTicWidth_ = 0.025
        ticPosition = NEGATIVE_SIDE
      labelPosition = NEGATIVE_SIDE
      labelInterval = 2
          labelFont = Font("Helvetica", Font.ITALIC, 10);
         labelColor = Color.black;
       labelHeightP = 0.15
  significantDigits = 2;
        labelFormat = ""
              title = null
        orientation = HORIZONTAL
         selectable = true
            visible = true
  

Parameters:
id - axis identifier
Method Detail

updateRegisteredTransforms

protected abstract void updateRegisteredTransforms()

updateRegisteredAxes

protected abstract void updateRegisteredAxes()

drawXTic

protected void drawXTic(java.awt.Graphics g,
                        double xp,
                        double yp,
                        double ticHeight)

drawThickXTic

protected void drawThickXTic(java.awt.Graphics g,
                             double xp,
                             double yp,
                             double ticHeight)

drawYTic

protected void drawYTic(java.awt.Graphics g,
                        double xp,
                        double yp,
                        double ticHeight)

drawThickYTic

protected void drawThickYTic(java.awt.Graphics g,
                             double xp,
                             double yp,
                             double ticHeight)

copy

public abstract Axis copy()
Create a copy of the axis.

Returns:
the copy

getGraph

public CartesianGraph getGraph()
Get the Graph associated with the axis.

Returns:
Graph object.

getPane

public AbstractPane getPane()
Get the parent pane.

Returns:
AbstractPane
Since:
2.0

modified

public void modified(java.lang.String mess)
Used internally by sgt.

Since:
2.0

register

public void register(Axis axis)
Register an axis. Registered axes will be notified of changes to the user coordinate range.

Parameters:
axis - An Axis object.

register

public void register(AxisTransform trns)
Register an AxisTransform. Registered AxisTransforms will be notified of changes to the user coordinate range and physical coordinate range.

Parameters:
trns - A AxisTransform object.

clear

public void clear(Axis axis)
Unregister an axis. Axis will no longer be notified of changes in the user range.

Parameters:
axis - An Axis object.

clear

public void clear(AxisTransform trns)
Unregister an AxisTransform. The AxisTransform will no longer be notified of changes to the user or physical coordinate range.

Parameters:
trns - A AxisTransform ojbect.

clearAllRegisteredAxes

public void clearAllRegisteredAxes()
Unregister all axes. No axes will be notified of changes in the user range.


clearAllRegisteredTransforms

public void clearAllRegisteredTransforms()
Unregister all AxisTransforms. No AxisTransforms will be notified of changes in the user of physical range.


getNumberRegisteredTransforms

public int getNumberRegisteredTransforms()
Get the number of currently registered transforms.

Returns:
number of registered transforms

getNumberRegisteredAxes

public int getNumberRegisteredAxes()
Get the number of currently registered axes.

Returns:
number of registered axes

setLargeTicHeightP

public void setLargeTicHeightP(double lthgt)
Set the large tic height in physical units.

Parameters:
lthgt - large tic height.

getLargeTicHeightP

public double getLargeTicHeightP()
Get the large tic height.

Returns:
large tic height in physcial units.

setNumberSmallTics

public void setNumberSmallTics(int nstic)
Set the number of small tics between large tics.

Parameters:
nstic - number of small tics.

getNumberSmallTics

public int getNumberSmallTics()
Get the number of small tics between large tics.

Returns:
number of small tics.

setSmallTicHeightP

public void setSmallTicHeightP(double sthgt)
Set the small tic height in physical units.

Parameters:
sthgt - small tic height.

getSmallTicHeightP

public double getSmallTicHeightP()
Get the small tic height.

Returns:
small tic height in physical units.

setThickTicWidthP

public void setThickTicWidthP(double wid)
Set the thick tic width in physical units. Minimum thickness is 3 pixels.

Parameters:
wid - thick tic width.

getThickTicWidthP

public double getThickTicWidthP()
Get the thick tic width.

Returns:
thick tic width in physical units.

setTicPosition

public void setTicPosition(int tpos)
Set the tic position. Tic position can be POSITIVE_SIDE, NEGATIVE_SIDE, or BOTH_SIDES.

Parameters:
tpos - tic position

getTicPosition

public int getTicPosition()
Get the tic position.

Returns:
tic position

setLabelPosition

public void setLabelPosition(int labp)
Set the label position. Label position can be POSITIVE_SIDE, NEGATIVE_SIDE, and NO_LABEL.

Parameters:
labp - label position.

getLabelPosition

public int getLabelPosition()
Get the label position.

Returns:
label position

setLabelFont

public void setLabelFont(java.awt.Font fnt)
Set the label font.

Parameters:
fnt - label font

getLabelFont

public java.awt.Font getLabelFont()
Get the label font.

Returns:
label font

setLineColor

public void setLineColor(java.awt.Color color)
Set the line and tick color.

Parameters:
color - line and tick color
Since:
3.0

getLineColor

public java.awt.Color getLineColor()
Get the line color.

Returns:
color
Since:
3.0

setLabelColor

public void setLabelColor(java.awt.Color color)
Set the label color.

Parameters:
color - label color
Since:
2.0

getLabelColor

public java.awt.Color getLabelColor()
Get the label color.

Returns:
color
Since:
2.0

setLabelHeightP

public void setLabelHeightP(double lhgt)
Set the label height in physical units.

Parameters:
lhgt - label height.

getLabelHeightP

public double getLabelHeightP()
Get the label height.

Returns:
label height

setTitle

public void setTitle(SGLabel title)
Set the axis title.

Parameters:
title - axis title

getTitle

public SGLabel getTitle()
Get the axis title.

Returns:
axis title

setRangeP

public void setRangeP(Range2D pr)
Set the physical range. This method updates any registered Transforms. If no Transforms are registered, the setRangeP method has no effect.

Parameters:
pr - physcial range

getRangeP

public Range2D getRangeP()
Get the physical range. Obtains the physical range from the associated CartesianGraph object and attached Transform.

Returns:
physical range

setId

public void setId(java.lang.String id)
Set the axis identifier.

Parameters:
id - identifier

getId

public java.lang.String getId()
Get the axis identifier.

Returns:
identifier

setOrientation

public void setOrientation(int or)
Set axis orientation. Allowed orientations are HORIZONATAL and VERTICAL.

Parameters:
or - orientation

getOrientation

public int getOrientation()
Get axis orientation

Returns:
axis orientation

isSpace

public boolean isSpace()
Tests if axis is space.

Returns:
true if space

isTime

public boolean isTime()
Tests if axis is time.

Returns:
true if time

getBounds

public abstract java.awt.Rectangle getBounds()
Get the bounding box for the axis in device units.

Specified by:
getBounds in interface Selectable
Returns:
bounding box

toString

public java.lang.String toString()
Get a String representation of the Axis.

Overrides:
toString in class java.lang.Object
Returns:
String representation

setSelected

public void setSelected(boolean sel)
Description copied from interface: Selectable
Sets the selected property.

Specified by:
setSelected in interface Selectable
Parameters:
sel - true if selected, false if not.

isSelected

public boolean isSelected()
Determines if the axis has been selected.

Specified by:
isSelected in interface Selectable
Returns:
true, if selected
Since:
2.0

setSelectable

public void setSelectable(boolean select)
Set the selectable state.

Specified by:
setSelectable in interface Selectable
Parameters:
select - if true object is selectable
Since:
2.0

isSelectable

public boolean isSelectable()
Determines if the axis is selectable.

Specified by:
isSelectable in interface Selectable
Returns:
true if selectable
Since:
2.0

isVisible

public boolean isVisible()
Determines if the axis is visible.

Since:
2.0

setVisible

public void setVisible(boolean visible)
Set the visibility state.

Since:
2.0

setLocationU

public abstract void setLocationU(SoTPoint pt)
Set the axis location.

Since:
2.0

getSoTLocationU

public abstract SoTPoint getSoTLocationU()
Get current axis location.

Since:
2.0

setRangeU

public abstract void setRangeU(SoTRange range)
Set user range.

Since:
2.0

getSoTRangeU

public abstract SoTRange getSoTRangeU()
Get user range.

Since:
2.0