public static BufferedImage createHeatMapImage(HeatMapDataset dataset, PaintScale paintScale) { if (dataset == null) { string str = "Null 'dataset' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else if (paintScale == null) { string str = "Null 'paintScale' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { int xsampleCount = dataset.getXSampleCount(); int ysampleCount = dataset.getYSampleCount(); BufferedImage bufferedImage = new BufferedImage(xsampleCount, ysampleCount, 2); Graphics2D graphics = bufferedImage.createGraphics(); for (int i1 = 0; i1 < xsampleCount; ++i1) { for (int i2 = 0; i2 < ysampleCount; ++i2) { double zvalue = dataset.getZValue(i1, i2); Paint paint = paintScale.getPaint(zvalue); graphics.setPaint(paint); ((Graphics) graphics).fillRect(i1, ysampleCount - i2 - 1, 1, 1); } } return bufferedImage; } }
public static void writeScaledChartAsPNG(OutputStream @out, JFreeChart chart, int width, int height, int widthScaleFactor, int heightScaleFactor) { if (@out == null) { string str = "Null 'out' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else if (chart == null) { string str = "Null 'chart' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { double num1 = (double) (width * widthScaleFactor); double num2 = (double) (height * heightScaleFactor); double num3 = (double) width; double num4 = (double) height; int num5 = 0; if (widthScaleFactor != 1 || heightScaleFactor != 1) num5 = 1; double num6 = num1 / num3; double num7 = num2 / num4; BufferedImage image = new BufferedImage(ByteCodeHelper.d2i(num1), ByteCodeHelper.d2i(num2), 2); Graphics2D graphics = image.createGraphics(); if (num5 != 0) { AffineTransform transform = graphics.getTransform(); graphics.transform(AffineTransform.getScaleInstance(num6, num7)); chart.draw(graphics, (Rectangle2D) new Rectangle2D.Double(0.0, 0.0, num3, num4), (Point2D) null, (ChartRenderingInfo) null); graphics.setTransform(transform); ((Graphics) graphics).dispose(); } else chart.draw(graphics, (Rectangle2D) new Rectangle2D.Double(0.0, 0.0, num3, num4), (Point2D) null, (ChartRenderingInfo) null); @out.write(ChartUtilities.encodeAsPNG(image)); } }