org.opensourcephysics.display2d
Class InterpolatedPlot

java.lang.Object
  extended by org.opensourcephysics.display.MeasuredImage
      extended by org.opensourcephysics.display2d.InterpolatedPlot
All Implemented Interfaces:
Drawable, Measurable, Plot2D
Direct Known Subclasses:
Carpet

public class InterpolatedPlot
extends MeasuredImage
implements Plot2D

InterpolatedPlot creates an image of a scalar field by interpolating every image pixel to an untabulated point (x,y) in the 2d data. This interpolation smooths the resulting image.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
 
Fields inherited from class org.opensourcephysics.display.MeasuredImage
image, visible, xmax, xmin, ymax, ymin
 
Fields inherited from interface org.opensourcephysics.display2d.Plot2D
CONTOUR_PLOT, GRID_PLOT, INTERPOLATED_PLOT, SURFACE_PLOT
 
Constructor Summary
InterpolatedPlot()
          Constructs an InterpolatedPlot without data.
InterpolatedPlot(GridData _griddata)
          Constructs the InterpolatedPlot using the given data storage.
 
Method Summary
protected  void checkImage(DrawingPanel panel)
          Checks if the image is the correct size.
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws the image and the grid.
 double getCeiling()
          Gets the ceiling for scaling the z data.
 double getFloor()
          Gets the floor for scaling the z data.
 GridData getGridData()
          Gets the GridData object.
static XML.ObjectLoader getLoader()
          Gets an XML.ObjectLoader to save and load data for this program.
 byte[][] getRGBData()
          Gets the byte array of rgb colors
 double indexToX(int i)
          Gets the x coordinate for the given index.
 double indexToY(int i)
          Gets the y coordinate for the given index.
 boolean isAutoscaleZ()
          Gets the autoscale flag for z.
 boolean isMeasured()
          Determines if information is available to set min/max values.
protected  void recolorImage()
          Recolors the image pixels using the data array.
 void setAll(java.lang.Object obj)
          Sets the data to new values.
 void setAll(java.lang.Object obj, double xmin, double xmax, double ymin, double ymax)
          Sets the values and the scale.
 void setAutoscaleZ(boolean isAutoscale, double floor, double ceil)
          Sets the autoscale flag and the floor and ceiling values for the colors.
 void setColorPalette(java.awt.Color[] colors)
          Sets the colors that will be used between the floor and ceiling values.
 void setExpandedZ(boolean expanded, double expansionFactor)
          Expands the z scale so as to enhance values close to zero.
 void setFloorCeilColor(java.awt.Color floorColor, java.awt.Color ceilColor)
          Sets the floor and ceiling colors.
 void setGridData(GridData _griddata)
          Sets the data to the given griddata.
 void setGridLineColor(java.awt.Color c)
          Sets the color for grid line boundaries
 void setIndexes(int[] indexes)
          Sets the indexes for the data component that will be plotted.
 void setPaletteType(int type)
          Determines the palette type that will be used.
 void setShowGridLines(boolean showGrid)
          Sets the show grid option.
 javax.swing.JFrame showLegend()
          Shows how values map to colors.
 void update()
          Updates the buffered image using the data array.
 int xToIndex(double x)
          Gets closest index from the given x world coordinate.
 int yToIndex(double y)
          Gets closest index from the given y world coordinate.
 
Methods inherited from class org.opensourcephysics.display.MeasuredImage
getXMax, getXMin, getYMax, getYMin, setImage, setMinMax, setVisible, setXMax, setXMin, setYMax, setYMin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensourcephysics.display2d.Plot2D
setVisible
 
Methods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin
 

Constructor Detail

InterpolatedPlot

public InterpolatedPlot()
Constructs an InterpolatedPlot without data.


InterpolatedPlot

public InterpolatedPlot(GridData _griddata)
Constructs the InterpolatedPlot using the given data storage.

Parameters:
_griddata -
Method Detail

getRGBData

public byte[][] getRGBData()
Gets the byte array of rgb colors

Returns:
byte[][]

getGridData

public GridData getGridData()
Gets the GridData object.

Specified by:
getGridData in interface Plot2D
Returns:
GridData

indexToX

public double indexToX(int i)
Gets the x coordinate for the given index.

Specified by:
indexToX in interface Plot2D
Parameters:
i - int
Returns:
double the x coordinate

indexToY

public double indexToY(int i)
Gets the y coordinate for the given index.

Specified by:
indexToY in interface Plot2D
Parameters:
i - int
Returns:
double the y coordinate

xToIndex

public int xToIndex(double x)
Gets closest index from the given x world coordinate.

Specified by:
xToIndex in interface Plot2D
Parameters:
x - double the coordinate
Returns:
int the index

yToIndex

public int yToIndex(double y)
Gets closest index from the given y world coordinate.

Specified by:
yToIndex in interface Plot2D
Parameters:
y - double the coordinate
Returns:
int the index

setAll

public void setAll(java.lang.Object obj)
Sets the data to new values. The grid is resized to fit the new data if needed.

Specified by:
setAll in interface Plot2D
Parameters:
obj -

setAll

public void setAll(java.lang.Object obj,
                   double xmin,
                   double xmax,
                   double ymin,
                   double ymax)
Sets the values and the scale. The grid is resized to fit the new data if needed.

Specified by:
setAll in interface Plot2D
Parameters:
obj - array of new values
xmin - double
xmax - double
ymin - double
ymax - double

setGridData

public void setGridData(GridData _griddata)
Sets the data to the given griddata.

Specified by:
setGridData in interface Plot2D
Parameters:
_griddata -

setAutoscaleZ

public void setAutoscaleZ(boolean isAutoscale,
                          double floor,
                          double ceil)
Sets the autoscale flag and the floor and ceiling values for the colors. If autoscaling is true, then the min and max values of z are span the colors. If autoscaling is false, then floor and ceiling values limit the colors. Values below min map to the first color; values above max map to the last color.

Specified by:
setAutoscaleZ in interface Plot2D
Parameters:
isAutoscale -
floor -
ceil -

isAutoscaleZ

public boolean isAutoscaleZ()
Gets the autoscale flag for z.

Specified by:
isAutoscaleZ in interface Plot2D
Returns:
boolean

getFloor

public double getFloor()
Gets the floor for scaling the z data.

Specified by:
getFloor in interface Plot2D
Returns:
double

getCeiling

public double getCeiling()
Gets the ceiling for scaling the z data.

Specified by:
getCeiling in interface Plot2D
Returns:
double

setShowGridLines

public void setShowGridLines(boolean showGrid)
Sets the show grid option.

Specified by:
setShowGridLines in interface Plot2D
Parameters:
showGrid -

setGridLineColor

public void setGridLineColor(java.awt.Color c)
Sets the color for grid line boundaries

Specified by:
setGridLineColor in interface Plot2D
Parameters:
c -

setIndexes

public void setIndexes(int[] indexes)
Sets the indexes for the data component that will be plotted.

Specified by:
setIndexes in interface Plot2D
Parameters:
indexes - the sample-component

setPaletteType

public void setPaletteType(int type)
Determines the palette type that will be used.

Specified by:
setPaletteType in interface Plot2D
Parameters:
type -

setColorPalette

public void setColorPalette(java.awt.Color[] colors)
Sets the colors that will be used between the floor and ceiling values.

Specified by:
setColorPalette in interface Plot2D
Parameters:
colors -

setFloorCeilColor

public void setFloorCeilColor(java.awt.Color floorColor,
                              java.awt.Color ceilColor)
Sets the floor and ceiling colors.

Specified by:
setFloorCeilColor in interface Plot2D
Parameters:
floorColor -
ceilColor -

setExpandedZ

public void setExpandedZ(boolean expanded,
                         double expansionFactor)
Expands the z scale so as to enhance values close to zero.

Specified by:
setExpandedZ in interface Plot2D
Parameters:
expanded - boolean
expansionFactor - double

update

public void update()
Updates the buffered image using the data array.

Specified by:
update in interface Plot2D

checkImage

protected void checkImage(DrawingPanel panel)
Checks if the image is the correct size.


recolorImage

protected void recolorImage()
Recolors the image pixels using the data array.


showLegend

public javax.swing.JFrame showLegend()
Shows how values map to colors.

Specified by:
showLegend in interface Plot2D

isMeasured

public boolean isMeasured()
Description copied from interface: Measurable
Determines if information is available to set min/max values. Objects that store data should return false if data is null.

Specified by:
isMeasured in interface Measurable
Overrides:
isMeasured in class MeasuredImage
Returns:
true if min/max values are valid

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Draws the image and the grid.

Specified by:
draw in interface Drawable
Overrides:
draw in class MeasuredImage
Parameters:
panel -
g -

getLoader

public static XML.ObjectLoader getLoader()
Gets an XML.ObjectLoader to save and load data for this program.

Returns:
the object loader