y.io
Class ImageOutputHandler

java.lang.Object
  |
  +--y.io.IOHandler
        |
        +--y.io.ImageOutputHandler
Direct Known Subclasses:
GIFIOHandler, JPGIOHandler

public abstract class ImageOutputHandler
extends IOHandler

Abstract base class for IOHandlers that produce image based output formats. The encoding process is done in two steps. First the graph will be renderer to an image. Rendering upon an image is done by calling method Graph2DView.paintVisibleContent(Graphics2D) on the current view of the Graph2D. Configuring the view influences size, viewport, background, etc. of the rendered image. In the second step the image is taken and encoded to the output format.


Constructor Summary
protected ImageOutputHandler()
           
protected ImageOutputHandler(boolean antialias)
           
 
Method Summary
 boolean canRead()
          Returns false, since this class can't read a graph.
 Graph2DView createDefaultGraph2DView(Graph2D graph)
          Creates the default view used as image producer in case there is no current view associated with the graph2D.
protected abstract  BufferedImage createImage(int width, int height)
          Creates the buffered image on which the graph will be rendered.
protected abstract  void encode(BufferedImage image, OutputStream out)
          Encodes the given image to the given output stream.
 boolean isAntialiasingEnabled()
          Getter for property antialias.
 void read(Graph2D graph, InputStream in)
          Unsupported method.
 void setAntialiasingEnabled(boolean antialias)
          Setter for property antialias.
 void write(Graph2D graph, OutputStream out)
          Writes the contents of the given graph to the image based format encoded by this class.
 
Methods inherited from class y.io.IOHandler
canWrite, canWriteSubset, createObjectInputStream, createObjectOutputStream, getFileFormatString, getFileNameExtension, hide, read, read, shouldSerialize, shouldSerialize, write, writeSubset, writeSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageOutputHandler

protected ImageOutputHandler()

ImageOutputHandler

protected ImageOutputHandler(boolean antialias)
Method Detail

canRead

public boolean canRead()
Returns false, since this class can't read a graph.

Overrides:
canRead in class IOHandler

read

public void read(Graph2D graph,
                 InputStream in)
Unsupported method.

Specified by:
read in class IOHandler

write

public void write(Graph2D graph,
                  OutputStream out)
           throws IOException
Writes the contents of the given graph to the image based format encoded by this class.

Specified by:
write in class IOHandler
IOException
Parameters:
graph - the graph to be encoded.
out - The OutputStream being written to.

createImage

protected abstract BufferedImage createImage(int width,
                                             int height)
Creates the buffered image on which the graph will be rendered.


createDefaultGraph2DView

public Graph2DView createDefaultGraph2DView(Graph2D graph)
Creates the default view used as image producer in case there is no current view associated with the graph2D. The default view renders the graph in its original size using a white background color.

The returned view will be automatically registered as one of the graph's views. After the returned view is not needed anymore it is advisable to remove it from the list of registered view of the given graph.

See Also:
Graph2D.removeView(View)

encode

protected abstract void encode(BufferedImage image,
                               OutputStream out)
                        throws IOException
Encodes the given image to the given output stream.

IOException

isAntialiasingEnabled

public boolean isAntialiasingEnabled()
Getter for property antialias.

Returns:
Value of property antialias.

setAntialiasingEnabled

public void setAntialiasingEnabled(boolean antialias)
Setter for property antialias.

Parameters:
antialias - New value of property antialias.

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003