edu.mines.jtk.mosaic
Class ContoursView

java.lang.Object
  extended by edu.mines.jtk.mosaic.TiledView
      extended by edu.mines.jtk.mosaic.ContoursView
All Implemented Interfaces:
ColorMapped

public class ContoursView
extends TiledView
implements ColorMapped

A view of a sampled function f(x1,x2), displayed with contour lines.

Version:
2009.07.06
Author:
Dave Hale and Chris Engelsma, Colorado School of Mines

Nested Class Summary
static class ContoursView.Line
           
static class ContoursView.Orientation
          Orientation of sample axes x1 and x2.
 
Constructor Summary
ContoursView(float[][] f)
          Constructs a contours view of the specified sampled function f(x1,x2).
ContoursView(Sampling s1, Sampling s2, float[][] f)
          Constructs a contours view of the specified sampled function f(x1,x2).
 
Method Summary
 void addColorMapListener(ColorMapListener cml)
          Adds the specified color map listener.
 float getClipMax()
          Gets the maximum clip value.
 float getClipMin()
          Gets the minimum clip value.
 ColorMap getColorMap()
          Gets the color map.
 float[] getContours()
          Gets the contour values.
 ContoursView.Orientation getOrientation()
          Gets the orientation of sample axes.
 float getPercentileMax()
          Gets the maximum percentile.
 float getPercentileMin()
          Gets the minimum percentile.
 void paint(java.awt.Graphics2D g2d)
          Paints this tiled view.
 void removeColorMapListener(ColorMapListener cml)
          Removes the specified color map listener.
 void set(float[][] f)
          Sets the sampled function f(x1,x2) for this view.
 void set(Sampling s1, Sampling s2, float[][] f)
          Sets the sampled function f(x1,x2) for this view.
 void setClips(float clipMin, float clipMax)
          Sets the clips for this view.
 void setColorModel(java.awt.image.IndexColorModel colorModel)
          Sets the color model used to map contour values to colors.
 void setContours(float[] c)
          Sets the contour values to those in the specified array.
 void setContours(int n)
          Sets the number of contour values.
 void setContours(Sampling cs)
          Sets the contour values to the specified sampling.
 void setLineColor(java.awt.Color color)
          Sets the color of each contour line to the specified color.
 void setLineStyle(ContoursView.Line style)
          Sets the contour line style.
 void setLineStyleNegative(ContoursView.Line style)
          Sets the contour line style for negative-valued contours.
 void setLineWidth(float width)
          Sets the contour line width.
 void setOrientation(ContoursView.Orientation orientation)
          Sets the orientation of sample axes.
 void setPercentiles(float percMin, float percMax)
          Sets the percentiles used to compute clips for this view.
 void setReadableContours(boolean readableContours)
          Enables or disables automatically computed readable contour values.
 
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

ContoursView

public ContoursView(float[][] f)
Constructs a contours view of the specified sampled function f(x1,x2). Assumes zero first sample values and unit sampling intervals.

Parameters:
f - array[n2][n1] of sampled function values f(x1,x2), where n1 = f[0].length and n2 = f.length.

ContoursView

public ContoursView(Sampling s1,
                    Sampling s2,
                    float[][] f)
Constructs a contours view of the specified sampled function f(x1,x2).

Parameters:
s1 - the sampling of the variable x1; must be uniform.
s2 - the sampling of the variable x2; must be uniform.
f - array[n2][n1] of sampled function values f(x1,x2), where n1 and n2 denote the number of samples in s1 and s2, respectively.
Method Detail

set

public void set(float[][] f)
Sets the sampled function f(x1,x2) for this view. Assumes zero first sample values and unit sampling intervals.

Parameters:
f - array[n2][n1] of sampled function values f(x1,x2), where n1 = f[0].length and n2 = f.length.

set

public void set(Sampling s1,
                Sampling s2,
                float[][] f)
Sets the sampled function f(x1,x2) for this view.

Parameters:
s1 - the sampling of the variable x1; must be uniform.
s2 - the sampling of the variable x2; must be uniform.
f - array[n2][n1] of sampled function values f(x1,x2), where n1 and n2 denote the number of samples in s1 and s2, respectively.

setOrientation

public void setOrientation(ContoursView.Orientation orientation)
Sets the orientation of sample axes.

Parameters:
orientation - the orientation.

getOrientation

public ContoursView.Orientation getOrientation()
Gets the orientation of sample axes.

Returns:
the orientation.

setLineStyle

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

Parameters:
style - the line style.

setLineStyleNegative

public void setLineStyleNegative(ContoursView.Line style)
Sets the contour line style for negative-valued contours. By default, all contours share the same line style.

Parameters:
style - the line style.

setLineWidth

public void setLineWidth(float width)
Sets the contour 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 color of each contour line to the specified color.

Parameters:
color - the contour line color.

setColorModel

public void setColorModel(java.awt.image.IndexColorModel colorModel)
Sets the color model used to map contour values to colors. If set, then byte 0 of the color model corresponds to the minimum clip value, and byte 255 corresponds to the maximum clip value. If not set, then all contour lines have the same color.

Parameters:
colorModel - the color model.

getColorMap

public ColorMap getColorMap()
Description copied from interface: ColorMapped
Gets the color map.

Specified by:
getColorMap in interface ColorMapped
Returns:
the color map.

setReadableContours

public void setReadableContours(boolean readableContours)
Enables or disables automatically computed readable contour values. Here, readable values are multiples of 1, 2, and 5 times some power of ten. If enabled, then any specified number of contours serves as an upper bound on the number of contour values. Readable contour values are the default.

Parameters:
readableContours - true, for readable contours; false, otherwise.

setContours

public void setContours(int n)
Sets the number of contour values. If readable contours are enabled, then this number is an upper bound, and the actual number of contours may be less than this number. Otherwise, if readable contours are disabled, then contour values will be evenly spaced between, but not including, the minimum and maximum clip values. The default number of contour values is 25.

Parameters:
n - the number of contour values.

setContours

public void setContours(float[] c)
Sets the contour values to those in the specified array. If this method is called, then clips (or percentiles) are not used to determine contour values, and readable contours are disabled.

Parameters:
c - the array of contour values.

setContours

public void setContours(Sampling cs)
Sets the contour values to the specified sampling. If this method is called, then clips (or percentiles) are not used to determine contour values, and readable contours are disabled.

Parameters:
cs - the contour sampling.

getContours

public float[] getContours()
Gets the contour values.

Returns:
array of contour values.

setClips

public void setClips(float clipMin,
                     float clipMax)
Sets the clips for this view. These values limit the range used to determine contour values. Function values f(x1,x2) less than clipMin and greater than clipMax are ignored.

Calling this method disables the computation of clips from percentiles. Previous clip values will be forgotten.

Parameters:
clipMin - the lower bound on contour values.
clipMax - the upper bound on contour values.

getClipMin

public float getClipMin()
Gets the minimum clip value.

Returns:
the minimum clip value.

getClipMax

public float getClipMax()
Gets the maximum clip value.

Returns:
the maximum clip value.

setPercentiles

public void setPercentiles(float percMin,
                           float percMax)
Sets the percentiles used to compute clips for this view. The default percentiles are 0 and 100, which correspond to the minimum and maximum values of the sampled function f(x1,x2).

Calling this method enables the computation of clips from percentiles. Any clip values specified or computed previously will be forgotten.

Parameters:
percMin - the percentile corresponding to clipMin.
percMax - the percentile corresponding to clipMax.

getPercentileMin

public float getPercentileMin()
Gets the minimum percentile.

Returns:
the minimum percentile.

getPercentileMax

public float getPercentileMax()
Gets the maximum percentile.

Returns:
the maximum percentile.

addColorMapListener

public void addColorMapListener(ColorMapListener cml)
Adds the specified color map listener.

Parameters:
cml - the listener.

removeColorMapListener

public void removeColorMapListener(ColorMapListener cml)
Removes the specified color map listener.

Parameters:
cml - the listener.

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.