yext.svg.io
Class SVGIOHandler

java.lang.Object
  extended by y.io.IOHandler
      extended by yext.svg.io.SVGIOHandler
Direct Known Subclasses:
SVGZIOHandler

public class SVGIOHandler
extends IOHandler

Writes a Graph2D in SVG vector graphics format.

The size, viewport and zoom level of the output will be determined by the Graph2DView associated with the input graph.

The output SVG can be enhanced by providing a specialized implementation of SVGGraph2DRenderer.

See Also:
Graph2DView, SVGGraph2DRenderer

Constructor Summary
SVGIOHandler()
          Instantiates a new SVGIOHandler.
 
Method Summary
 boolean canRead()
          Returns false, since this class can't read a graph.
 Graph2DView createDefaultGraph2DView(Graph2D graph)
          Creates the default view used as rendering context of this output handler in case there is no current view associated with the graph2D.
protected  Document createDocument()
          Creates the xml document that will serve as internal representation of the SVG output.
 Graph2DView getActiveGraph2DView()
           
 Document getDocument()
          Returns the xml document that will serve as internal representation of the SVG output.
 String getFileFormatString()
          Returns the SVG file format string.
 String getFileNameExtension()
          Returns the SVG file name extension, i.e.
 Graph2DView getGraph2DView()
           
 SVGGraph2DRenderer getSVGGraph2DRenderer()
          Returns the SVGGraph2DRenderer that will be used to render the graph.
 Object getSVGRenderingHintValue()
          Returns the preferred rendering mode to be used when exporting SVG enhanced content (i.e.
 boolean isCanvasSizeAssigned()
          Returns whether or not the <svg> element of the generated file will have the canvas width and height assigned.
 boolean isUseCSS()
          Returns true if SVG element attributes will be generated as a single CSS style attribute.
 void read(Graph2D graph, InputStream in)
          Throws always an UnsupportedOperationException, since canRead() == false.
 void setCanvasSizeAssigned(boolean canvasSizeAssigned)
          Sets whether or not the <svg> element of the generated file will have the canvas width and height assigned.
 void setGraph2DView(Graph2DView viewPort)
           
 void setSVGGraph2DRenderer(SVGGraph2DRenderer renderer)
          Sets the SVGGraph2DRenderer that will be used to render the graph.
 void setSVGRenderingHintValue(Object value)
          Specifies the preferred rendering mode to be used when exporting SVG enhanced content (i.e.
 void setUseCSS(boolean useCSS)
          Specifies whether SVG element attributes should be generated as a single CSS style attribute.
 void write(Graph2D graph, OutputStream out)
           
 
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

SVGIOHandler

public SVGIOHandler()
Instantiates a new SVGIOHandler.

Method Detail

getFileFormatString

public String getFileFormatString()
Returns the SVG file format string.

Specified by:
getFileFormatString in class IOHandler

getFileNameExtension

public String getFileNameExtension()
Returns the SVG file name extension, i.e. "gif"

Specified by:
getFileNameExtension in class IOHandler

canRead

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

Overrides:
canRead in class IOHandler

setSVGGraph2DRenderer

public void setSVGGraph2DRenderer(SVGGraph2DRenderer renderer)
Sets the SVGGraph2DRenderer that will be used to render the graph. Specialized renderers serve as a means to enhance the SVG output many ways, e.g. hyperlinks, rollover effects, ...


getSVGGraph2DRenderer

public SVGGraph2DRenderer getSVGGraph2DRenderer()
Returns the SVGGraph2DRenderer that will be used to render the graph.

See Also:
setSVGGraph2DRenderer(yext.svg.io.SVGGraph2DRenderer)

getSVGRenderingHintValue

public Object getSVGRenderingHintValue()
Returns the preferred rendering mode to be used when exporting SVG enhanced content (i.e. when exporting objects that delegate painting to SVGModel).

Returns:
an object which is compatible with SVGModel.KEY_SVG_RENDERING
See Also:
SVGModel.KEY_SVG_RENDERING, SVGModel.VALUE_SVG_RENDERING_DEFAULT, SVGModel.VALUE_SVG_RENDERING_FORCE_RASTERIZATION, SVGModel.VALUE_SVG_RENDERING_FORCE_VECTORIZATION

setSVGRenderingHintValue

public void setSVGRenderingHintValue(Object value)
Specifies the preferred rendering mode to be used when exporting SVG enhanced content (i.e. when exporting objects that delegate painting to SVGModel). The specified value has to be compatible with SVGModel.KEY_SVG_RENDERING. If the specified value is null, it is silently treated as SVGModel.VALUE_SVG_RENDERING_DEFAULT. The default setting for SVGRenderingHintValue is SVGModel.VALUE_SVG_RENDERING_FORCE_VECTORIZATION.

Parameters:
value - the SVG rendering hint value
Throws:
IllegalArgumentException - iff the specified value is not compatible with SVGModel.KEY_SVG_RENDERING
See Also:
SVGModel.KEY_SVG_RENDERING, SVGModel.VALUE_SVG_RENDERING_DEFAULT, SVGModel.VALUE_SVG_RENDERING_FORCE_RASTERIZATION, SVGModel.VALUE_SVG_RENDERING_FORCE_VECTORIZATION

isUseCSS

public boolean isUseCSS()
Returns true if SVG element attributes will be generated as a single CSS style attribute.

Returns:
true if SVG element attributes will be generated as a single CSS style attribute; false otherwise.

setUseCSS

public void setUseCSS(boolean useCSS)
Specifies whether SVG element attributes should be generated as a single CSS style attribute.

Parameters:
useCSS - if true SVG element attributes are generated as a single CSS style attribute.

getActiveGraph2DView

public Graph2DView getActiveGraph2DView()

read

public void read(Graph2D graph,
                 InputStream in)
          throws IOException
Throws always an UnsupportedOperationException, since canRead() == false.

Specified by:
read in class IOHandler
Throws:
IOException

write

public void write(Graph2D graph,
                  OutputStream out)
           throws IOException
Specified by:
write in class IOHandler
Throws:
IOException

createDocument

protected Document createDocument()
Creates the xml document that will serve as internal representation of the SVG output.


getDocument

public Document getDocument()
Returns the xml document that will serve as internal representation of the SVG output.


createDefaultGraph2DView

public Graph2DView createDefaultGraph2DView(Graph2D graph)
Creates the default view used as rendering context of this output handler 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)

setGraph2DView

public void setGraph2DView(Graph2DView viewPort)

getGraph2DView

public Graph2DView getGraph2DView()

isCanvasSizeAssigned

public boolean isCanvasSizeAssigned()
Returns whether or not the <svg> element of the generated file will have the canvas width and height assigned.

By default the canvas size will be assigned.


setCanvasSizeAssigned

public void setCanvasSizeAssigned(boolean canvasSizeAssigned)
Sets whether or not the <svg> element of the generated file will have the canvas width and height assigned.

By default the canvas size will be assigned.


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