Search this API

y.io
Class JPGIOHandler

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

public class JPGIOHandler
extends ImageOutputHandler

Writes a Graph2D in JPG image format. 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(java.awt.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
JPGIOHandler()
          Instantiates a new JPGIOHandler.
 
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 img, java.io.OutputStream out)
          Encodes the given image to the given output stream.
 java.lang.String getFileFormatString()
          Returns the JPG file format string.
 java.lang.String getFileNameExtension()
          Returns the JPG file name extension, i.e.
 float getQuality()
          Returns the quality level of JPG encoding.
 void setQuality(float quality)
          Sets the quality level of JPG encoding.
 
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

JPGIOHandler

public JPGIOHandler()
Instantiates a new JPGIOHandler.

Method Detail

getFileFormatString

public java.lang.String getFileFormatString()
Returns the JPG file format string.

Specified by:
getFileFormatString in class IOHandler

getFileNameExtension

public java.lang.String getFileNameExtension()
Returns the JPG file name extension, i.e. "jpg"

Specified by:
getFileNameExtension 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

encode

protected void encode(java.awt.image.BufferedImage img,
                      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.

setQuality

public void setQuality(float quality)
Sets the quality level of JPG encoding. At a quality level of 1.0 the encoding will lead to no loss of data due to quantization. The lower the level the more loss of data will occur. By default a setting of 1.0 (no loss) is used.

Parameters:
quality - a value between 0.0 and 1.0

getQuality

public float getQuality()
Returns the quality level of JPG encoding.


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