edu.mines.jtk.mosaic
Class PointsView

java.lang.Object
  extended by edu.mines.jtk.mosaic.TiledView
      extended by edu.mines.jtk.mosaic.PointsView

public class PointsView
extends TiledView

A view of points (x1,x2) with marks at points and/or lines between them. Points (x1,x2) may be specified as arrays x1 and x2 of coordinates. Each pair of arrays x1 and x2 corresponds to one plot segment. Multiple plot segments may be specified by arrays of arrays of x1 and x2 coordinates.

For each point (x1,x2), a mark with a specified style, size, and color may be painted. Between each consecutive pair of points (x1,x2) within a plot segment, lines with specified style, width, and color may be painted.

For example, to view sampled functions x2 = sin(x1) and x2 = cos(x1), one might construct two plot segments by specifying an array of two arrays of x1 coordinates and a corresponding array of two arrays of x2 coordinates.

Note that mark and line attributes are constant for each points view. These attributes do not vary among plot segments. To paint marks and lines with different attributes, construct multiple views.

Version:
2005.12.28
Author:
Dave Hale, Colorado School of Mines

Nested Class Summary
static class PointsView.Line
          The style of line plotted between consecutive points (x1,x2).
static class PointsView.Mark
          The style of mark plotted at points (x1,x2).
static class PointsView.Orientation
          Orientation of axes x1 and x2.
 
Constructor Summary
PointsView(float[] x2)
          Constructs a view of points (x1,x2) with specified x2 coordinates.
PointsView(float[][] x1, float[][] x2)
          Constructs a view of points (x1,x2) with multiple plot segments.
PointsView(float[][] x1, float[][] x2, float[][] x3)
          Constructs a view of points (x1,x2,x3) with multiple plot segments.
PointsView(float[] x1, float[] x2)
          Constructs a view of points (x1,x2) with a single plot segment.
PointsView(float[] x1, float[] x2, float[] x3)
          Constructs a view of points (x1,x2,x3) with a single plot segment.
PointsView(Sampling s1, float[] x2)
          Constructs a view of points (x1,x2) for a sampled function x2(x1).
 
Method Summary
 PointsView.Orientation getOrientation()
          Gets the orientation of (x1,x2) axes.
 void paint(java.awt.Graphics2D g2d)
          Paints this tiled view.
 void set(float[][] x1, float[][] x2)
          Sets array of arrays of (x1,x2) coordinates for multiple plot segments.
 void set(float[][] x1, float[][] x2, float[][] x3)
          Sets array of arrays of (x1,x2,x3) coordinates for multiple plot segments.
 void set(float[] x1, float[] x2)
          Sets arrays of (x1,x2) coordinates for a single plot segment.
 void set(float[] x1, float[] x2, float[] x3)
          Sets arrays of (x1,x2,x3) coordinates for a single plot segment.
 void set(Sampling s1, float[] x2)
          Sets (x1,x2) coordinates for a sampled function x2(x1).
 void setLineColor(java.awt.Color color)
          Sets the line color.
 void setLineStyle(PointsView.Line style)
          Sets the line style.
 void setLineWidth(float width)
          Sets the line width.
 void setMarkColor(java.awt.Color color)
          Sets the mark color.
 void setMarkSize(float size)
          Sets the mark size.
 void setMarkStyle(PointsView.Mark style)
          Sets the mark style.
 void setOrientation(PointsView.Orientation orientation)
          Sets the orientation of (x1,x2) axes.
 void setStyle(java.lang.String style)
          Sets the color, line style, and mark style from a style string.
 void setTextFormat(java.lang.String format)
          Sets the format used for text labels.
 
Methods inherited from class edu.mines.jtk.mosaic.TiledView
getBestHorizontalProjector, getBestVerticalProjector, getHorizontalProjector, getLineWidth, getTile, getTranscaler, getVerticalProjector, repaint, setBestProjectors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PointsView

public PointsView(float[] x2)
Constructs a view of points (x1,x2) with specified x2 coordinates. The corresponding coordinates x1 are assumed to be 0, 1, 2, ....

Parameters:
x2 - array of x2 coordinates.

PointsView

public PointsView(Sampling s1,
                  float[] x2)
Constructs a view of points (x1,x2) for a sampled function x2(x1).

Parameters:
s1 - the sampling of x1 coordinates.
x2 - array of x2 coordinates.

PointsView

public PointsView(float[] x1,
                  float[] x2)
Constructs a view of points (x1,x2) with a single plot segment. The lengths of the specified arrays x1 and x2 must be equal.

Parameters:
x1 - array of x1 coordinates.
x2 - array of x2 coordinates.

PointsView

public PointsView(float[][] x1,
                  float[][] x2)
Constructs a view of points (x1,x2) with multiple plot segments. The lengths of the specified arrays x1 and x2 must be equal.

Parameters:
x1 - array of arrays of x1 coordinates.
x2 - array of arrays of x2 coordinates.

PointsView

public PointsView(float[] x1,
                  float[] x2,
                  float[] x3)
Constructs a view of points (x1,x2,x3) with a single plot segment. The lengths of the specified arrays x1 and x2 must be equal. If x3 is not null, its length must equal that of x1 and x2.

Parameters:
x1 - array of x1 coordinates.
x2 - array of x2 coordinates.
x3 - array of x3 coordinates; null, if none.

PointsView

public PointsView(float[][] x1,
                  float[][] x2,
                  float[][] x3)
Constructs a view of points (x1,x2,x3) with multiple plot segments. The lengths of the specified arrays x1 and x2 must be equal. If x3 is not null, its length must equal that of x1 and x2.

Parameters:
x1 - array of arrays of x1 coordinates.
x2 - array of arrays of x2 coordinates.
Method Detail

set

public void set(Sampling s1,
                float[] x2)
Sets (x1,x2) coordinates for a sampled function x2(x1).

Parameters:
s1 - the sampling of x1 coordinates.
x2 - array of x2 coordinates.

set

public void set(float[] x1,
                float[] x2)
Sets arrays of (x1,x2) coordinates for a single plot segment. The lengths of the specified arrays x1 and x2 must be equal.

Parameters:
x1 - array of x1 coordinates.
x2 - array of x2 coordinates.

set

public void set(float[] x1,
                float[] x2,
                float[] x3)
Sets arrays of (x1,x2,x3) coordinates for a single plot segment. The lengths of the specified arrays x1 and x2 must be equal. If x3 is not null, its length must equal that of x1 and x2.

Parameters:
x1 - array of x1 coordinates.
x2 - array of x2 coordinates.
x3 - array of x3 coordinates; null, if none.

set

public void set(float[][] x1,
                float[][] x2)
Sets array of arrays of (x1,x2) coordinates for multiple plot segments. The lengths of the specified arrays x1 and x2 must be equal.

Parameters:
x1 - array of arrays of x1 coordinates.
x2 - array of arrays of x2 coordinates.

set

public void set(float[][] x1,
                float[][] x2,
                float[][] x3)
Sets array of arrays of (x1,x2,x3) coordinates for multiple plot segments. The lengths of the specified arrays x1 and x2 must be equal. If x3 is not null, its length must equal that of x1 and x2.

Parameters:
x1 - array of arrays of x1 coordinates.
x2 - array of arrays of x2 coordinates.
x3 - array of arrays of x3 coordinates; null, if none.

setOrientation

public void setOrientation(PointsView.Orientation orientation)
Sets the orientation of (x1,x2) axes.

Parameters:
orientation - the orientation.

getOrientation

public PointsView.Orientation getOrientation()
Gets the orientation of (x1,x2) axes.

Returns:
the orientation.

setStyle

public void setStyle(java.lang.String style)
Sets the color, line style, and mark style from a style string. This method provides a convenient way to set the most commonly specified attributes of lines and marks painted by this view.

To specify a color, the style string may contain one of "r" for red, "g" for green, "b" for blue, "c" for cyan, "m" for magenta, "y" for yellow, "k" for black, or "w" for white. If the style string contains none of these colors, then the default color is used.

To specify a line style, the style string may contain one of "-" for solid lines, "--" for dashed lines, "-." for dotted lines, or "--." for dash-dotted lines. If the style string contains none of these line styles, then no lines are painted.

To specify a mark style, the style string may contain one of "." for point, "+" for plus, "x" for cross, "o" for hollow circle", "O" for filled circle, "s" for hollow square, or "S" for filled square. If the style string contains none of these mark styles, then no marks are painted.

Parameters:
style - the style string.

setLineStyle

public void setLineStyle(PointsView.Line style)
Sets the line style. The default style is solid.

Parameters:
style - the line style.

setLineWidth

public void setLineWidth(float width)
Sets the line width. The default width is zero, for the thinnest lines.

Parameters:
width - the line width.

setLineColor

public void setLineColor(java.awt.Color color)
Sets the line color. The default line color is the tile foreground color. That default is used if the specified line color is null.

Parameters:
color - the line color; null, for tile foreground color.

setMarkStyle

public void setMarkStyle(PointsView.Mark style)
Sets the mark style. The default mark style is none, for no marks.

Parameters:
style - the mark style.

setMarkSize

public void setMarkSize(float size)
Sets the mark size. The default mark size is half the tile font size. The default is used if the specified mark size is zero.

Parameters:
size - the mark size.

setMarkColor

public void setMarkColor(java.awt.Color color)
Sets the mark color. The default mark color is the tile foreground color. That default is used if the specified mark color is null.

Parameters:
color - the mark color.

setTextFormat

public void setTextFormat(java.lang.String format)
Sets the format used for text labels. The default format is "%1.4G".

Parameters:
format - the text format.

paint

public void paint(java.awt.Graphics2D g2d)
Description copied from class: TiledView
Paints this tiled view. This method is implemented by classes that extend this abstract base class. Implementations may modify the specified graphics context freely. Such modifications will not affect the paintings of other tiled views in the same tile or mosaic.

Tiled views should not replace (set) entirely the transform in the specified graphics context. This transform may already have been set by the tile or its mosaic. Therefore, tiled views should modify this transform only by specifying additional scaling, translation, etc.

Specified by:
paint in class TiledView
Parameters:
g2d - the graphics context in which to paint.