com.yworks.yfiles.server.svg
Class SVGIdRewriteGraphVisitor

java.lang.Object
  extended bycom.yworks.yfiles.server.svg.SVGIdRewriteGraphVisitor
All Implemented Interfaces:
SVGGraphVisitor

public class SVGIdRewriteGraphVisitor
extends Object
implements SVGGraphVisitor

This implementation of SVGGraphVisitor rewrites all IDs in the SVG document to include a prefix. The prefix is retrieved from the SVGRenderContext.getIdPrefix() method.


Constructor Summary
SVGIdRewriteGraphVisitor(SVGRenderContext ctx)
          Creates a new SVGIDRewriteGraphVisitor for the given context.
 
Method Summary
protected  String createNewId(String oldId)
          Creates a new ID given the old one.
 void visitAttribute(Attr attr)
          Replaces ID values with a prefixed version.
 void visitNode(Node node)
          Does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGIdRewriteGraphVisitor

public SVGIdRewriteGraphVisitor(SVGRenderContext ctx)
Creates a new SVGIDRewriteGraphVisitor for the given context.

Parameters:
ctx - The context
Method Detail

createNewId

protected String createNewId(String oldId)
Creates a new ID given the old one. This method can be overriden to customize it.

Parameters:
oldId - Can be either the actual ID or a Pattern replacement string (i.e. "$1")
Returns:
The new ID

visitNode

public final void visitNode(Node node)
Does nothing.

Specified by:
visitNode in interface SVGGraphVisitor
Parameters:
node - The node

visitAttribute

public final void visitAttribute(Attr attr)
Replaces ID values with a prefixed version. This method handles the "id" attribute by replacing its value with a prefixed one, and can also handle the "xlink:href" attribute as well as any other attribute that contains a "url(#someid)" reference as its value.

Specified by:
visitAttribute in interface SVGGraphVisitor
Parameters:
attr - The attribute whose value might be rewritten.


Copyright © 2006-2013 yWorks GmbH. All rights reserved