|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph.output.Output
org.faceless.graph.output.ImageOutput
org.faceless.graph.output.PNGOutput
public class PNGOutput
The PNGOutput
class is concrete subclass of
ImageOutput
which creates a PNG image as it's output.
PNG images can be viewed by most modern web browsers, and are
usually smaller than the equivalent GIF image. Further details
are available from
http://www.libpng.org/pub/png.
A few words about transparency. The PNG format includes support for full alpha-channel transparency, although this is poorly supported by both IE and Netscape. Since 1.0.8, the transparency handling has been rewritten to fit in with the broken alpha support in both these browsers.
A Graph may be set to have a transparent background by setting the background color to a value with an alpha-channel of zero, e.g.
Color clear_red = new Color(255,0,0, 0); Output out = new PNGOutput(400,400,clear_red, outputstream);The library will "mask" the image against a red background, and set the background to fully transparent - so when the image is painted on a red background the edges appear smooth. This will work with GIF images written with the
GIFOutput
class as well.
If a partially transparent background color is set, this will be
changed to fully transparent in order to display correctly in Internet
Explorer. This behaviour can be turned off by turning off color
quantization - setting setNumColors(0)
Constructor Summary | |
---|---|
PNGOutput(int width,
int height,
Color color,
OutputStream out)
Create a new PNGOutput of the specified width, height and background color. |
|
PNGOutput(int width,
int height,
OutputStream out)
Create a new PNGOutput of the specified width and height. |
Method Summary | |
---|---|
void |
render(Graph gr)
Render the Graph to this Output object. |
void |
setNumColors(int numcolors)
The number of distinct colors to use in the image. |
Methods inherited from class org.faceless.graph.output.ImageOutput |
---|
canPattern, canRotate, getCanvas, getGraph, getImage, getReducedColorImage, getTextBox, line, poly, setColor, setFontMap, setLineDash, setLineThickness, setMargin, setRenderingHint, text |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PNGOutput(int width, int height, OutputStream out)
width
- the width of the image in pixelsheight
- the height of the image in pixelsout
- the OutputStream to render the image topublic PNGOutput(int width, int height, Color color, OutputStream out)
width
- the width of the image in pixelsheight
- the height of the image in pixelscolor
- the background color of the image.out
- the OutputStream to render the image toMethod Detail |
---|
public void setNumColors(int numcolors)
If for some reason your graph has hundreds of distinct colors, you can set the number of colors to 0, and no color reduction will be done.
num
- the maximum number of colors to use in the image, or zero for
no reduction (possibly resulting in a 24-bit PNG).public void render(Graph gr) throws IOException
Output
render
in class ImageOutput
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |