@Test public void drawDataImage() throws Exception{ int colorValue=0; double[] numbers=new double[200*100]; for(int i=0; i<200*100;i++){ if(i%5000==0) colorValue++; numbers[i]=colorValue; } ArrayDouble dataList=new ArrayDouble(numbers); Cell2DDataset dataSet=Cell2DDatasets.linearRange(dataList,Ranges.range(0,200),200,Ranges.range(0, 100),100 ); GraphBuffer test=new GraphBuffer(300, 200); test.setXScaleAsCell(Ranges.range(0, 200), 0, 200, ValueScales.linearScale()); test.setYScaleAsCell(Ranges.range(0, 100), 0, 100, ValueScales.linearScale()); int [] xPointToDataMap= new int [200]; int [] yPointToDataMap= new int [100]; for(int i=0; i<200;i++){ xPointToDataMap [i]=i; } for(int i=0;i<100;i++){ yPointToDataMap[i]=i; } NumberColorMap colormap = NumberColorMaps.JET; NumberColorMapInstance colorMapInstance=colormap.createInstance(Ranges.range(1, 4)); test.drawBackground(Color.white); test.drawDataImage(50,50, xPointToDataMap, yPointToDataMap, dataSet, colorMapInstance); ImageAssert.compareImages("graphBuffer.drawDataImage", test.getImage()); }
public void drawDataImage(int xStartPoint, int yStartPoint, int[] xPointToDataMap, int[] yPointToDataMap, Cell2DDataset data, NumberColorMapInstance colorMap) { int previousYData = -1; for (int yOffset = 0; yOffset < yPointToDataMap.length; yOffset++) { int yData = yPointToDataMap[yOffset]; if (yData != previousYData) { for (int xOffset = 0; xOffset < xPointToDataMap.length; xOffset++) { int xData = xPointToDataMap[xOffset]; int rgb = colorMap.colorFor(data.getValue(xData, yData)); setPixel( xStartPoint + xOffset , yStartPoint + yOffset , rgb ); } } else { if (hasAlphaChannel) { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*4 + 4*xStartPoint, pixels, (yStartPoint + yOffset)*width*4 + 4*xStartPoint, xPointToDataMap.length*4); } else { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*3 + 3*xStartPoint, pixels, (yStartPoint + yOffset)*width*3 + 3*xStartPoint, xPointToDataMap.length*3); } } previousYData = yData; } }
GraphBuffer { public void drawDataImage(int xStartPoint, int yStartPoint, int[] xPointToDataMap, int[] yPointToDataMap, Cell2DDataset data, NumberColorMapInstance colorMap) { int previousYData = -1; for (int yOffset = 0; yOffset < yPointToDataMap.length; yOffset++) { int yData = yPointToDataMap[yOffset]; if (yData != previousYData) { for (int xOffset = 0; xOffset < xPointToDataMap.length; xOffset++) { int xData = xPointToDataMap[xOffset]; int rgb = colorMap.colorFor(data.getValue(xData, yData)); setPixel( xStartPoint + xOffset , yStartPoint + yOffset , rgb ); } } else { if (hasAlphaChannel) { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*4 + 4*xStartPoint, pixels, (yStartPoint + yOffset)*width*4 + 4*xStartPoint, xPointToDataMap.length*4); } else { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*3 + 3*xStartPoint, pixels, (yStartPoint + yOffset)*width*3 + 3*xStartPoint, xPointToDataMap.length*3); } } previousYData = yData; } } }
GraphBuffer { public void drawDataImage(int xStartPoint, int yStartPoint, int[] xPointToDataMap, int[] yPointToDataMap, Cell2DDataset data, NumberColorMapInstance colorMap) { int previousYData = -1; for (int yOffset = 0; yOffset < yPointToDataMap.length; yOffset++) { int yData = yPointToDataMap[yOffset]; if (yData != previousYData) { for (int xOffset = 0; xOffset < xPointToDataMap.length; xOffset++) { int xData = xPointToDataMap[xOffset]; int rgb = colorMap.colorFor(data.getValue(xData, yData)); setPixel( xStartPoint + xOffset , yStartPoint + yOffset , rgb ); } } else { if (hasAlphaChannel) { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*4 + 4*xStartPoint, pixels, (yStartPoint + yOffset)*width*4 + 4*xStartPoint, xPointToDataMap.length*4); } else { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*3 + 3*xStartPoint, pixels, (yStartPoint + yOffset)*width*3 + 3*xStartPoint, xPointToDataMap.length*3); } } previousYData = yData; } } private  GraphBuffer(BufferedImage image);  GraphBuffer(int width, int height);  GraphBuffer(Graph2DRenderer<?> renderer); }
GraphBuffer { public void drawDataImage(int xStartPoint, int yStartPoint, int[] xPointToDataMap, int[] yPointToDataMap, Cell2DDataset data, NumberColorMapInstance colorMap) { int previousYData = -1; for (int yOffset = 0; yOffset < yPointToDataMap.length; yOffset++) { int yData = yPointToDataMap[yOffset]; if (yData != previousYData) { for (int xOffset = 0; xOffset < xPointToDataMap.length; xOffset++) { int xData = xPointToDataMap[xOffset]; int rgb = colorMap.colorFor(data.getValue(xData, yData)); setPixel( xStartPoint + xOffset , yStartPoint + yOffset , rgb ); } } else { if (hasAlphaChannel) { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*4 + 4*xStartPoint, pixels, (yStartPoint + yOffset)*width*4 + 4*xStartPoint, xPointToDataMap.length*4); } else { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*3 + 3*xStartPoint, pixels, (yStartPoint + yOffset)*width*3 + 3*xStartPoint, xPointToDataMap.length*3); } } previousYData = yData; } } private  GraphBuffer(BufferedImage image);  GraphBuffer(int width, int height);  GraphBuffer(Graph2DRenderer<?> renderer); void setPixel(int x, int y, int color); BufferedImage getImage(); Graphics2D getGraphicsContext(); void drawDataImage(int xStartPoint, int yStartPoint,
                        int[] xPointToDataMap, int[] yPointToDataMap,
                        Cell2DDataset data, NumberColorMapInstance colorMap); void setXScaleAsCell(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); void setXScaleAsPoint(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); int xValueToPixel(double value); double xPixelLeftToValue(int pixelValue); double xPixelRightToValue(int pixelValue); double xPixelCenterToValue(int pixelValue); void setYScaleAsCell(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); void setYScaleAsPoint(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); int yValueToPixel(double value); double yPixelTopToValue(int pixelValue); double yPixelCenterToValue(int pixelValue); double yPixelBottomToValue(int pixelValue); void drawValueLine(ListNumber xValues, ListNumber yValues, InterpolationScheme interpolation, ProcessValue pv); void drawValueExplicitLine(Point2DDataset data, InterpolationScheme interpolation, ReductionScheme reduction,ProcessValue pv); }
GraphBuffer { public void drawDataImage(int xStartPoint, int yStartPoint, int[] xPointToDataMap, int[] yPointToDataMap, Cell2DDataset data, NumberColorMapInstance colorMap) { int previousYData = -1; for (int yOffset = 0; yOffset < yPointToDataMap.length; yOffset++) { int yData = yPointToDataMap[yOffset]; if (yData != previousYData) { for (int xOffset = 0; xOffset < xPointToDataMap.length; xOffset++) { int xData = xPointToDataMap[xOffset]; int rgb = colorMap.colorFor(data.getValue(xData, yData)); setPixel( xStartPoint + xOffset , yStartPoint + yOffset , rgb ); } } else { if (hasAlphaChannel) { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*4 + 4*xStartPoint, pixels, (yStartPoint + yOffset)*width*4 + 4*xStartPoint, xPointToDataMap.length*4); } else { System.arraycopy(pixels, (yStartPoint + yOffset - 1)*width*3 + 3*xStartPoint, pixels, (yStartPoint + yOffset)*width*3 + 3*xStartPoint, xPointToDataMap.length*3); } } previousYData = yData; } } private  GraphBuffer(BufferedImage image);  GraphBuffer(int width, int height);  GraphBuffer(Graph2DRenderer<?> renderer); void setPixel(int x, int y, int color); BufferedImage getImage(); Graphics2D getGraphicsContext(); void drawDataImage(int xStartPoint, int yStartPoint,
                        int[] xPointToDataMap, int[] yPointToDataMap,
                        Cell2DDataset data, NumberColorMapInstance colorMap); void setXScaleAsCell(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); void setXScaleAsPoint(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); int xValueToPixel(double value); double xPixelLeftToValue(int pixelValue); double xPixelRightToValue(int pixelValue); double xPixelCenterToValue(int pixelValue); void setYScaleAsCell(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); void setYScaleAsPoint(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); int yValueToPixel(double value); double yPixelTopToValue(int pixelValue); double yPixelCenterToValue(int pixelValue); double yPixelBottomToValue(int pixelValue); void drawValueLine(ListNumber xValues, ListNumber yValues, InterpolationScheme interpolation, ProcessValue pv); void drawValueExplicitLine(Point2DDataset data, InterpolationScheme interpolation, ReductionScheme reduction,ProcessValue pv);  }