Search this API

y.io
Class ImageIoOutputHandler

java.lang.Object
  extended by y.io.IOHandler
      extended by y.io.ImageOutputHandler
          extended by y.io.ImageIoOutputHandler

public class ImageIoOutputHandler
extends ImageOutputHandler

This class serves as an adapter to the javax.imageio API which is available in J2RE version 1.4 and later. It can be used to adapt an ImageWriter to an ImageOutputHandler.

 

Constructor Summary
ImageIoOutputHandler(javax.imageio.ImageWriter iWriter)
          Creates a new instance of ImageIoOutputHandler using the given ImageWriter.
 
Method Summary
protected  java.awt.image.BufferedImage createImage(int width, int height)
          Creates the buffered image on which the graph will be rendered.
protected  void encode(java.awt.image.BufferedImage image, java.io.OutputStream out)
          Encodes the given image to the given output stream.
 java.lang.String getFileFormatString()
          Returns a descriptive string of the supported file format.
 java.lang.String getFileNameExtension()
          Returns the file name extension of the supported file format.
 javax.imageio.ImageWriteParam getImageWriteParam()
          Returns the current ImageWriteParam for the ImageWriter.
 javax.imageio.ImageWriter getImageWriter()
          Returns the currently set ImageWriter instance.
 boolean isTransparencyEnabled()
          Returns true if this image output handler uses an intermediate image that can handle non-opaque pixels and false otherwise.
 void setImageWriteParam(javax.imageio.ImageWriteParam iwp)
          Sets the current ImageWriteParam for the ImageWriter.
 void setImageWriter(javax.imageio.ImageWriter iWriter)
          Sets the new ImageWriter instance.
 void setTransparencyEnabled(boolean enabled)
          Specifies whether this image output handler uses an intermediate image that can or cannot handle non-opaque pixels.
 
Methods inherited from class y.io.ImageOutputHandler
canRead, createDefaultGraph2DView, createGraphicsContext, getBorder, isAntialiasingEnabled, isSelectionPaintingEnabled, read, setAntialiasingEnabled, setBorder, setSelectionPaintingEnabled, write, write
 
Methods inherited from class y.io.IOHandler
canWrite, canWriteSubset, createObjectInputStream, createObjectOutputStream, 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

ImageIoOutputHandler

public ImageIoOutputHandler(javax.imageio.ImageWriter iWriter)
Creates a new instance of ImageIoOutputHandler using the given ImageWriter.

Method Detail

isTransparencyEnabled

public boolean isTransparencyEnabled()
Returns true if this image output handler uses an intermediate image that can handle non-opaque pixels and false otherwise.

Defaults to false

Note: If the ImageWriter associated to this handler does not support transparency, the result image will only have opaque pixels regardless of this property.

Returns:
true if this image output handler uses an intermediate image that can handle non-opaque pixels and false otherwise.
See Also:
setTransparencyEnabled(boolean)

setTransparencyEnabled

public void setTransparencyEnabled(boolean enabled)
Specifies whether this image output handler uses an intermediate image that can or cannot handle non-opaque pixels.

Defaults to false

Note: If the ImageWriter associated to this handler does not support transparency, the result image will only have opaque pixels regardless of this property.

Parameters:
enabled - if true an intermediate image that can handle non-opaque pixels is used; otherwise an intermediate image that cannot handle non-opaque pixels is used.
See Also:
isTransparencyEnabled()

setImageWriter

public void setImageWriter(javax.imageio.ImageWriter iWriter)
Sets the new ImageWriter instance. This call resets the current ImageWriteParam to the default of the given writer.

Parameters:
iWriter - the new writer - must not be null

getImageWriter

public javax.imageio.ImageWriter getImageWriter()
Returns the currently set ImageWriter instance.


encode

protected void encode(java.awt.image.BufferedImage image,
                      java.io.OutputStream out)
               throws java.io.IOException
Description copied from class: ImageOutputHandler
Encodes the given image to the given output stream.

Specified by:
encode in class ImageOutputHandler
Throws:
java.io.IOException - if an error occurs during writing.

getFileNameExtension

public java.lang.String getFileNameExtension()
Description copied from class: IOHandler
Returns the file name extension of the supported file format. The extension does not include the separating dot (i.e, '.').

Specified by:
getFileNameExtension in class IOHandler

getFileFormatString

public java.lang.String getFileFormatString()
Description copied from class: IOHandler
Returns a descriptive string of the supported file format.

Specified by:
getFileFormatString in class IOHandler

createImage

protected java.awt.image.BufferedImage createImage(int width,
                                                   int height)
Description copied from class: ImageOutputHandler
Creates the buffered image on which the graph will be rendered.

Specified by:
createImage in class ImageOutputHandler

getImageWriteParam

public javax.imageio.ImageWriteParam getImageWriteParam()
Returns the current ImageWriteParam for the ImageWriter.


setImageWriteParam

public void setImageWriteParam(javax.imageio.ImageWriteParam iwp)
Sets the current ImageWriteParam for the ImageWriter.


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