Package org.opensourcephysics.display2d
Class DataRaster
java.lang.Object
org.opensourcephysics.display2d.DataRaster
- All Implemented Interfaces:
Drawable
,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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDataRaster
(DrawingPanel dp, double _xmin, double _xmax, double _ymin, double _ymax) Constructs a DataRaster object that maps (x,y) data to image pixels. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 existsvoid
clear()
Clears all data from all Datasets.void
clear
(int i) Clears data from the i-th dataset.void
draw
(DrawingPanel panel, Graphics g) Draw the image containing the dataset pixels.double
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
Determines if information is available to set min/max values.render()
Paints a new image using the existing data.void
Sets the data point marker color.protected BufferedImage
setImage
(BufferedImage image) 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
Methods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
xmin
protected double xmin -
xmax
protected double xmax -
ymin
protected double ymin -
ymax
protected double ymax -
maxPoints
protected int maxPoints
-
-
Constructor Details
-
DataRaster
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 Details
-
getDrawingPanel
-
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
Sets the data point marker color.- Parameters:
dataIndex
-color
-
-
clear
public void clear()Clears all data from all Datasets. -
clear
public void clear(int i) Clears data from the i-th dataset.- Parameters:
i
- the dataset index
-
checkIndex
protected org.opensourcephysics.display2d.DataRaster.ImageData checkIndex(int dataIndex) Ensures that the image data exists- Parameters:
dataIndex
-
-
render
Paints a new image using the existing data. returns the image buffer -
draw
Draw the image containing the dataset pixels. -
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 interfaceMeasurable
- 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 interfaceMeasurable
- Returns:
- minimum
-
getXMax
public double getXMax()Description copied from interface:Measurable
Gets the maximum x needed to draw this object.- Specified by:
getXMax
in interfaceMeasurable
- Returns:
- maximum
-
getYMin
public double getYMin()Description copied from interface:Measurable
Gets the minimum y needed to draw this object.- Specified by:
getYMin
in interfaceMeasurable
- Returns:
- minimum
-
getYMax
public double getYMax()Description copied from interface:Measurable
Gets the maximum y needed to draw this object.- Specified by:
getYMax
in interfaceMeasurable
- Returns:
- minimum
-
setImage
-
getWidth
public double getWidth() -
getHeight
public double getHeight() -
getBackgroundColor
-
getPixColor
-
setVisible
public void setVisible(boolean isVisible) Sets the visibility of the DataRaster. Drawing will be disabled if visible is false.- Parameters:
isVisible
-
-