Package org.opensourcephysics.display2d
Class InterpolatedPlot
java.lang.Object
org.opensourcephysics.display.MeasuredImage
org.opensourcephysics.display2d.InterpolatedPlot
- All Implemented Interfaces:
Drawable,Measurable,Plot2D
- Direct Known Subclasses:
Carpet
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
FieldsFields inherited from class org.opensourcephysics.display.MeasuredImage
image, minmax, visible, xmax, xmin, ymax, yminFields inherited from interface org.opensourcephysics.display2d.Plot2D
CONTOUR_PLOT, GRID_PLOT, INTERPOLATED_PLOT, SURFACE_PLOT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an InterpolatedPlot without data.InterpolatedPlot(GridData _griddata) Constructs the InterpolatedPlot using the given data storage. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckImage(DrawingPanel panel) Checks if the image is the correct size.voiddraw(DrawingPanel panel, Graphics g) Draws the image and the grid.doubleGets the ceiling for scaling the z data.doublegetFloor()Gets the floor for scaling the z data.Gets the GridData object.static XML.ObjectLoaderGets an XML.ObjectLoader to save and load data for this program.doubleindexToX(int i) Gets the x coordinate for the given index.doubleindexToY(int i) Gets the y coordinate for the given index.booleanGets the autoscale flag for z.booleanDetermines if information is available to set min/max values.booleanGets the symmetric z flag.protected voidRecolors the image pixels using the data array.voidSets the data to new values.voidSets the values and the scale.voidsetAutoscaleZ(boolean isAutoscale, double floor, double ceil) Sets the autoscale flag and the floor and ceiling values for the colors.voidsetColorPalette(Color[] colors) Sets the colors that will be used between the floor and ceiling values.voidsetExpandedZ(boolean expanded, double expansionFactor) Expands the z scale so as to enhance values close to zero.voidsetFloorCeilColor(Color floorColor, Color ceilColor) Sets the floor and ceiling colors.voidsetGridData(GridData _griddata) Sets the data to the given griddata.voidSets the color for grid line boundariesvoidsetIndexes(int[] indexes) Sets the indexes for the data component that will be plotted.voidsetPaletteType(int type) Determines the palette type that will be used.voidsetShowGridLines(boolean showGrid) Sets the show grid option.voidsetSymmetricZ(boolean symmetric) Forces the z-scale to be symmetric about zero.Shows how values map to colors.voidupdate()Updates the buffered image using the data array.protected voidwriteToRaster(double x0, double y, double dx, double dy) intxToIndex(double x) Gets closest index from the given x world coordinate.intyToIndex(double y) Gets closest index from the given y world coordinate.Methods inherited from class org.opensourcephysics.display.MeasuredImage
getImage, getXMax, getXMin, getYMax, getYMin, setImage, setMinMax, setVisible, setXMax, setXMin, setYMax, setYMinMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opensourcephysics.display.Drawable
isInteractiveMethods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMinMethods inherited from interface org.opensourcephysics.display2d.Plot2D
setVisible
-
Field Details
-
imageType
protected int imageType -
pixelData
protected byte[] pixelData
-
-
Constructor Details
-
InterpolatedPlot
public InterpolatedPlot()Constructs an InterpolatedPlot without data. -
InterpolatedPlot
Constructs the InterpolatedPlot using the given data storage.- Parameters:
_griddata-
-
-
Method Details
-
getGridData
Gets the GridData object.- Specified by:
getGridDatain interfacePlot2D- Returns:
- GridData
-
indexToX
public double indexToX(int i) Gets the x coordinate for the given index. -
indexToY
public double indexToY(int i) Gets the y coordinate for the given index. -
xToIndex
public int xToIndex(double x) Gets closest index from the given x world coordinate. -
yToIndex
public int yToIndex(double y) Gets closest index from the given y world coordinate. -
setAll
Sets the data to new values. The grid is resized to fit the new data if needed. -
setAll
Sets the values and the scale. The grid is resized to fit the new data if needed. -
setGridData
Sets the data to the given griddata.- Specified by:
setGridDatain interfacePlot2D- 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:
setAutoscaleZin interfacePlot2D- Parameters:
isAutoscale-floor-ceil-
-
setSymmetricZ
public void setSymmetricZ(boolean symmetric) Forces the z-scale to be symmetric about zero. Forces zmax to be positive and zmin=-zmax when in autoscale mode.- Specified by:
setSymmetricZin interfacePlot2D- Parameters:
symmetric-
-
isSymmetricZ
public boolean isSymmetricZ()Gets the symmetric z flag.- Specified by:
isSymmetricZin interfacePlot2D
-
isAutoscaleZ
public boolean isAutoscaleZ()Gets the autoscale flag for z.- Specified by:
isAutoscaleZin interfacePlot2D- Returns:
- boolean
-
getFloor
public double getFloor()Gets the floor for scaling the z data. -
getCeiling
public double getCeiling()Gets the ceiling for scaling the z data.- Specified by:
getCeilingin interfacePlot2D- Returns:
- double
-
setShowGridLines
public void setShowGridLines(boolean showGrid) Sets the show grid option.- Specified by:
setShowGridLinesin interfacePlot2D- Parameters:
showGrid-
-
setGridLineColor
Sets the color for grid line boundaries- Specified by:
setGridLineColorin interfacePlot2D- Parameters:
c-
-
setIndexes
public void setIndexes(int[] indexes) Sets the indexes for the data component that will be plotted.- Specified by:
setIndexesin interfacePlot2D- Parameters:
indexes- the sample-component
-
setPaletteType
public void setPaletteType(int type) Determines the palette type that will be used.- Specified by:
setPaletteTypein interfacePlot2D- Parameters:
type-
-
setColorPalette
Sets the colors that will be used between the floor and ceiling values.- Specified by:
setColorPalettein interfacePlot2D- Parameters:
colors-
-
setFloorCeilColor
Sets the floor and ceiling colors.- Specified by:
setFloorCeilColorin interfacePlot2D- 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:
setExpandedZin interfacePlot2D- Parameters:
expanded- booleanexpansionFactor- double
-
update
public void update()Updates the buffered image using the data array. -
checkImage
Checks if the image is the correct size. -
recolorImage
protected void recolorImage()Recolors the image pixels using the data array. -
writeToRaster
protected void writeToRaster(double x0, double y, double dx, double dy) -
showLegend
Shows how values map to colors.- Specified by:
showLegendin interfacePlot2D
-
isMeasured
public boolean isMeasured()Description copied from interface:MeasurableDetermines if information is available to set min/max values. Objects that store data should return false if data is null.- Specified by:
isMeasuredin interfaceMeasurable- Overrides:
isMeasuredin classMeasuredImage- Returns:
- true if min/max values are valid
-
draw
Draws the image and the grid.- Specified by:
drawin interfaceDrawable- Overrides:
drawin classMeasuredImage- Parameters:
panel-g-
-
getLoader
Gets an XML.ObjectLoader to save and load data for this program.- Returns:
- the object loader
-