Package org.opensourcephysics.display2d
Class ContourPlot
java.lang.Object
org.opensourcephysics.display2d.ContourPlot
- All Implemented Interfaces:
Drawable,Measurable,Plot2D
ContourPlot draws a contour plot of a scalar field.
Contour uses code from the Surface Plotter package by Yanto Suryono.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Field Summary
FieldsFields inherited from interface org.opensourcephysics.display2d.Plot2D
CONTOUR_PLOT, GRID_PLOT, INTERPOLATED_PLOT, SURFACE_PLOT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a ContourPlot without any data.ContourPlot(GridData _griddata) Constructs a ContourPlot that renders the given GridData. -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(DrawingPanel panel, Graphics g) Paint the contour.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.doublegetXMax()Gets the maximum x needed to draw this object.doublegetXMin()Gets the minimum x needed to draw this object.doublegetYMax()Gets the maximum y needed to draw this object.doublegetYMin()Gets the minimum y needed to draw this object.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.booleanRetruns true if plot interpolates a large grid onto a smaller grid to speed the computation of contour lines.booleanDetermines if information is available to set min/max values.booleanGets the symmetric z flag.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.voidsetColorPalette(Color[] colors) Determines the palette type that will be used.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, ceiling, and line colors.voidsetGridData(GridData _griddata) Sets the data storage to the given value.voidsetGridLineColor(Color color) Sets the contour line color.voidsetIndexes(int[] indexes) Sets the indexes for the data components that will be plotted.voidsetInterpolateLargeGrids(boolean interpolate) Sets flag to interpolates a large grid onto a smaller grid to speed the computation of contour lines.voidsetNumberOfLevels(int n) Sets the number of contour levels.voidsetPaletteType(int mode) Sets the type of palette.voidsetShowColorLevels(boolean show) voidsetShowGridLines(boolean showLines) Shows the contour lines.voidsetSymmetricZ(boolean symmetric) Forces the z-scale to be symmetric about zero.voidsetVisible(boolean isVisible) Sets the visibility of the contour plot.Shows how values map to colors.voidupdate()Updates the contour data.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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
zMap
-
colorMap
-
interpolateLargeGrids
protected boolean interpolateLargeGrids
-
-
Constructor Details
-
ContourPlot
public ContourPlot()Constructs a ContourPlot without any data. -
ContourPlot
Constructs a ContourPlot that renders the given GridData.- Parameters:
_griddata- data storage
-
-
Method Details
-
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. -
getGridData
Gets the GridData object.- Specified by:
getGridDatain interfacePlot2D- Returns:
- GridData
-
setGridData
Sets the data storage to the given value.- Specified by:
setGridDatain interfacePlot2D- Parameters:
_griddata-
-
setVisible
public void setVisible(boolean isVisible) Sets the visibility of the contour plot. Drawing will be disabled if visible is false.- Specified by:
setVisiblein interfacePlot2D- Parameters:
isVisible-
-
showLegend
Shows how values map to colors.- Specified by:
showLegendin interfacePlot2D
-
setShowGridLines
public void setShowGridLines(boolean showLines) Shows the contour lines.- Specified by:
setShowGridLinesin interfacePlot2D- Parameters:
showLines-
-
setGridLineColor
Sets the contour line color. The default line color is dark green.- Specified by:
setGridLineColorin interfacePlot2D- Parameters:
color-
-
setShowColorLevels
public void setShowColorLevels(boolean show) -
draw
Paint the contour. -
setAutoscaleZ
public void setAutoscaleZ(boolean isAutoscale, double floor, double ceil) Sets the autoscale flag and the floor and ceiling values. If autoscaling is true, then the min and max values of z are set using the data. If autoscaling is false, then floor and ceiling values become the max and min. 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
-
setInterpolateLargeGrids
public void setInterpolateLargeGrids(boolean interpolate) Sets flag to interpolates a large grid onto a smaller grid to speed the computation of contour lines.- Parameters:
interpolate- boolean
-
isInterpolateLargeGrids
public boolean isInterpolateLargeGrids()Retruns true if plot interpolates a large grid onto a smaller grid to speed the computation of contour lines.- Returns:
- boolean
-
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
-
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
-
update
public void update()Updates the contour data. -
setColorPalette
Determines the palette type that will be used.- Specified by:
setColorPalettein interfacePlot2D- Parameters:
colors- Color[]
-
setPaletteType
public void setPaletteType(int mode) Sets the type of palette. Palette types are defined in the ColorMapper class and include: SPECTRUM, GRAYSCALE, and DUALSHADE.- Specified by:
setPaletteTypein interfacePlot2D- Parameters:
mode-
-
setFloorCeilColor
Sets the floor, ceiling, and line colors.- Specified by:
setFloorCeilColorin interfacePlot2D- Parameters:
floorColor-ceilColor-
-
setIndexes
public void setIndexes(int[] indexes) Sets the indexes for the data components that will be plotted.- Specified by:
setIndexesin interfacePlot2D- Parameters:
indexes- the sample-component indexes
-
setNumberOfLevels
public void setNumberOfLevels(int n) Sets the number of contour levels.- Parameters:
n- number of levels.
-
getXMin
public double getXMin()Description copied from interface:MeasurableGets the minimum x needed to draw this object.- Specified by:
getXMinin interfaceMeasurable- Returns:
- minimum
-
getXMax
public double getXMax()Description copied from interface:MeasurableGets the maximum x needed to draw this object.- Specified by:
getXMaxin interfaceMeasurable- Returns:
- maximum
-
getYMin
public double getYMin()Description copied from interface:MeasurableGets the minimum y needed to draw this object.- Specified by:
getYMinin interfaceMeasurable- Returns:
- minimum
-
getYMax
public double getYMax()Description copied from interface:MeasurableGets the maximum y needed to draw this object.- Specified by:
getYMaxin interfaceMeasurable- Returns:
- minimum
-
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- Returns:
- true if min/max values are valid
-
getLoader
Gets an XML.ObjectLoader to save and load data for this program.- Returns:
- the object loader
-