org.opensourcephysics.display2d
Class ComplexSurfacePlot

java.lang.Object
  extended byorg.opensourcephysics.display2d.ComplexSurfacePlot
All Implemented Interfaces:
Drawable, False3D, Measurable, Plot2D

public class ComplexSurfacePlot
extends java.lang.Object
implements Plot2D, False3D

SurfacePlot draws a 3D surface of a scalar field. Surfaceplot uses code from the Surface Plotter package by Yanto Suryono.


Field Summary
static int INIT_CALC_DIV
          Field INIT_CALC_DIV
static int INIT_DISP_DIV
          Field INIT_DISP_DIV
protected  java.text.DecimalFormat labelFormat
           
 
Constructor Summary
ComplexSurfacePlot()
          Constructs the ComplexSurfacePlot without data.
ComplexSurfacePlot(GridData _griddata)
          ComplexSurfacePlot constructor with the given data model.
 
Method Summary
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Paint the surface.
 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.
 double getXMax()
          Gets the maximum x needed to draw this object.
 double getXMin()
          Gets the minimum x needed to draw this object.
 double getYMax()
          Gets the maximum y needed to draw this object.
 double getYMin()
          Gets the minimum y needed to draw this object.
 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.
 void mouseDragged(java.awt.event.MouseEvent e, DrawingPanel drawingPanel)
          mouseDrag event handler.
 boolean mousePressed(java.awt.event.MouseEvent e, DrawingPanel drawingPanel)
          mouseDown event handler.
 void mouseReleased(java.awt.event.MouseEvent e, DrawingPanel drawingPanel)
          Method mouseReleased
 void set2DScaling(double scale)
          Sets the 2D scaling factor.
 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.
 void setColorPalette(java.awt.Color[] colors)
          Sets the colors that will be used between the floor and ceiling values.
 void setDistance(double distance)
          Sets the viewing distance.
 void setElevationAngle(double angle)
          Sets the viewing elevation angle.
 void setFloorCeilColor(java.awt.Color floorColor, java.awt.Color ceilColor)
          Sets the floor and ceiling colors.
 void setGridData(GridData _griddata)
          Sets the data storage to the given value.
 void setGridLineColor(java.awt.Color c)
          Sets the color for grid line boundaries
 void setIndexes(int[] indexes)
          Sets the indexes for the data components that will be plotted.
 void setLabelFormat(java.lang.String _format)
          Sets the format for the axis labels.
 void setPaletteType(int type)
          Determines the palette type that will be used.
 void setRotationAngle(double angle)
          Sets the viewing rotation angle.
 void setShowGridLines(boolean show)
          Outlines the data grid's boundaries.
 void setTranslation(int xpix, int ypix)
          Translates the view by the specified number of pixels.
 void setVisible(boolean isVisible)
          Sets the visibility of the lattice.
 javax.swing.JFrame showLegend()
          Shows a legend of phase angle and color.
 void update()
          Updates the surface plot using the current data.
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

labelFormat

protected java.text.DecimalFormat labelFormat

INIT_CALC_DIV

public static final int INIT_CALC_DIV
Field INIT_CALC_DIV

See Also:
Constant Field Values

INIT_DISP_DIV

public static final int INIT_DISP_DIV
Field INIT_DISP_DIV

See Also:
Constant Field Values
Constructor Detail

ComplexSurfacePlot

public ComplexSurfacePlot()
Constructs the ComplexSurfacePlot without data.


ComplexSurfacePlot

public ComplexSurfacePlot(GridData _griddata)
ComplexSurfacePlot constructor with the given data model.

Parameters:
_griddata - GridData
Method Detail

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

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

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

getGridData

public GridData getGridData()
Gets the GridData object.

Specified by:
getGridData in interface Plot2D
Returns:
GridData

setGridData

public void setGridData(GridData _griddata)
                 throws java.lang.IllegalArgumentException
Sets the data storage to the given value.

Specified by:
setGridData in interface Plot2D
Parameters:
_griddata -
Throws:
java.lang.IllegalArgumentException

setIndexes

public void setIndexes(int[] indexes)
Sets the indexes for the data components that will be plotted. Indexes determine the postion of the amplitude, real-component, and imaginary-component in the data array.

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

setColorPalette

public void setColorPalette(java.awt.Color[] colors)
Sets the colors that will be used between the floor and ceiling values. Not implemented. Color always maps to phase.

Specified by:
setColorPalette in interface Plot2D
Parameters:
colors -

setVisible

public void setVisible(boolean isVisible)
Sets the visibility of the lattice. Drawing will be disabled if visible is false.

Specified by:
setVisible in interface Plot2D
Parameters:
isVisible -

showLegend

public javax.swing.JFrame showLegend()
Shows a legend of phase angle and color.

Specified by:
showLegend in interface Plot2D

setShowGridLines

public void setShowGridLines(boolean show)
Outlines the data grid's boundaries.

Specified by:
setShowGridLines in interface Plot2D
Parameters:
show -

setGridLineColor

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

Specified by:
setGridLineColor in interface Plot2D
Parameters:
c -

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Paint the surface.

Specified by:
draw in interface Drawable
Parameters:
panel -
g -

setPaletteType

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

Specified by:
setPaletteType in interface Plot2D
Parameters:
type -

setLabelFormat

public void setLabelFormat(java.lang.String _format)
Sets the format for the axis labels. For example, _format=0.000 will produce three digits to the right of decimal point

Parameters:
_format - the format string

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:
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

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 -

update

public void update()
Updates the surface plot using the current data.

Specified by:
update in interface Plot2D

setTranslation

public void setTranslation(int xpix,
                           int ypix)
Translates the view by the specified number of pixels.

Parameters:
xpix - the x translation in pixels
ypix - the y translation in pixels

setRotationAngle

public void setRotationAngle(double angle)
Sets the viewing rotation angle.

Parameters:
angle - the rotation angle in degrees

setElevationAngle

public void setElevationAngle(double angle)
Sets the viewing elevation angle.

Parameters:
angle - the elevation angle in degrees

setDistance

public void setDistance(double distance)
Sets the viewing distance.

Parameters:
distance - the distance

set2DScaling

public void set2DScaling(double scale)
Sets the 2D scaling factor.

Parameters:
scale - the scaling factor

mousePressed

public boolean mousePressed(java.awt.event.MouseEvent e,
                            DrawingPanel drawingPanel)
mouseDown event handler. Sets internal tracking variables for dragging operations.

Parameters:
e - the event
drawingPanel -
Returns:
mouse pressed flag

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e,
                          DrawingPanel drawingPanel)
Method mouseReleased

Parameters:
e -
drawingPanel -

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e,
                         DrawingPanel drawingPanel)
mouseDrag event handler. Tracks dragging operations. Checks the delay regeneration flag and does proper actions.

Parameters:
e - the event
drawingPanel -

getXMin

public double getXMin()
Gets the minimum x needed to draw this object.

Specified by:
getXMin in interface Measurable
Returns:
minimum

getXMax

public double getXMax()
Gets the maximum x needed to draw this object.

Specified by:
getXMax in interface Measurable
Returns:
maximum

getYMin

public double getYMin()
Gets the minimum y needed to draw this object.

Specified by:
getYMin in interface Measurable
Returns:
minimum

getYMax

public double getYMax()
Gets the maximum y needed to draw this object.

Specified by:
getYMax in interface Measurable
Returns:
minimum

isMeasured

public boolean isMeasured()
Determines if information is available to set min/max values. X y values have no meaning for this plot.

Specified by:
isMeasured in interface Measurable
Returns:
false

getLoader

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

Returns:
the object loader