org.opensourcephysics.display2d
Class DataRaster

java.lang.Object
  extended by org.opensourcephysics.display2d.DataRaster
All Implemented Interfaces:
Drawable, Measurable

public class DataRaster
extends java.lang.Object
implements Measurable

DataRaster maps (x,y) data onto an image. The image has the same size as the data panel. Every data point renders itself as one pixel.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
protected  int alpha
           
protected  java.awt.image.BufferedImage image
           
protected  int maxPoints
           
 DrawingPanel primaryDrawingPanel
          The drawing panel that determines the image size.
protected  double xmax
           
protected  double xmin
           
protected  double ymax
           
protected  double ymin
           
 
Constructor Summary
DataRaster(DrawingPanel dp, double _xmin, double _xmax, double _ymin, double _ymax)
          Constructs a DataRaster object that maps (x,y) data to image pixels.
 
Method Summary
 void append(int dataIndex, double x, double y)
          Appends an (x,y) datum to the image.
protected  org.opensourcephysics.display2d.DataRaster.ImageData checkIndex(int dataIndex)
          Ensures that the image data exists
 void clear()
          Clears all data from all Datasets.
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draw the image containing the dataset pixels.
 java.awt.Color getBackgroundColor()
           
 double getHeight()
           
 java.awt.Color getPixColor(int xpix, int ypix)
           
 double getWidth()
           
 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.
 boolean isMeasured()
          Determines if information is available to set min/max values.
 java.awt.image.BufferedImage render()
          Paints a new image using the existing data.
 void setColor(int dataIndex, java.awt.Color color)
          Sets the data point marker color.
 void setMinMax(double _minx, double _maxx, double _miny, double _maxy)
           
 void setVisible(boolean isVisible)
          Sets the visibility of the DataRaster.
 void setXMax(double _value)
           
 void setXMin(double _value)
           
 void setYMax(double _value)
           
 void setYMin(double _value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

primaryDrawingPanel

public DrawingPanel primaryDrawingPanel
The drawing panel that determines the image size.


xmin

protected double xmin

xmax

protected double xmax

ymin

protected double ymin

ymax

protected double ymax

alpha

protected int alpha

image

protected java.awt.image.BufferedImage image

maxPoints

protected int maxPoints
Constructor Detail

DataRaster

public DataRaster(DrawingPanel dp,
                  double _xmin,
                  double _xmax,
                  double _ymin,
                  double _ymax)
Constructs a DataRaster object that maps (x,y) data to image pixels.

Parameters:
dp - the drawing panel that will be used to calculate the image size
_xmin - the mininum x value that can be mapped
_xmax - the maximum x value that can be mapped
_ymin - the mininum y value that can be mapped
_ymax - the maximum y value that can be mapped
Method Detail

append

public void append(int dataIndex,
                   double x,
                   double y)
Appends an (x,y) datum to the image.

Parameters:
x -
y -
dataIndex - Description of Parameter

setColor

public void setColor(int dataIndex,
                     java.awt.Color color)
Sets the data point marker color.

Parameters:
dataIndex -
color -

clear

public void clear()
Clears all data from all Datasets.


checkIndex

protected org.opensourcephysics.display2d.DataRaster.ImageData checkIndex(int dataIndex)
Ensures that the image data exists

Parameters:
dataIndex -

render

public java.awt.image.BufferedImage render()
Paints a new image using the existing data. returns the image buffer


draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Draw the image containing the dataset pixels.

Specified by:
draw in interface Drawable
Parameters:
panel - the panel containing this data raster
g - the graphics context upon which to draw

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
Returns:
true if min/max values are valid

setXMin

public void setXMin(double _value)

setXMax

public void setXMax(double _value)

setYMin

public void setYMin(double _value)

setYMax

public void setYMax(double _value)

setMinMax

public void setMinMax(double _minx,
                      double _maxx,
                      double _miny,
                      double _maxy)

getXMin

public double getXMin()
Description copied from interface: Measurable
Gets the minimum x needed to draw this object.

Specified by:
getXMin in interface Measurable
Returns:
minimum

getXMax

public double getXMax()
Description copied from interface: Measurable
Gets the maximum x needed to draw this object.

Specified by:
getXMax in interface Measurable
Returns:
maximum

getYMin

public double getYMin()
Description copied from interface: Measurable
Gets the minimum y needed to draw this object.

Specified by:
getYMin in interface Measurable
Returns:
minimum

getYMax

public double getYMax()
Description copied from interface: Measurable
Gets the maximum y needed to draw this object.

Specified by:
getYMax in interface Measurable
Returns:
minimum

getWidth

public double getWidth()

getHeight

public double getHeight()

getBackgroundColor

public java.awt.Color getBackgroundColor()

getPixColor

public java.awt.Color getPixColor(int xpix,
                                  int ypix)

setVisible

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

Parameters:
isVisible -