lt.monarch.image
Class ImageWriter

java.lang.Object
  extended by lt.monarch.image.ImageWriter

public class ImageWriter
extends java.lang.Object

This utility class writes chart view as encoded image to given data streams.


Field Summary
Modifier and Type Field and Description
static int SCREEN_DPI
          Number of pixels per inch on monitor screen.
 
Constructor Summary
Constructor and Description
ImageWriter()
           
 
Method Summary
Modifier and Type Method and Description
 void draw(AbstractGraphics g, View chart, int width, int height)
          Instead of writing encoded image data to stream, this lower level method allows to draw chart view into any graphics context for further custom manipulation.
 void writePNG(java.io.OutputStream stream, View chart, int width, int height)
          Outputs chart image encoded in PNG format with dpi equal to SCREEN_DPI.
 void writePNG(java.io.OutputStream stream, View chart, int width, int height, int dpi)
          Outputs chart image encoded in PNG format using given dpi.
 void writeSVG(java.io.OutputStream stream, View chart, int width, int height)
          Outputs chart image encoded in SVG format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCREEN_DPI

public static final int SCREEN_DPI
Number of pixels per inch on monitor screen. This constant is used to calculate necessary scaling when generating images with different DPIs. Equals to 72.

See Also:
Constant Field Values
Constructor Detail

ImageWriter

public ImageWriter()
Method Detail

writePNG

public void writePNG(java.io.OutputStream stream,
                     View chart,
                     int width,
                     int height)
Outputs chart image encoded in PNG format with dpi equal to SCREEN_DPI.

Parameters:
stream - stream to write into. Stream is closed on return.
chart - chart view
width - width of chart
height - height of chart

writePNG

public void writePNG(java.io.OutputStream stream,
                     View chart,
                     int width,
                     int height,
                     int dpi)
Outputs chart image encoded in PNG format using given dpi. Chart will look like on-screen-rendered width x height sized view, but image will be bigger in pixels. dpi/SCREEN_DPI ratio will be used for scaling.

Parameters:
stream - stream to write into. Stream is closed on return.
chart - chart view
width - width of chart
height - height of chart
dpi - dots per inch for exported image

writeSVG

public void writeSVG(java.io.OutputStream stream,
                     View chart,
                     int width,
                     int height)
Outputs chart image encoded in SVG format.

Parameters:
stream - stream to write into. Stream is closed on return.
chart - chart view
width - width of chart
height - height of chart

draw

public void draw(AbstractGraphics g,
                 View chart,
                 int width,
                 int height)
Instead of writing encoded image data to stream, this lower level method allows to draw chart view into any graphics context for further custom manipulation.

Parameters:
g - graphics context
chart - chart view
width - width of chart
height - height of chart