yext.graphml.graph2D
Class ImageConverter

java.lang.Object
  extended byyext.graphml.graph2D.ImageConverter
All Implemented Interfaces:
GraphMLParseContext.ResourceDecoder, GraphMLWriteContext.ResourceEncoder

public class ImageConverter
extends Object
implements GraphMLParseContext.ResourceDecoder, GraphMLWriteContext.ResourceEncoder

Implementation of the GraphMLParseContext.ResourceDecoder and GraphMLWriteContext.ResourceEncoder interfaces that (de)serialize Images to/from embedded Base64 encoded blocks.


Constructor Summary
ImageConverter()
           
 
Method Summary
protected  Image createOptimizedImage(int w, int h, BufferedImage bufferedImage)
          Create an optimized version of the raw image.
 Object decode(Node codeNode, GraphMLParseContext context)
          Decode an image from an embedded resource block.
 void encode(Object o, XmlWriter xmlWriter, GraphMLWriteContext context)
          Encode an image to an embedded Base64 resource block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageConverter

public ImageConverter()
Method Detail

decode

public Object decode(Node codeNode,
                     GraphMLParseContext context)
Decode an image from an embedded resource block.

Specified by:
decode in interface GraphMLParseContext.ResourceDecoder
Parameters:
codeNode - the xml node that encloses the encoded image resource
context - the current parse context.
Returns:
An image object, or null if the resource could not be decoded.
See Also:
createOptimizedImage(int,int,java.awt.image.BufferedImage)

createOptimizedImage

protected Image createOptimizedImage(int w,
                                     int h,
                                     BufferedImage bufferedImage)
Create an optimized version of the raw image. Since buffered images that get created by the usual IO methods may have serious performance impacts, this method can be used to create a platform dependent speed optimized version of the image.

This implementation retrieves the default GraphicsConfiguration for the current environment and paints to an image created by GraphicsConfiguration.createCompatibleImage(int,int,int).

Parameters:
w -
h -
bufferedImage -
Returns:
an image created from bufferedImage that is optimized for

encode

public void encode(Object o,
                   XmlWriter xmlWriter,
                   GraphMLWriteContext context)
Encode an image to an embedded Base64 resource block. This method only writes the content of the resource block, since the surrounding tags need to be configured by the calling context.

Specified by:
encode in interface GraphMLWriteContext.ResourceEncoder
Parameters:
o -
xmlWriter -
context -


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