org.omegahat.Graphics.Plots
Class Axis

java.lang.Object
  |
  +--org.omegahat.Graphics.Primitives.GraphicalObject
        |
        +--org.omegahat.Graphics.Primitives.RGO
              |
              +--org.omegahat.Graphics.Primitives.GraphicalContainer
                    |
                    +--org.omegahat.Graphics.Plots.Axis
All Implemented Interfaces:
Addable, AxisInt, Copyable, GraphicalComponentInt, GraphicalContainerInt, MathOperable, ScaledComponentInt, SimpleGraphicalContainerInt, Subsettable, Tree
Direct Known Subclasses:
BottomAxis, CategoricalAxis, LeftAxis

public abstract class Axis
extends GraphicalContainer
implements AxisInt

the class for creating plot axes, with tick marks and labels.

Will choose suitable ``pretty'' locations for the ticks and generate corresponding text labels.

Currently only linear axes are implemented; that is, the tick positions will be equally spaced (linearly) over the scale of the axis. However, you can use the constructor that takes tick positions and labels to generate custom axes, or you can reset the tick locations to the transformed values after generating the axis. Just get the tick locations, modify them, and call makeAxis((Scale)null).


Field Summary
protected  GraphicalObject axisLabel
          The label for the entire axis.
static int DEFAULT_NTICKS
          the default suggestion for number of ticks (5).
protected  int nTicks
          the suggested number of ticks and labels
protected  java.lang.String[] tickLabel
          the labels for the tick marks.
protected  double[] tickLocn
          the locations of the tick marks and tick labels.
protected  java.util.Vector ticks
          The vector of tick objects.
 
Fields inherited from class org.omegahat.Graphics.Primitives.GraphicalContainer
allocator, children, origin, parent, scaleX, scaleY
 
Fields inherited from class org.omegahat.Graphics.Primitives.RGO
region
 
Fields inherited from class org.omegahat.Graphics.Primitives.GraphicalObject
ACTIVE, fontSize, lastDevice, lastHeightCM, lastRegion, lastWidthCM, parents, status, VISIBLE
 
Fields inherited from interface org.omegahat.Environment.DataStructures.MathOperable
DIVIDE, MINUS, MULTIPLY, PLUS
 
Constructor Summary
Axis()
           
Axis(ScaleInt s, double[] tickLocn, java.lang.String[] tickLabel, java.lang.String axisLabel)
          a constructor when you want to do it all yourself.
Axis(ScaleInt s, java.lang.String label)
          use the given scale, choosing pretty tick locations with the default number of ticks, and generating tick labels from the corresponding numbers.
Axis(ScaleInt s, java.lang.String label, int nTicks)
          use the given scale, using the specified number of ticks to generate labels and positions for the tick marks.
 
Method Summary
 void create(ScaleInt s, java.lang.String label, AxisRangeInt sr)
           
protected  void createTickData(AxisRangeInt sr)
          Populate the internal information about the tick marks and labels computed from the range information.
abstract  void editScale(double min, double max)
          Change the scale to the given minimum and maximum.
 GraphicalObject getAxisLabel()
          Accessor for axisLabel field
 int getNTicks()
          get the suggested number of tick marks.
abstract  ScaleInt getScale()
          Get the scale object for this axis
 java.lang.String[] getTickLabels()
          the tick labels.
 double[] getTickLocations()
          the tick locations.
 void makeAxis(ScaleInt s, double[] tickLocn, java.lang.String[] tickLabel, java.lang.String label)
          remake the axis (e.g, after transforming the tick locations).
abstract  void makeContainer(ScaleInt s)
           
abstract  void makeLabel(java.lang.String label)
          Make this string the label for the entire axis.
abstract  void makeMajor()
           
abstract  void makeTicks(ScaleInt s, double[] tickLocn, java.lang.String[] tickLabel)
           
 void removeTicks()
           
 GraphicalObject setAxisLabel(GraphicalObject value)
          Accessor for setting axisLabel field
 void setNTicks(int n)
          set the suggested number of tick marks.
 void setTickLabels(java.lang.String[] labels)
          set the tick labels, but leave the location alone.
 void setTickLocations(double[] locations)
          set the tick locations, but leave the labels alone.
 
Methods inherited from class org.omegahat.Graphics.Primitives.GraphicalContainer
add, addGraphicalObject, addGraphicalObject, addGraphicalObject, addGraphicalObject, addGraphicalObject, addGraphicalObject, addGraphicalObject, addGraphicalObject, addGraphicalObject, addGraphicalObject, addValue, copy, copy, draw, drawChildren, get, getChild, getChildCount, getChildren, getDevice, getOrigin, getRegionAllocator, getXScale, getYScale, parent, parent, remove, removeGraphicalObject, removeGraphicalObject, setOrigin, setRegionAllocator, setXScale, setYScale, subset, subset, transform, transform
 
Methods inherited from class org.omegahat.Graphics.Primitives.RGO
center, centre, createRegionDescription, createRegionDescription, getRegion, height, height, setHJust, setRegion, setVJust, width, width, x, x, y, y
 
Methods inherited from class org.omegahat.Graphics.Primitives.GraphicalObject
cacheSize, getFontSize, getFontSize, getParameters, getParents, getStatus, isActive, isVisible, lastHeightCM, lastRegion, lastWidthCM, parents, setActive, setParameters, setParents, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.omegahat.Graphics.Primitives.ScaledComponentInt
getXScale, getYScale, setXScale, setYScale
 
Methods inherited from interface org.omegahat.Graphics.Primitives.GraphicalComponentInt
draw, getParameters, getRegion, isActive, isVisible, parent, parent, parents, setActive, setParameters, setRegion, setVisible
 

Field Detail

DEFAULT_NTICKS

public static final int DEFAULT_NTICKS
the default suggestion for number of ticks (5).

nTicks

protected int nTicks
the suggested number of ticks and labels

tickLocn

protected double[] tickLocn
the locations of the tick marks and tick labels.

tickLabel

protected java.lang.String[] tickLabel
the labels for the tick marks.

ticks

protected java.util.Vector ticks
The vector of tick objects.

axisLabel

protected GraphicalObject axisLabel
The label for the entire axis.
Constructor Detail

Axis

public Axis()

Axis

public Axis(ScaleInt s,
            double[] tickLocn,
            java.lang.String[] tickLabel,
            java.lang.String axisLabel)
a constructor when you want to do it all yourself.

Axis

public Axis(ScaleInt s,
            java.lang.String label)
use the given scale, choosing pretty tick locations with the default number of ticks, and generating tick labels from the corresponding numbers.

Axis

public Axis(ScaleInt s,
            java.lang.String label,
            int nTicks)
use the given scale, using the specified number of ticks to generate labels and positions for the tick marks.
Method Detail

getAxisLabel

public GraphicalObject getAxisLabel()
Accessor for axisLabel field

setAxisLabel

public GraphicalObject setAxisLabel(GraphicalObject value)
Accessor for setting axisLabel field

getScale

public abstract ScaleInt getScale()
Description copied from interface: AxisInt
Get the scale object for this axis
Specified by:
getScale in interface AxisInt

getNTicks

public int getNTicks()
get the suggested number of tick marks.

getTickLocations

public double[] getTickLocations()
the tick locations.

setTickLocations

public void setTickLocations(double[] locations)
set the tick locations, but leave the labels alone.

getTickLabels

public java.lang.String[] getTickLabels()
the tick labels.

setTickLabels

public void setTickLabels(java.lang.String[] labels)
set the tick labels, but leave the location alone.

setNTicks

public void setNTicks(int n)
set the suggested number of tick marks.

0 is allowed, but a negative number resets the number of tick marks to the default.


create

public void create(ScaleInt s,
                   java.lang.String label,
                   AxisRangeInt sr)

createTickData

protected void createTickData(AxisRangeInt sr)
Populate the internal information about the tick marks and labels computed from the range information.

makeAxis

public void makeAxis(ScaleInt s,
                     double[] tickLocn,
                     java.lang.String[] tickLabel,
                     java.lang.String label)
remake the axis (e.g, after transforming the tick locations).

If the scale provided is null, the scale will be recomputed from the current tick locations.


makeContainer

public abstract void makeContainer(ScaleInt s)

makeMajor

public abstract void makeMajor()

makeTicks

public abstract void makeTicks(ScaleInt s,
                               double[] tickLocn,
                               java.lang.String[] tickLabel)

makeLabel

public abstract void makeLabel(java.lang.String label)
Description copied from interface: AxisInt
Make this string the label for the entire axis.
Specified by:
makeLabel in interface AxisInt

removeTicks

public void removeTicks()

editScale

public abstract void editScale(double min,
                               double max)
Change the scale to the given minimum and maximum.

The bottom axis and left axis define this to recreate the suitable ticks, etc.

Specified by:
editScale in interface AxisInt