public virtual void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { Polygon polygon = new Polygon(); int itemCount = dataset.getItemCount(seriesIndex); for (int i2 = 0; i2 < itemCount; ++i2) { double xvalue = dataset.getXValue(seriesIndex, i2); double yvalue = dataset.getYValue(seriesIndex, i2); Point point = plot.translateValueThetaRadiusToJava2D(xvalue, yvalue, dataArea); polygon.addPoint((int) point.x, (int) point.y); } g2.setPaint(this.lookupSeriesPaint(seriesIndex)); g2.setStroke(this.lookupSeriesStroke(seriesIndex)); if (this.isSeriesFilled(seriesIndex)) { Composite composite = g2.getComposite(); g2.setComposite((Composite) AlphaComposite.getInstance(3, 0.5f)); g2.fill((Shape) polygon); g2.setComposite(composite); } else g2.draw((Shape) polygon); }
public override void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!this.getItemVisible(series, item)) return; if (pass == 0) { IntervalXYDataset ntervalXyDataset = (IntervalXYDataset) dataset; DeviationRenderer.State state1 = (DeviationRenderer.State) state; double xvalue = ntervalXyDataset.getXValue(series, item); double startYvalue = ntervalXyDataset.getStartYValue(series, item); double endYvalue = ntervalXyDataset.getEndYValue(series, item); RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); double num1 = domainAxis.valueToJava2D(xvalue, dataArea, domainAxisEdge); double num2 = rangeAxis.valueToJava2D(startYvalue, dataArea, rangeAxisEdge); double num3 = rangeAxis.valueToJava2D(endYvalue, dataArea, rangeAxisEdge); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.__\u003C\u003EHORIZONTAL) { List list1 = state1.lowerCoordinates; double[] numArray1 = new double[2]; int index1 = 0; double num4 = num2; numArray1[index1] = num4; int index2 = 1; double num5 = num1; numArray1[index2] = num5; list1.add((object) numArray1); List list2 = state1.upperCoordinates; double[] numArray2 = new double[2]; int index3 = 0; double num6 = num3; numArray2[index3] = num6; int index4 = 1; double num7 = num1; numArray2[index4] = num7; list2.add((object) numArray2); } else if (orientation == PlotOrientation.__\u003C\u003EVERTICAL) { List list1 = state1.lowerCoordinates; double[] numArray1 = new double[2]; int index1 = 0; double num4 = num1; numArray1[index1] = num4; int index2 = 1; double num5 = num2; numArray1[index2] = num5; list1.add((object) numArray1); List list2 = state1.upperCoordinates; double[] numArray2 = new double[2]; int index3 = 0; double num6 = num1; numArray2[index3] = num6; int index4 = 1; double num7 = num3; numArray2[index4] = num7; list2.add((object) numArray2); } if (item == dataset.getItemCount(series) - 1) { Composite composite = g2.getComposite(); g2.setComposite((Composite) AlphaComposite.getInstance(3, this.alpha)); g2.setPaint(this.getItemFillPaint(series, item)); GeneralPath generalPath = new GeneralPath(); double[] numArray1 = (double[]) state1.lowerCoordinates.get(0); ((Path2D.Float) generalPath).moveTo((float) numArray1[0], (float) numArray1[1]); for (int index = 1; index < state1.lowerCoordinates.size(); ++index) { double[] numArray2 = (double[]) state1.lowerCoordinates.get(index); ((Path2D.Float) generalPath).lineTo((float) numArray2[0], (float) numArray2[1]); } int num4 = state1.upperCoordinates.size(); double[] numArray3 = (double[]) state1.upperCoordinates.get(num4 - 1); ((Path2D.Float) generalPath).lineTo((float) numArray3[0], (float) numArray3[1]); int num5 = num4 - 2; while (num5 >= 0) { double[] numArray2 = (double[]) state1.upperCoordinates.get(num5); ((Path2D.Float) generalPath).lineTo((float) numArray2[0], (float) numArray2[1]); num5 += -1; } ((Path2D) generalPath).closePath(); g2.fill((Shape) generalPath); g2.setComposite(composite); state1.lowerCoordinates.clear(); state1.upperCoordinates.clear(); } } if (this.isLinePass(pass)) { if (item == 0) { DeviationRenderer.State state1 = (DeviationRenderer.State) state; ((Path2D) state1.seriesPath).reset(); state1.setLastPointGood(false); } if (!this.getItemLineVisible(series, item)) return; this.drawPrimaryLineAsPath(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); } else { if (!this.isItemPass(pass)) return; EntityCollection entities = (EntityCollection) null; if (info != null) entities = info.getOwner().getEntityCollection(); this.drawSecondaryPass(g2, plot, dataset, pass, series, item, domainAxis, dataArea, rangeAxis, crosshairState, entities); } }
// protected void doDrawOnTo(BufferedImageRaster canvas) // { // Sector sector = this.getSector(); // if (null == sector) // { // String message = Logging.getMessage("nullValue.SectorIsNull"); // Logging.logger().severe(message); // throw new ArgumentException(message); // } // // if (!sector.intersects(canvas.getSector())) // { // return; // } // // BufferedImage transformedImage = null; // java.awt.Graphics2D g2d = null; // java.awt.Shape prevClip = null; // java.awt.Composite prevComposite = null; // // try // { // int canvasWidth = canvas.getWidth(); // int canvasHeight = canvas.getHeight(); // // // Apply the transform that correctly maps the image onto the canvas. // java.awt.geom.AffineTransform transform = this.computeSourceToDestTransform( // this.getWidth(), this.getHeight(), this.getSector(), canvasWidth, canvasHeight, canvas.getSector()); // // AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); // Rectangle2D rect = op.getBounds2D(this.getBufferedImage()); // // int clipWidth = (int) Math.Ceiling((rect.getMaxX() >= canvasWidth) ? canvasWidth : rect.getMaxX()); // int clipHeight = (int) Math.Ceiling((rect.getMaxY() >= canvasHeight) ? canvasHeight : rect.getMaxY()); // // if (clipWidth <= 0 || clipHeight <= 0) // { // return; // } // // int transformedImageType = (BufferedImage.TYPE_CUSTOM != this.getBufferedImage().getType()) // ? this.getBufferedImage().getType() : BufferedImage.TYPE_INT_ARGB; // // transformedImage = new BufferedImage(clipWidth, clipHeight, transformedImageType); // op.filter(this.getBufferedImage(), transformedImage); // // g2d = canvas.getGraphics(); // // prevClip = g2d.getClip(); // prevComposite = g2d.getComposite(); // // // Set the alpha composite for appropriate alpha blending. // g2d.setComposite(java.awt.AlphaComposite.SrcOver); // g2d.drawImage(transformedImage, 0, 0, null); // } // catch (java.awt.image.ImagingOpException ioe) // { // // If we catch a ImagingOpException, then the transformed image has a width or height of 0. // // This indicates that there is no intersection between the source image and the canvas, // // or the intersection is smaller than one pixel. // } // catch (java.awt.image.RasterFormatException rfe) // { // // If we catch a RasterFormatException, then the transformed image has a width or height of 0. // // This indicates that there is no intersection between the source image and the canvas, // // or the intersection is smaller than one pixel. // } // finally // { // // Restore the previous clip, composite, and transform. // try // { // if (null != transformedImage) // { // transformedImage.flush(); // } // // if (null != g2d) // { // if (null != prevClip) // { // g2d.setClip(prevClip); // } // // if (null != prevComposite) // { // g2d.setComposite(prevComposite); // } // } // } // catch (Throwable t) // { // Logging.logger().log(java.util.logging.Level.FINEST, WWUtil.extractExceptionReason(t), t); // } // } // } protected void doDrawOnTo(BufferedImageRaster canvas) { Sector sector = this.getSector(); if (null == sector) { String message = Logging.getMessage("nullValue.SectorIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (!sector.intersects(canvas.getSector())) { return; } java.awt.Graphics2D g2d = null; java.awt.Shape prevClip = null; java.awt.Composite prevComposite = null; java.lang.Object prevInterpolation = null, prevAntialiasing = null; try { int canvasWidth = canvas.getWidth(); int canvasHeight = canvas.getHeight(); // Apply the transform that correctly maps the image onto the canvas. java.awt.geom.AffineTransform transform = this.computeSourceToDestTransform( this.getWidth(), this.getHeight(), this.getSector(), canvasWidth, canvasHeight, canvas.getSector()); AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); Rectangle2D rect = op.getBounds2D(this.getBufferedImage()); int clipWidth = (int)Math.Ceiling((rect.getMaxX() >= canvasWidth) ? canvasWidth : rect.getMaxX()); int clipHeight = (int)Math.Ceiling((rect.getMaxY() >= canvasHeight) ? canvasHeight : rect.getMaxY()); if (clipWidth <= 0 || clipHeight <= 0) { return; } g2d = canvas.getGraphics(); prevClip = g2d.getClip(); prevComposite = g2d.getComposite(); prevInterpolation = g2d.getRenderingHint(RenderingHints.KEY_INTERPOLATION); prevAntialiasing = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING); // Set the alpha composite for appropriate alpha blending. g2d.setComposite(java.awt.AlphaComposite.SrcOver); g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.drawImage(this.getBufferedImage(), transform, null); } // catch (java.awt.image.ImagingOpException ioe) // { // // If we catch a ImagingOpException, then the transformed image has a width or height of 0. // // This indicates that there is no intersection between the source image and the canvas, // // or the intersection is smaller than one pixel. // } // catch (java.awt.image.RasterFormatException rfe) // { // // If we catch a RasterFormatException, then the transformed image has a width or height of 0. // // This indicates that there is no intersection between the source image and the canvas, // // or the intersection is smaller than one pixel. // } catch (Throwable t) { String reason = WWUtil.extractExceptionReason(t); Logging.logger().log(java.util.logging.Level.SEVERE, reason, t); } finally { // Restore the previous clip, composite, and transform. try { if (null != g2d) { if (null != prevClip) { g2d.setClip(prevClip); } if (null != prevComposite) { g2d.setComposite(prevComposite); } if (null != prevInterpolation) { g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, prevInterpolation); } if (null != prevAntialiasing) { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, prevAntialiasing); } } } catch (Throwable t) { Logging.logger().log(java.util.logging.Level.FINEST, WWUtil.extractExceptionReason(t), t); } } }