Package org.opensourcephysics.display2d
Interface Plot2D
- All Superinterfaces:
Drawable,Measurable
- All Known Implementing Classes:
Carpet,ComplexCarpet,ComplexContourPlot,ComplexGridPlot,ComplexInterpolatedPlot,ComplexSurfacePlot,ContourPlot,GrayscalePlot,GridPlot,InterpolatedPlot,SurfacePlot,VectorPlot
The Plot2D interface defines common methods for 2d-plotting such as a GridPlot,
a VectorPlot, or a ContourPlot.
Data must be stored in a GridData object.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the ceiling for scaling the z data.doublegetFloor()Gets the floor for scaling the z data.Gets the GridData 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.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 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 storage to the given value.voidSets the color for grid line boundariesvoidsetIndexes(int[] indexes) Sets the indexes for the data components that will be plotted.voidsetPaletteType(int type) Determines the palette type that will be used.voidsetShowGridLines(boolean showGrid) Outlines the data grid's boundaries.voidsetSymmetricZ(boolean symmetric) Forces the z-scale to be symmetric about zero.voidsetVisible(boolean isVisible) Sets the visibility of the plot.Shows how values map to colors.voidupdate()Updates this object's state using new data values.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 interface org.opensourcephysics.display.Drawable
draw, isInteractiveMethods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin, isMeasured
-
Field Details
-
GRID_PLOT
static final int GRID_PLOT- See Also:
-
INTERPOLATED_PLOT
static final int INTERPOLATED_PLOT- See Also:
-
CONTOUR_PLOT
static final int CONTOUR_PLOT- See Also:
-
SURFACE_PLOT
static final int SURFACE_PLOT- See Also:
-
-
Method Details
-
setAll
Sets the data to new values. The grid is resized to fit the new data if needed.- Parameters:
val- an array of new values
-
setAll
Sets the values and the scale. The grid is resized to fit the new data if needed.- Parameters:
obj- array of new valuesxmin- doublexmax- doubleymin- doubleymax- double
-
setGridData
Sets the data storage to the given value.- Parameters:
_griddata-
-
getGridData
GridData getGridData()Gets the GridData object.- Returns:
- GridData
-
indexToX
double indexToX(int i) Gets the x coordinate for the given index.- Parameters:
i- int- Returns:
- double the x coordinate
-
indexToY
double indexToY(int i) Gets the y coordinate for the given index.- Parameters:
i- int- Returns:
- double the y coordinate
-
xToIndex
int xToIndex(double x) Gets closest index from the given x world coordinate.- Parameters:
x- double the coordinate- Returns:
- int the index
-
yToIndex
int yToIndex(double y) Gets closest index from the given y world coordinate.- Parameters:
y- double the coordinate- Returns:
- int the index
-
isAutoscaleZ
boolean isAutoscaleZ()Gets the autoscale flag for z.- Returns:
- boolean
-
getFloor
double getFloor()Gets the floor for scaling the z data.- Returns:
- double
-
getCeiling
double getCeiling()Gets the ceiling for scaling the z data.- Returns:
- double
-
setAutoscaleZ
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.- Parameters:
isAutoscale-floor-ceil-
-
setSymmetricZ
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.- Parameters:
symmetric-
-
isSymmetricZ
boolean isSymmetricZ()Gets the symmetric z flag. -
setFloorCeilColor
Sets the floor and ceiling colors.- Parameters:
floorColor-ceilColor-
-
setColorPalette
Sets the colors that will be used between the floor and ceiling values.- Parameters:
colors-
-
setPaletteType
void setPaletteType(int type) Determines the palette type that will be used.- Parameters:
type-
-
setGridLineColor
Sets the color for grid line boundaries- Parameters:
c-
-
setShowGridLines
void setShowGridLines(boolean showGrid) Outlines the data grid's boundaries.- Parameters:
showGrid-
-
showLegend
JFrame showLegend()Shows how values map to colors. -
setVisible
void setVisible(boolean isVisible) Sets the visibility of the plot. Drawing will be disabled if visible is false.- Parameters:
isVisible-
-
setIndexes
void setIndexes(int[] indexes) Sets the indexes for the data components that will be plotted. Indexes determine the postion of the amplitude, phase, x-component, and y-component data in the data array. The amplitude index is usually the first index.- Parameters:
indexes- the sample-component indexes
-
update
void update()Updates this object's state using new data values. Update should be invoked if the data in the PointData object changes or if the z scale of the PointData object changes. -
setExpandedZ
void setExpandedZ(boolean expanded, double expansionFactor) Expands the z scale so as to enhance values close to zero.- Parameters:
expanded- booleanexpansionFactor- double
-