at.tuwien.ifs.somtoolbox.visualization.contourplot
Class ContourPlot

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.visualization.contourplot.ContourPlot

public class ContourPlot
extends Object

Computes and draws the contours.

Version:
$Id: ContourPlot.java 3883 2010-11-02 17:13:23Z frank $

Nested Class Summary
private static class ContourPlot.Profile
           
 
Field Summary
private  int cntrIndex
           
private  float[] cv
           
private  double cval
           
private  double deltaX
           
private  double deltaY
           
private  int elle
           
private static String EOL
           
private  boolean fill
           
private  int height
           
private  int[] i1
           
private  int[] i2
           
private  int[] i3
           
private  int ibkey
           
private  int icur
           
private  int idir
           
private  int iedge
           
private  int iflag
           
private  int ii
           
private  int[] ij
           
private  double[] intersect
           
private  int ix
           
private  int jcur
           
private  int jj
           
private  boolean jump
           
private  int k
           
private  int ks
           
private  int[] l1
           
private  int[] l2
           
private  boolean logInterpolation
           
private static int MIN_Y_STEPS
           
private  int ni
           
private  int numberOfContours
           
private  int nxidir
           
private  Color[] palette
           
private static int PLOT_MARGIN
           
private  int prevIndex
           
private  double[] prevXY
           
private  Stack<ContourPlot.Profile> profiles
           
private static long serialVersionUID
           
private static boolean SHOW_NUMBERS
           
private  int width
           
private  int xSteps
           
private  double[] xy
           
private  int ySteps
           
private  float[][] z
           
private static double Z_MAX_MAX
           
private static double Z_MIN_MIN
           
private  double z1
           
private  double z2
           
private  double zMax
           
private  double zMin
           
 
Constructor Summary
ContourPlot(int x, int y, int width, int height)
           
 
Method Summary
private  void AssignContourValues()
          interpolate between zMin and zMax, logarithmically or linearly, in order to assign contour values to the array cv
private  double ClipX(double x)
           
private  double ClipY(double y)
           
private  void ContinueContour()
          continues tracing a contour.
private  void ContourPlotKernel(Graphics g, boolean[] workSpace)
          corresponds to Synder's subroutine "GCONTR".
private  boolean CrossedByContour(boolean[] workSpace)
          true iff the current segment in the grid is crossed by one of the contour values and has not already been processed for that value.
private  void DetectBoundary()
           
private  void DrawKernel(Graphics g)
          the guts of drawing and is called directly or indirectly by ContourPlotKernel(Graphics, boolean[]) in order to draw a segment of a contour or to set the pen position "prevXY".
private  void DrawProfile(Graphics g, ContourPlot.Profile profile)
           
private  Color GetColour(int index)
           
private  void GetExtremes()
          scans the data in z in order to assign values to zMin and zMax
private  void InvalidData()
          sets the first two components of the contour value array to equal values, thus preventing subsequent drawing of the contour plot.
private  void MakeMatrixRectangular()
          appends zero(s) to the end of any row of "z" which is shorter than the longest row.
 void paint(Graphics g)
          draws the contours provided that the first two contour values are not equal (which would indicate invalid data)
private  boolean Routine_label_020()
          corresponds to a block of code starting at label 20 in Synder's subroutine "GCONTR".
private  boolean Routine_label_050()
          corresponds to a block of code starting at label 50 in Synder's subroutine "GCONTR".
private  boolean Routine_label_150()
          corresponds to a block of code starting at label 150 in Synder's subroutine "GCONTR".
private  short Routine_label_200(Graphics g, boolean[] workSpace)
          corresponds to a block of code starting at label 200 in Synder's subroutine "GCONTR".
private  void SetColour(Graphics g)
          sets the colour of the graphics object, given the contour index, by interpolating linearly between Color.BLUE & Color.red
 void setFill(boolean fill)
           
 void setLogInterpolation(boolean logInterpolation)
           
 void setNumberOfContours(int numberOfContours)
           
 void setPalette(Color[] palette)
           
 void setZedMatrix(cern.colt.matrix.DoubleMatrix2D zed)
           
private  int sign(int a, int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

MIN_Y_STEPS

private static final int MIN_Y_STEPS
See Also:
Constant Field Values

SHOW_NUMBERS

private static final boolean SHOW_NUMBERS
See Also:
Constant Field Values

PLOT_MARGIN

private static final int PLOT_MARGIN
See Also:
Constant Field Values

Z_MAX_MAX

private static final double Z_MAX_MAX
See Also:
Constant Field Values

Z_MIN_MIN

private static final double Z_MIN_MIN
See Also:
Constant Field Values

EOL

private static final String EOL

xSteps

private int xSteps

ySteps

private int ySteps

z

private float[][] z

logInterpolation

private boolean logInterpolation

width

private int width

height

private int height

deltaX

private double deltaX

deltaY

private double deltaY

numberOfContours

private int numberOfContours

l1

private int[] l1

l2

private int[] l2

ij

private int[] ij

i1

private int[] i1

i2

private int[] i2

i3

private int[] i3

ibkey

private int ibkey

icur

private int icur

jcur

private int jcur

ii

private int ii

jj

private int jj

elle

private int elle

ix

private int ix

iedge

private int iedge

iflag

private int iflag

ni

private int ni

ks

private int ks

cntrIndex

private int cntrIndex

prevIndex

private int prevIndex

idir

private int idir

nxidir

private int nxidir

k

private int k

z1

private double z1

z2

private double z2

cval

private double cval

zMax

private double zMax

zMin

private double zMin

intersect

private double[] intersect

xy

private double[] xy

prevXY

private double[] prevXY

cv

private float[] cv

jump

private boolean jump

palette

private Color[] palette

fill

private boolean fill

profiles

private Stack<ContourPlot.Profile> profiles
Constructor Detail

ContourPlot

public ContourPlot(int x,
                   int y,
                   int width,
                   int height)
Method Detail

sign

private int sign(int a,
                 int b)

InvalidData

private void InvalidData()
sets the first two components of the contour value array to equal values, thus preventing subsequent drawing of the contour plot.


GetExtremes

private void GetExtremes()
                  throws SOMToolboxException
scans the data in z in order to assign values to zMin and zMax

Throws:
SOMToolboxException

AssignContourValues

private void AssignContourValues()
                          throws SOMToolboxException
interpolate between zMin and zMax, logarithmically or linearly, in order to assign contour values to the array cv

Throws:
SOMToolboxException

SetColour

private void SetColour(Graphics g)
sets the colour of the graphics object, given the contour index, by interpolating linearly between Color.BLUE & Color.red


GetColour

private Color GetColour(int index)

ClipX

private double ClipX(double x)

ClipY

private double ClipY(double y)

DrawProfile

private void DrawProfile(Graphics g,
                         ContourPlot.Profile profile)

DrawKernel

private void DrawKernel(Graphics g)
the guts of drawing and is called directly or indirectly by ContourPlotKernel(Graphics, boolean[]) in order to draw a segment of a contour or to set the pen position "prevXY". Its action depends on "iflag": If the constant "SHOW_NUMBERS" is true then when completing a contour ("iflag" == 4 or 5) the contour index is drawn adjacent to where the contour ends.


DetectBoundary

private void DetectBoundary()

Routine_label_020

private boolean Routine_label_020()
corresponds to a block of code starting at label 20 in Synder's subroutine "GCONTR".


Routine_label_050

private boolean Routine_label_050()
corresponds to a block of code starting at label 50 in Synder's subroutine "GCONTR".


Routine_label_150

private boolean Routine_label_150()
corresponds to a block of code starting at label 150 in Synder's subroutine "GCONTR".


Routine_label_200

private short Routine_label_200(Graphics g,
                                boolean[] workSpace)
corresponds to a block of code starting at label 200 in Synder's subroutine "GCONTR". It has return values 0, 1 or 2.


CrossedByContour

private boolean CrossedByContour(boolean[] workSpace)
true iff the current segment in the grid is crossed by one of the contour values and has not already been processed for that value.


ContinueContour

private void ContinueContour()
continues tracing a contour. Edges are numbered clockwise, the bottom edge being # 1.


ContourPlotKernel

private void ContourPlotKernel(Graphics g,
                               boolean[] workSpace)
corresponds to Synder's subroutine "GCONTR".


paint

public void paint(Graphics g)
draws the contours provided that the first two contour values are not equal (which would indicate invalid data)


setFill

public void setFill(boolean fill)

setPalette

public void setPalette(Color[] palette)

setZedMatrix

public void setZedMatrix(cern.colt.matrix.DoubleMatrix2D zed)
                  throws SOMToolboxException
Throws:
SOMToolboxException

setNumberOfContours

public void setNumberOfContours(int numberOfContours)

setLogInterpolation

public void setLogInterpolation(boolean logInterpolation)

MakeMatrixRectangular

private void MakeMatrixRectangular()
appends zero(s) to the end of any row of "z" which is shorter than the longest row.