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 TypeMethodDescriptionvoidappend(int dataIndex, double x, double y) Appends an (x,y) datum to the image.protected org.opensourcephysics.display2d.DataRaster.ImageDatacheckIndex(int dataIndex) Ensures that the image data existsvoidclear()Clears all data from all Datasets.voidclear(int i) Clears data from the i-th dataset.voiddraw(DrawingPanel panel, Graphics g) Draw the image containing the dataset pixels.doublegetPixColor(int xpix, int ypix) doublegetWidth()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.booleanDetermines if information is available to set min/max values.render()Paints a new image using the existing data.voidSets the data point marker color.protected BufferedImagesetImage(BufferedImage image) voidsetMinMax(double _minx, double _maxx, double _miny, double _maxy) voidsetVisible(boolean isVisible) Sets the visibility of the DataRaster.voidsetXMax(double _value) voidsetXMin(double _value) voidsetYMax(double _value) voidsetYMin(double _value) 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
-
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: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
-
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: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
-
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-
-