Class DataRaster

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

public class DataRaster extends 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 Details

    • xmin

      protected double xmin
    • xmax

      protected double xmax
    • ymin

      protected double ymin
    • ymax

      protected double ymax
    • maxPoints

      protected int maxPoints
  • Constructor Details

    • 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 Details

    • getDrawingPanel

      public DrawingPanel 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

      public void setColor(int dataIndex, Color color)
      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

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

      public void draw(DrawingPanel panel, 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
    • setImage

      protected BufferedImage setImage(BufferedImage image)
    • getWidth

      public double getWidth()
    • getHeight

      public double getHeight()
    • getBackgroundColor

      public Color getBackgroundColor()
    • getPixColor

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