org.omegahat.Graphics.Plots
Class Scatterplot

java.lang.Object
  |
  +--org.omegahat.Graphics.Primitives.GraphicalObject
        |
        +--org.omegahat.Graphics.Primitives.RGO
              |
              +--org.omegahat.Graphics.Primitives.GraphicalContainer
                    |
                    +--org.omegahat.Graphics.Plots.DataPlot
                          |
                          +--org.omegahat.Graphics.Plots.Scatterplot
All Implemented Interfaces:
Addable, Copyable, GraphicalComponentInt, GraphicalContainerInt, MathOperable, ScaledComponentInt, SimpleGraphicalContainerInt, Subsettable, Tree

public class Scatterplot
extends DataPlot

the basic x-data, y-data plot.


Field Summary
static int CURRENT_SCALE
          Maintain the current scale when new points are outside its range.
static int EXTEND_SCALE
          Extend the scale for new points falling outside the range of the current one.
static int ICONS
          alias for POINTS
static int LINES
          Use Lines for type of element in plot.
static int MAX_TYPES
           
static int NEW_SCALE
          Create a new scale when new points fall ouside the range of the current one.
static int POINTS
          Use Points for type of element in plot.
static int WITH_BREAKS
          alias for MAX_TYPES
 
Fields inherited from class org.omegahat.Graphics.Plots.DataPlot
dataRegion, xAxis, xLabel, yAxis, yLabel
 
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
Scatterplot()
           
Scatterplot(double[] x, double[] y)
           
Scatterplot(double[] x, double[] y, int type)
           
Scatterplot(NumericVariableInt x, NumericVariableInt y)
           
Scatterplot(RealVariable x, RealVariable y)
           
Scatterplot(ScaleInt sx, ScaleInt sy)
           
 
Method Summary
 GraphicalContainerInt addData(double[] x, double[] y, int type, int rescale)
           
 GraphicalContainerInt addIcons(double[] x, double[] y, javax.swing.Icon[] icons, int rescale)
          Add the icons from the array of icons, plotted at the x, y co-ordinates.
 GraphicalContainerInt addLines(double[] x, double[] y, int rescale)
          Add a connected line segment through the data.
 GraphicalContainerInt addLinesWithBreaks(double[] x, double[] y, int rescale)
          Add connected line segments, with breaks wherever either co-ordinate is NaN.
 GraphicalContainerInt addStringIcons(double[] x, double[] y, int rescale)
          Add an icon (the current default StringIcon in this call) at each of the points x[i], y[i].
 void adjustScales()
           
 ScaleInt dataScaleX(double[] x, int how)
          use the x array to scale or re-scale the x co-ordinates of the plot.
 ScaleInt dataScaleY(double[] y, int how)
          use the y array to scale or re-scale the y co-ordinates of the plot.
 void makeScales(double[] x, double[] y)
           
 void makeScales(double[] x, double[] y, int rescale)
          Make (or remake) the scaling for the plot, using the data values and adjusting to leave a little extra space.
protected  boolean ok(double x, double y)
          Check for NaN, Inf values
 
Methods inherited from class org.omegahat.Graphics.Plots.DataPlot
bottomAxis, bottomAxis, createDataRegion, createDataRegion, createDataRegion, createRegionAllocator, dataRegion, getXAxis, getXLabel, getYAxis, getYLabel, leftAxis, leftAxis, make, setXAxis, setXLabel, setYAxis, setYLabel
 
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.GraphicalComponentInt
getParameters, getRegion, isActive, isVisible, parents, setActive, setParameters, setRegion, setVisible
 

Field Detail

POINTS

public static final int POINTS
Use Points for type of element in plot.

LINES

public static final int LINES
Use Lines for type of element in plot.

ICONS

public static final int ICONS
alias for POINTS

MAX_TYPES

public static final int MAX_TYPES

WITH_BREAKS

public static final int WITH_BREAKS
alias for MAX_TYPES

NEW_SCALE

public static final int NEW_SCALE
Create a new scale when new points fall ouside the range of the current one.

EXTEND_SCALE

public static final int EXTEND_SCALE
Extend the scale for new points falling outside the range of the current one.

CURRENT_SCALE

public static final int CURRENT_SCALE
Maintain the current scale when new points are outside its range.
Constructor Detail

Scatterplot

public Scatterplot()

Scatterplot

public Scatterplot(ScaleInt sx,
                   ScaleInt sy)

Scatterplot

public Scatterplot(double[] x,
                   double[] y)

Scatterplot

public Scatterplot(double[] x,
                   double[] y,
                   int type)

Scatterplot

public Scatterplot(RealVariable x,
                   RealVariable y)

Scatterplot

public Scatterplot(NumericVariableInt x,
                   NumericVariableInt y)
Method Detail

addData

public GraphicalContainerInt addData(double[] x,
                                     double[] y,
                                     int type,
                                     int rescale)

addStringIcons

public GraphicalContainerInt addStringIcons(double[] x,
                                            double[] y,
                                            int rescale)
Add an icon (the current default StringIcon in this call) at each of the points x[i], y[i].

The added icons can extend or replace the current scale, or be clipped to it, depending on the value of the rescale argument.

No icons will be plotted at any point for which one of the co-ordinates is NaN or Inf.


addIcons

public GraphicalContainerInt addIcons(double[] x,
                                      double[] y,
                                      javax.swing.Icon[] icons,
                                      int rescale)
Add the icons from the array of icons, plotted at the x, y co-ordinates. Each icon will be embedded in an object of class Graphics.Primitives.IconPrimitive, to incorporate the appropriate co-ordinates.

All three arrays will be recycled to produce as many icons on the plot as the maximum of the three lengths. If the icons array is recycled, the resulting IconPrimitive objects will be distinct, but will refer to the same Icon object. This means that changing parameters on the objects in the GraphicalElement object returned by this call will change only those individual displayed objects, but changing a property of one of the icons in the array supplied in the call will change all the instances of that icon.

No icons will be plotted at any point for which one of the co-ordinates is NaN or Inf.


ok

protected boolean ok(double x,
                     double y)
Check for NaN, Inf values

addLines

public GraphicalContainerInt addLines(double[] x,
                                      double[] y,
                                      int rescale)
Add a connected line segment through the data.

No checks are made for possible NaN or Inf values. The input arrays are retained in the graphics object, so that subsequent changes to individual elements of the arrays will move the corresponding point when the plot is repainted. (This is not necessarily to be considered a feature.)


addLinesWithBreaks

public GraphicalContainerInt addLinesWithBreaks(double[] x,
                                                double[] y,
                                                int rescale)
Add connected line segments, with breaks wherever either co-ordinate is NaN. The only line segments appearing in the plot will be those for which neither end of the line segment is NaN in either the x or y co-ordinate.

Copies are made of the input arrays; later changes in the elements will not be reflected in the plot.


makeScales

public void makeScales(double[] x,
                       double[] y,
                       int rescale)
Make (or remake) the scaling for the plot, using the data values and adjusting to leave a little extra space.

makeScales

public void makeScales(double[] x,
                       double[] y)

adjustScales

public void adjustScales()

dataScaleX

public ScaleInt dataScaleX(double[] x,
                           int how)
use the x array to scale or re-scale the x co-ordinates of the plot. The second argument controls how the scaling is done: NEW_SCALE, EXTEND_SCALE, or CURRENT_SCALE.

dataScaleY

public ScaleInt dataScaleY(double[] y,
                           int how)
use the y array to scale or re-scale the y co-ordinates of the plot. The second argument controls how the scaling is done: NEW_SCALE, EXTEND_SCALE, or CURRENT_SCALE.