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. @author Wolfgang Christian @version 1.0
| 26 | * @version 1.0 |
| 27 | */ |
| 28 | public class DataRaster implements Measurable { |
| 29 | |
| 30 | // BH 2020.03.04 Modified to be more efficient with setting image pixels |
| 31 | // never used? |
| 32 | /** |
| 33 | * The drawing panel that determines the image size. |
| 34 | */ |
| 35 | DrawingPanel primaryDrawingPanel = null; |
| 36 | |
| 37 | public DrawingPanel getDrawingPanel() { |
| 38 | return primaryDrawingPanel; |
| 39 | } |
| 40 | |
| 41 | Color backgroundColor; |
| 42 | ArrayList<ImageData> imageDatasets = new ArrayList<ImageData>(); |
| 43 | boolean visible = true; |
| 44 | protected double xmin = -1; |
| 45 | protected double xmax = 1; |
| 46 | protected double ymin = -1; |
| 47 | protected double ymax = 1; |
| 48 | private double xrange, yrange; |
| 49 | //private int alpha = 255; // the alpha value for the image |
| 50 | private BufferedImage image; |
| 51 | int[] pixels; |
| 52 | int imageWidth, imageHeight; |
| 53 | protected int maxPoints = 0x2ffff; // the maximum number of points that will be saved as image data. |
| 54 | double xppu = 0; // x pixels per unit during last drawing |
| 55 | double yppu = 0; |
| 56 | double xMin, yMax; // based on panel |
| 57 | |
| 58 | /** |
| 59 | * Constructs a DataRaster object that maps (x,y) data to image pixels. |
| 60 | * |
| 61 | * @param dp the drawing panel that will be used to calculate the image size |
| 62 | * @param _xmin the mininum x value that can be mapped |
| 63 | * @param _xmax the maximum x value that can be mapped |
| 64 | * @param _ymin the mininum y value that can be mapped |
| 65 | * @param _ymax the maximum y value that can be mapped |
| 66 | */ |
| 67 | public DataRaster(DrawingPanel dp, double _xmin, double _xmax, double _ymin, double _ymax) { |
| 68 | primaryDrawingPanel = dp; |
| 69 | if (primaryDrawingPanel != null) { |
| 70 | primaryDrawingPanel.setPixelScale(); |
| 71 | } |
| 72 | setMinMax(Math.min(_xmin, _xmax), Math.max(_xmin, _xmax), Math.min(_ymin, _ymax), Math.max(_ymin, _ymax)); |
| 73 | setImage(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)); // make a 1x1 image to start |
| 74 | backgroundColor = new Color(image.getRGB(0, 0)); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Appends an (x,y) datum to the image. |
| 79 | * |
| 80 | * @param x |
| 81 | * @param y |
| 82 | * @param dataIndex Description of Parameter |
| 83 | */ |
| 84 | public void append(int dataIndex, double x, double y) { |
| 85 | checkIndex(dataIndex).append(x, y); |
nothing calls this directly
no outgoing calls
no test coverage detected