Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.faceless.graph.output
Class PNGOutput

    java.lang.Object
      org.faceless.graph.output.Output
          org.faceless.graph.output.ImageOutput
              org.faceless.graph.output.PNGOutput

    public class PNGOutput

extends ImageOutput

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

### PNGOutput

    public PNGOutput(int width,
                     int height,
                     OutputStream out)

  Create a new PNGOutput of the specified width and height. The resulting image has a white background.

  Parameters:
    `width` - the width of the image in pixels
    `height` - the height of the image in pixels
    `out` - the OutputStream to render the image to

### PNGOutput

    public PNGOutput(int width,
                     int height,
                     Color color,
                     OutputStream out)

  Create a new PNGOutput of the specified width, height and background color.

  Parameters:
    `width` - the width of the image in pixels
    `height` - the height of the image in pixels
    `color` - the background color of the image.
    `out` - the OutputStream to render the image to

Method Detail

### setNumColors

    public void setNumColors(int numcolors)

  The number of distinct colors to use in the image. By default, all PNG images are limited to 256 colors. This means they can be saved as an 8-bit PNG rather than 24-bit, with a smaller file as a result. The penalty is a slightly reduced image quality, which frankly may be an issue for photographs but for graphs is unnoticable, and a slightly longer rendering time.

  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.

  Parameters:
    `num` - the maximum number of colors to use in the image, or zero for no reduction (possibly resulting in a 24-bit PNG).

### render

    public void render(Graph gr)
                throws IOException

  Description copied from class: `Output`
  Render the Graph to this Output object.

  Overrides:
    `render` in class `ImageOutput`
  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 Big Faceless Organization