java - Apply image/pattern to pie section instead of normal color -
Instead of using the normal plot.setSectionPaint () method to fill the pie section It is possible to add a pattern or an image as shown below.
I have received this requirement because it is difficult to differentiate the color when it is printed in black; White printer
Most cases, if not possible, I will have to use 2 different colors which can easily vary on B / W printers
Allows any implementation to pass the interface color is a class that implements paint , but there are some others, such as
This code is a TexturePaint like blue line pattern in your example:
BufferedImage texture = new BufferedImage (1, 30, BufferedImage.TYPE_INT_RGB ); Graphics2D G = texture.createGraphics (); G.setColor (Color.white); G.fillRect (0, 0, 1, 30); G.setColor (new color (0x26A2D6)); G.fillRect (0, 0, 1, 20); G.dispose (); Texture Paint Pattern Paint = New Texture (Texture, Texture. Gastre). Get (); You can pass that code to texturePaint as the argument of setSectionPaint .
Comments
Post a Comment