org.tinyjee.maven.dim.extensions
Class SvgLoader

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Object>
          extended by org.tinyjee.maven.dim.extensions.SvgLoader
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class SvgLoader
extends HashMap<String,Object>

SvgLoader is a 'source-class' compatible helper class that can load and transform SVG content and include it either directly or rendered as PNG.

The loader is an extension of XmlLoader and supports remote URLs (e.g. services) and local paths to get the SVG source content.

Usage:

%{include|source=template.vm|source-class=org.tinyjee.maven.dim.extensions.SvgLoader|svg=file.svg}
or when using the alias:
%{include|source=template.vm|source-svg=file.svg}
include SVG after XSL transformation:
%{include|source-svg=file.xml|xsl=transform-to-svg.xsl}

Author:
Juergen_Kellerer, 2011-10-06
See Also:
Serialized Form

Nested Class Summary
static class SvgLoader.AliasHandler
          Implements the "PARAM_ALIAS" alias functionality.
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
static String OUT_PARAM_DOCUMENT
          Is set with the parsed document object (Document) and can be accessed from velocity templates.
static String OUT_PARAM_XPATH
          Is set with an XPath evaluator, see XmlLoader for details.
static String PARAM_ALIAS
          Defines a shortcut for the request properties 'source-class' and 'svg'.
static String PARAM_ATTACH
          Specifies whether the SVG is attached to the page (instead of copied straight to the document).
static String PARAM_HEIGHT
          Optional Parameter, sets the height in pixel.
static String PARAM_RENDER
          Specifies whether the SVG is rendered to an image and included.
static String PARAM_RENDER_BACKGROUND
          Specifies a background color to use when rendering an SVG to an image.
static String PARAM_RENDER_MEDIA
          Specifies the CSS media when rendering an SVG containing CSS stylesheets with alternating media styles.
static String PARAM_SVG
          Sets the URL or local path to the SVG file to load inside the request parameters.
static String PARAM_WIDTH
          Optional Parameter, sets the width in pixel.
static String PARAM_XSL
          Optional Parameter, transform the given input (e.g.
 
Constructor Summary
SvgLoader(File baseDir, Map<String,Object> requestParams)
           
 
Method Summary
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

PARAM_ALIAS

public static final String PARAM_ALIAS
Defines a shortcut for the request properties 'source-class' and 'svg'.

If this parameter is present inside the request parameters list, the system will effectively behave as if 'source-class' and 'svg' where set separately.

See Also:
Constant Field Values

PARAM_SVG

public static final String PARAM_SVG
Sets the URL or local path to the SVG file to load inside the request parameters.

The specified file is resolved in exactly the same way as when using the parameter "source" (see Macro reference).

Note: When no further source is specified, the svg loader uses a built-in template to add the SVG to the output as image using Apache Batik to render it.

See Also:
Constant Field Values

PARAM_XSL

public static final String PARAM_XSL
Optional Parameter, transform the given input (e.g. XML) to an SVG file using an XML stylesheet.

See XmlLoader for details.

See Also:
Constant Field Values

PARAM_WIDTH

public static final String PARAM_WIDTH
Optional Parameter, sets the width in pixel.

See Also:
Constant Field Values

PARAM_HEIGHT

public static final String PARAM_HEIGHT
Optional Parameter, sets the height in pixel.

See Also:
Constant Field Values

PARAM_RENDER

public static final String PARAM_RENDER
Specifies whether the SVG is rendered to an image and included.

Possible values:

See Also:
Constant Field Values

PARAM_RENDER_BACKGROUND

public static final String PARAM_RENDER_BACKGROUND
Specifies a background color to use when rendering an SVG to an image.

See Also:
Constant Field Values

PARAM_RENDER_MEDIA

public static final String PARAM_RENDER_MEDIA
Specifies the CSS media when rendering an SVG containing CSS stylesheets with alternating media styles.

E.g. "print", "screen"

See Also:
Constant Field Values

PARAM_ATTACH

public static final String PARAM_ATTACH
Specifies whether the SVG is attached to the page (instead of copied straight to the document).

Possible values:

Note: When an SVG is attached, it cannot be further processed by velocity, thus any velocity expressions inside the included SVG are only processed with inline SVG graphics and the addition of the macro parameter "source-is-template=true".

See Also:
Constant Field Values

OUT_PARAM_DOCUMENT

public static final String OUT_PARAM_DOCUMENT
Is set with the parsed document object (Document) and can be accessed from velocity templates.

See Also:
Constant Field Values

OUT_PARAM_XPATH

public static final String OUT_PARAM_XPATH
Is set with an XPath evaluator, see XmlLoader for details.

See Also:
Constant Field Values
Constructor Detail

SvgLoader

public SvgLoader(File baseDir,
                 Map<String,Object> requestParams)
          throws Exception
Throws:
Exception