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
 void addRenderingHint(RenderingHints.Key key, Object value)
          Adds a rendering hint key-value-pair, that is passed to the underlying rendering subsystem.
 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 document that is used as factory for the nodes in the DOM tree of the SVG that is generated by this SVGIOHandler instance.
protected  GraphicsContext createGraphicsContext(Graph2DView view, Graphics2D g2d)
          Creates the GraphicsContext that will be used for the graphics object while rendering to the SVG document.
 Graph2DView getActiveGraph2DView()
           
 Document getDocument()
          Returns the document that is used as factory for the nodes in the DOM tree of the SVG that is generated by this SVGIOHandler instance.
 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 removeRenderingHint(RenderingHints.Key key)
          Removes a rendering hint key-value-pair, so that it is no longer passed to the underlying rendering subsystem.
 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)

addRenderingHint

public void addRenderingHint(RenderingHints.Key key,
                             Object value)
Adds a rendering hint key-value-pair, that is passed to the underlying rendering subsystem.

Parameters:
key - the key of the hint to be set
value - the value indicating preferences for the specified hint category

removeRenderingHint

public void removeRenderingHint(RenderingHints.Key key)
Removes a rendering hint key-value-pair, so that it is no longer passed to the underlying rendering subsystem.

Parameters:
key - the key of the hint to be remove

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 document that is used as factory for the nodes in the DOM tree of the SVG that is generated by this SVGIOHandler instance.

Called from getDocument().

See Also:
getDocument()

getDocument

public Document getDocument()
Returns the document that is used as factory for the nodes in the DOM tree of the SVG that is generated by this SVGIOHandler instance.

Note: Adding nodes to this document will have no effect regarding the SVG that is generated by this SVGIOHandler instance. SVGDOMEnhancer may be used to manipulate the DOM tree of the generated SVG.

See Also:
SVGDOMEnhancer

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)

createGraphicsContext

protected GraphicsContext createGraphicsContext(Graph2DView view,
                                                Graphics2D g2d)
Creates the GraphicsContext that will be used for the graphics object while rendering to the SVG document. This implementation sets the GraphicsContext.isExportPainting() property to true.

Parameters:
view - the view that will be used for the painting.
g2d - the graphics object to use for the painting
Returns:
the context to register with the graphics object or null.

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 2002-2015,
yWorks GmbH.
All rights reserved.