java - JFreechart fill color outside polygon -


After

I can create a polygon annotation on my chart and know how to fill the chart with just the color outside of the prepared polygon Want to I am using Jfreechart 1.0.17

I work it like this at this time:.

  color plotBackground = (color) plot.getBackgroundPaint (); Plot.setBackgroundPaint (new color (0xff0000)); XYLineAndShapeRenderer Renderer = (XYLineAndShapeRenderer) plot.getRenderer (); XYPolygonAnnotationA = New XYPolygonAnnotation (New Double [] {2.0, 5.0, 2.5, 8.0, 3.0, 5.0, 2.5, 2.0}, Null, Null, New Color (plotBackground.getRed), plotBackground.getGreen (), plotBackground.getBlue (), 255));  

But this is not true what I want, we can not see the grid line like this in this way.

Here is the possible solution:

  Rectangle2D r2d = new Rectangle2D.Double (plot.getQuadrantOrigin () getX (), plot.getQuadrantOrigin () Gety (), 3.2, 9 ..); Area A1 = New Area (R2D); Path 2d Float p = new path 2d. Float (); P.moveTo (2.0, 5.0); P.lineTo (2.5, 8.0); P.lineTo (3.0, 5.0); P.lineTo (2.5, 2.0); P.closePath (); Area A2 = New Area (P); A1.subtract (a2); XYShapeAnnotation a = New XYShapeAnnotation (a1, new BasicStroke (), new color (0xff0000), new color (0xff0000)); Renderer.ed Annotation (A, Layer Background); In the text after "text" itemprop = "text"> 

jfreecharts source code annotations are always painted after gridlines are painted in

  XYPolygonAnnotation A = new XYPolygonAnnotation (new double [] {2.0, 5.0, 2.5, 8.0, 3.0, 5.0, 2.5, 2.0}, null, weak , New color (plotBackground.getRed (), PlotBackground.getGreen (), plotBackground.getBlue (), 255)) {@ Override Public Zero Draw (Graphics 2DG2, X Plot Plot, Rectangle 2D Datairia, Value Axis Domain Axis, Value Axis Range Axis, Interrender Index, Plot RenderingInfo) {Graphics2D g22 = (Graphics 2D) G2.create (); G22.setXorMode (new color (0xff0000)); Super.draw (g22, plot, datairia, domain axis, range axis, renderer index, info); }}; Renderer.ed Annotation (A, Layer Background);  

Some images are merged with backgrounds and gridlines with a x-ray composite drawing. The following results appear:

simplegraph

< / Html>

Comments