fr.inria.zvtm.svg
Class SVGReader

java.lang.Object
  extended by fr.inria.zvtm.svg.SVGReader

public class SVGReader
extends Object

An SVG interpreter for ZVTM. For now SVGReader covers a very limited subset of the specification. Enough to interpret GraphViz layout programs' SVG output (Ellipse, Text, Path, Rectangle, Circle, limited support for Polygon and Image). The goal is to have it support at least SVG Tiny.

Author:
Emmanuel Pietriga

Field Summary
static String _a
           
static String _circle
           
static String _class
           
static String _cx
           
static String _cy
           
static String _d
           
static String _ellipse
           
static String _end
           
static String _fill
           
static String _fillCSS
           
static String _fillopacity
           
static String _fillopacityCSS
           
static String _fontfamily
           
static String _fontfamilyCSS
           
static String _fontsize
           
static String _fontsizeCSS
           
static String _fontstyle
           
static String _fontstyleCSS
           
static String _fontweight
           
static String _fontweightCSS
           
static String _g
           
static String _height
           
static String _href
           
static String _id
           
static String _image
           
static String _inherit
           
static String _line
           
static String _middle
           
static String _path
           
static String _points
           
static String _polygon
           
static String _polyline
           
static String _pt
           
static String _r
           
static String _rect
           
static String _rx
           
static String _ry
           
static String _start
           
static String _stroke
           
static String _strokeCSS
           
static String _strokedasharray
           
static String _strokedasharrayCSS
           
static String _strokewidth
           
static String _strokewidthCSS
           
static String _style
           
static String _text
           
static String _textanchor
           
static String _title
           
static String _transform
           
static String _translate
           
static String _viewBox
           
static String _width
           
static String _x
           
static String _x1
           
static String _x2
           
static String _y
           
static String _y1
           
static String _y2
           
static String COMMA_SEP
           
static String EMPTY_STRING
           
static String FILE_PROTOCOL
           
static String FILE_SCHEME
           
static String HTTP_SCHEME
           
static String LINE_SEP
           
static float RRARCR
           
protected static String SOLID_DASH_PATTERN
           
static String SPACE_SEP
           
protected static Hashtable strokes
           
static String xlinkURI
           
 
Constructor Summary
SVGReader()
           
 
Method Summary
static void assignStroke(Glyph g, SVGStyle ss)
           
static boolean checkSVGPath(String svg)
          Check that an SVG path expression is supported by ZVTM.
static VCircle createCircle(Element e)
          Create a VCircle from an SVG circle element.
static VCircle createCircle(Element e, Context ctx)
          Create a VCircle from an SVG circle element.
static VCircle createCircle(Element e, Context ctx, boolean meta)
          Create a VCircle from an SVG circle element.
static VEllipse createEllipse(Element e)
          Create a VEllipse from an SVG ellipse element.
static VEllipse createEllipse(Element e, Context ctx)
          Create a VEllipse from an SVG ellipse element.
static VEllipse createEllipse(Element e, Context ctx, boolean meta)
          Create a VEllipse from an SVG ellipse element.
static Glyph createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL)
          Create a VImage from an SVG image element.
static VImage createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL, String fallbackParentURL)
          Create a VImage from an SVG image element.
static VSegment createLine(Element e)
          Create a VSegment from an SVG line element.
static VSegment createLine(Element e, Context ctx)
          Create a VSegment from an SVG line element.
static VSegment createLine(Element e, Context ctx, boolean meta)
          Create a VSegment from an SVG line element.
static DPath createPath(Element e, DPath ph)
          Create a DPath from an SVG text element.
static DPath createPath(Element e, DPath ph, Context ctx)
          Create a DPath from an SVG text element.
static DPath createPath(Element e, DPath ph, Context ctx, boolean meta)
          Create a DPath from an SVG text element.
static DPath createPath(String d, DPath ph)
          Create a DPath from an SVG text element.
static DPath createPath(String d, DPath ph, Context ctx)
          Create a DPath from an SVG text element.
static DPath createPath(String d, DPath ph, Context ctx, boolean meta)
          Create a DPath from an SVG text element.
static VPolygon createPolygon(Element e)
          Create a VPolygon from an SVG polygon element.
static VPolygon createPolygon(Element e, Context ctx)
          Create a VPolygon from an SVG polygon element.
static VPolygon createPolygon(Element e, Context ctx, boolean meta)
          Create a VPolygon from an SVG polygon element.
static VSegment[] createPolyline(Element e)
          Create a set of VSegments from an SVG polyline element.
static VSegment[] createPolyline(Element e, Context ctx)
          Create a set of VSegments from an SVG polyline element.
static VSegment[] createPolyline(Element e, Context ctx, boolean meta)
          Create a set of VSegments from an SVG polyline element.
static VRectangleOr createRectangle(Element e)
          Create a VRectangle from an SVG rect element.
static VRectangleOr createRectangle(Element e, Context ctx)
          Create a VRectangle from an SVG rect element.
static VRectangleOr createRectangle(Element e, Context ctx, boolean meta)
          Create a VRectangle from an SVG rect element.
static VRectangleOr createRectangleFromPolygon(Element e)
          Create a VRectangle from an SVG polygon element.
static VRectangleOr createRectangleFromPolygon(Element e, Context ctx)
          Create a VRectangle from an SVG polygon element.
static VRectangleOr createRectangleFromPolygon(Element e, Context ctx, boolean meta)
          Create a VRectangle from an SVG polygon element.
static VRoundRect createRoundRectFromPolygon(Element e)
          Create a VRoundRect from an SVG polygon element.
static VRoundRect createRoundRectFromPolygon(Element e, Context ctx)
          Create a VRoundRect from an SVG polygon element.
static VRoundRect createRoundRectFromPolygon(Element e, Context ctx, boolean meta)
          Create a VRoundRect from an SVG polygon element.
static VText createText(Element e)
          Create a VText from an SVG text element.
static VText createText(Element e, Context ctx)
          Create a VText from an SVG text element.
static VText createText(Element e, Context ctx, boolean meta)
          Create a VText from an SVG text element.
static Color getColor(String s)
          Get the Java Color instance corresponding to an SVG string representation of that color.
static Font getFont(String fontFamily, int fontStyle, int fontSize)
          Returns the Font object corresponding to the provided description.
static Point2D.Double getPositionOffset()
          Get the position offset.
static SVGStyle getStyle(String s, Element e)
          Parse style information.
static boolean isRectangle(Vector<Point2D.Double> v)
          Tells whether the 4 points contained in a Vector form a rectangle or not.
static void load(Document d, VirtualSpace vs, boolean meta, String documentURL)
          Load a DOM-parsed SVG document d in VirtualSpace vs.
static void load(Document d, VirtualSpace vs, boolean meta, String documentURL, String fallbackParentURL)
          Load a DOM-parsed SVG document d in VirtualSpace vs.
static void setPositionOffset(double dx, double dy)
          Set position offset.
static void translateSVGPolygon(String s, Vector<Point2D.Double> res)
          Translate an SVG polygon coordinates from the SVG space to the ZVTM space, taking position offset into account.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_polyline

public static final String _polyline
See Also:
Constant Field Values

_line

public static final String _line
See Also:
Constant Field Values

_rect

public static final String _rect
See Also:
Constant Field Values

_image

public static final String _image
See Also:
Constant Field Values

_ellipse

public static final String _ellipse
See Also:
Constant Field Values

_circle

public static final String _circle
See Also:
Constant Field Values

_path

public static final String _path
See Also:
Constant Field Values

_text

public static final String _text
See Also:
Constant Field Values

_polygon

public static final String _polygon
See Also:
Constant Field Values

_g

public static final String _g
See Also:
Constant Field Values

_a

public static final String _a
See Also:
Constant Field Values

_title

public static final String _title
See Also:
Constant Field Values

_fill

public static final String _fill
See Also:
Constant Field Values

_stroke

public static final String _stroke
See Also:
Constant Field Values

_strokewidth

public static final String _strokewidth
See Also:
Constant Field Values

_strokedasharray

public static final String _strokedasharray
See Also:
Constant Field Values

_fillopacity

public static final String _fillopacity
See Also:
Constant Field Values

_fontfamily

public static final String _fontfamily
See Also:
Constant Field Values

_fontsize

public static final String _fontsize
See Also:
Constant Field Values

_fontweight

public static final String _fontweight
See Also:
Constant Field Values

_fontstyle

public static final String _fontstyle
See Also:
Constant Field Values

_fillCSS

public static final String _fillCSS
See Also:
Constant Field Values

_strokeCSS

public static final String _strokeCSS
See Also:
Constant Field Values

_strokewidthCSS

public static final String _strokewidthCSS
See Also:
Constant Field Values

_strokedasharrayCSS

public static final String _strokedasharrayCSS
See Also:
Constant Field Values

_fillopacityCSS

public static final String _fillopacityCSS
See Also:
Constant Field Values

_fontfamilyCSS

public static final String _fontfamilyCSS
See Also:
Constant Field Values

_fontsizeCSS

public static final String _fontsizeCSS
See Also:
Constant Field Values

_fontweightCSS

public static final String _fontweightCSS
See Also:
Constant Field Values

_fontstyleCSS

public static final String _fontstyleCSS
See Also:
Constant Field Values

_style

public static final String _style
See Also:
Constant Field Values

_class

public static final String _class
See Also:
Constant Field Values

_cx

public static final String _cx
See Also:
Constant Field Values

_cy

public static final String _cy
See Also:
Constant Field Values

_rx

public static final String _rx
See Also:
Constant Field Values

_ry

public static final String _ry
See Also:
Constant Field Values

_r

public static final String _r
See Also:
Constant Field Values

_d

public static final String _d
See Also:
Constant Field Values

_x

public static final String _x
See Also:
Constant Field Values

_y

public static final String _y
See Also:
Constant Field Values

_x1

public static final String _x1
See Also:
Constant Field Values

_y1

public static final String _y1
See Also:
Constant Field Values

_x2

public static final String _x2
See Also:
Constant Field Values

_y2

public static final String _y2
See Also:
Constant Field Values

_width

public static final String _width
See Also:
Constant Field Values

_height

public static final String _height
See Also:
Constant Field Values

_points

public static final String _points
See Also:
Constant Field Values

_textanchor

public static final String _textanchor
See Also:
Constant Field Values

_start

public static final String _start
See Also:
Constant Field Values

_middle

public static final String _middle
See Also:
Constant Field Values

_end

public static final String _end
See Also:
Constant Field Values

_inherit

public static final String _inherit
See Also:
Constant Field Values

_pt

public static final String _pt
See Also:
Constant Field Values

_id

public static final String _id
See Also:
Constant Field Values

_transform

public static final String _transform
See Also:
Constant Field Values

_translate

public static final String _translate
See Also:
Constant Field Values

_viewBox

public static final String _viewBox
See Also:
Constant Field Values

xlinkURI

public static final String xlinkURI
See Also:
Constant Field Values

_href

public static final String _href
See Also:
Constant Field Values

HTTP_SCHEME

public static final String HTTP_SCHEME
See Also:
Constant Field Values

FILE_SCHEME

public static final String FILE_SCHEME
See Also:
Constant Field Values

FILE_PROTOCOL

public static final String FILE_PROTOCOL
See Also:
Constant Field Values

EMPTY_STRING

public static final String EMPTY_STRING
See Also:
Constant Field Values

COMMA_SEP

public static final String COMMA_SEP
See Also:
Constant Field Values

SPACE_SEP

public static final String SPACE_SEP
See Also:
Constant Field Values

LINE_SEP

public static final String LINE_SEP
See Also:
Constant Field Values

RRARCR

public static float RRARCR

strokes

protected static Hashtable strokes

SOLID_DASH_PATTERN

protected static String SOLID_DASH_PATTERN
Constructor Detail

SVGReader

public SVGReader()
Method Detail

setPositionOffset

public static void setPositionOffset(double dx,
                                     double dy)
Set position offset. When this is set to something different than (0,0), all SVG objects will be translated by (dx,dy) in the ZVTM virtual space coordinates system. This can be useful if you do not want all objects of the SVG file to all be in the south-east quadrant of the virtual space. SVG files often use positive coordinates only, and their coordinate system is inversed (vertically) w.r.t ZVTM's coordinate system.


getPositionOffset

public static Point2D.Double getPositionOffset()
Get the position offset. (0,0) means no offset.


checkSVGPath

public static boolean checkSVGPath(String svg)
Check that an SVG path expression is supported by ZVTM. Verifies that all SVG commands are actually supported by ZVTM (M,m,L,l,H,h,V,v,C,c,Q,q)


getColor

public static Color getColor(String s)
Get the Java Color instance corresponding to an SVG string representation of that color. The SVG string representation of the color can be any of the values defined in Scalable Vector Graphics (SVG) 1.1 Specification, section 4.1: Basic data types.

Parameters:
s - string representation of a color (as an SVG style attribute)
Returns:
null if s is null or not a syntactically well-formed color

getStyle

public static SVGStyle getStyle(String s,
                                Element e)
Parse style information.

Parameters:
s - the value of an SVG style attribute. Supported declarations are: fill, fill-opacity, font-family, font-size, font-weight, font-style, stroke, stroke-dasharray, stroke-width
Returns:
styling attributes which can be interpreted by ZVTM

translateSVGPolygon

public static void translateSVGPolygon(String s,
                                       Vector<Point2D.Double> res)
Translate an SVG polygon coordinates from the SVG space to the ZVTM space, taking position offset into account.

Parameters:
s - the SVG list of coordinates (value of attribute points in polygon elements)
res - a Vector in which the result will be stored (this will be a vector of Point2D.Double)

assignStroke

public static void assignStroke(Glyph g,
                                SVGStyle ss)

isRectangle

public static boolean isRectangle(Vector<Point2D.Double> v)
Tells whether the 4 points contained in a Vector form a rectangle or not.

Parameters:
v - a vector of 4 Point2D.Double For this to return true, points 2 & 3 and points 1 & 4 have to be horizontally aligned. Moreother, points 1 & 2 and points 3 & 4 have to be vertically aligned.

createEllipse

public static VEllipse createEllipse(Element e)
Create a VEllipse from an SVG ellipse element.

Parameters:
e - an SVG ellipse as a DOM element (org.w3c.dom.Element)

createEllipse

public static VEllipse createEllipse(Element e,
                                     Context ctx)
Create a VEllipse from an SVG ellipse element.

Parameters:
e - an SVG ellipse as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createEllipse

public static VEllipse createEllipse(Element e,
                                     Context ctx,
                                     boolean meta)
Create a VEllipse from an SVG ellipse element.

Parameters:
e - an SVG ellipse as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createCircle

public static VCircle createCircle(Element e)
Create a VCircle from an SVG circle element.

Parameters:
e - an SVG circle as a DOM element (org.w3c.dom.Element)

createCircle

public static VCircle createCircle(Element e,
                                   Context ctx)
Create a VCircle from an SVG circle element.

Parameters:
e - an SVG circle as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createCircle

public static VCircle createCircle(Element e,
                                   Context ctx,
                                   boolean meta)
Create a VCircle from an SVG circle element.

Parameters:
e - an SVG circle as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createText

public static VText createText(Element e)
Create a VText from an SVG text element. Warning if text uses attribute text-anchor and has a value different from start, it will not be taken into account (it is up to you to place the text correctly, as it requires information about the View's graphicscontext to compute the string's width/height).

Parameters:
e - an SVG text as a DOM element (org.w3c.dom.Element)

createText

public static VText createText(Element e,
                               Context ctx)
Create a VText from an SVG text element. Warning if text uses attribute text-anchor and has a value different from start, it will not be taken into account (it is up to you to place the text correctly, as it requires information about the View's graphicscontext to compute the string's width/height).

Parameters:
e - an SVG text as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createText

public static VText createText(Element e,
                               Context ctx,
                               boolean meta)
Create a VText from an SVG text element. Warning if text uses attribute text-anchor and has a value different from start, it will not be taken into account (it is up to you to place the text correctly, as it requires information about the View's graphicscontext to compute the string's width/height).

Parameters:
e - an SVG text as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createRectangleFromPolygon

public static VRectangleOr createRectangleFromPolygon(Element e)
Create a VRectangle from an SVG polygon element. After checking this is actually a rectangle - returns null if not.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)

createRectangleFromPolygon

public static VRectangleOr createRectangleFromPolygon(Element e,
                                                      Context ctx)
Create a VRectangle from an SVG polygon element. After checking this is actually a rectangle - returns null if not.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createRectangleFromPolygon

public static VRectangleOr createRectangleFromPolygon(Element e,
                                                      Context ctx,
                                                      boolean meta)
Create a VRectangle from an SVG polygon element. After checking this is actually a rectangle - returns null if not.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createRoundRectFromPolygon

public static VRoundRect createRoundRectFromPolygon(Element e)
Create a VRoundRect from an SVG polygon element. After checking this is actually a rectangle - returns null if not.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)

createRoundRectFromPolygon

public static VRoundRect createRoundRectFromPolygon(Element e,
                                                    Context ctx)
Create a VRoundRect from an SVG polygon element. After checking this is actually a rectangle - returns null if not.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createRoundRectFromPolygon

public static VRoundRect createRoundRectFromPolygon(Element e,
                                                    Context ctx,
                                                    boolean meta)
Create a VRoundRect from an SVG polygon element. After checking this is actually a rectangle - returns null if not.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createRectangle

public static VRectangleOr createRectangle(Element e)
Create a VRectangle from an SVG rect element.

Parameters:
e - an SVG rect(angle) as a DOM element (org.w3c.dom.Element)

createRectangle

public static VRectangleOr createRectangle(Element e,
                                           Context ctx)
Create a VRectangle from an SVG rect element.

Parameters:
e - an SVG rect(angle) as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createRectangle

public static VRectangleOr createRectangle(Element e,
                                           Context ctx,
                                           boolean meta)
Create a VRectangle from an SVG rect element.

Parameters:
e - an SVG rect(angle) as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createImage

public static Glyph createImage(Element e,
                                Context ctx,
                                boolean meta,
                                Hashtable imageStore,
                                String documentParentURL)
Create a VImage from an SVG image element. This is a convenience method. An invocation of the form createImage(e, ctx, meta, imageStore, documentParentURL) behaves in exactly the same way as the invocation createImage(e, ctx, meta, imageStore, documentParentURL, null).

Parameters:
e - an SVG image as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object
imageStore - a simple hashtable (possibly empty at first) in which bitmap images will be stored so that they do not get loaded in memory multiple times.
documentParentURL - the URL of the parent directory containing the SVG/XML document. Provide an empty String if it is not know. This may however cause problems when retrieving bitmap images associated with this SVG document, unless there URL is expressed relative to the document's location.
See Also:
createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL, String fallbackParentURL)

createImage

public static VImage createImage(Element e,
                                 Context ctx,
                                 boolean meta,
                                 Hashtable imageStore,
                                 String documentParentURL,
                                 String fallbackParentURL)
Create a VImage from an SVG image element.

Parameters:
e - an SVG image as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object
imageStore - a simple hashtable (possibly empty at first) in which bitmap images will be stored so that they do not get loaded in memory multiple times.
documentParentURL - the URL of the parent directory containing the SVG/XML document. Provide an empty String if it is not know. This may however cause problems when retrieving bitmap images associated with this SVG document, unless there URL is expressed relative to the document's location.
fallbackParentURL - used to indicate a possible fallback directory from which to interpret relative paths in case documentParentURL is not the right place where to look for those images (this can happen e.g. if a file was generated somewhere and then moved alone, associated images staying in the original directory) ; set to null if no fallback directory is known.
See Also:
createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL)

createPolygon

public static VPolygon createPolygon(Element e)
Create a VPolygon from an SVG polygon element.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)

createPolygon

public static VPolygon createPolygon(Element e,
                                     Context ctx)
Create a VPolygon from an SVG polygon element.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createPolygon

public static VPolygon createPolygon(Element e,
                                     Context ctx,
                                     boolean meta)
Create a VPolygon from an SVG polygon element.

Parameters:
e - an SVG polygon as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createPolyline

public static VSegment[] createPolyline(Element e)
Create a set of VSegments from an SVG polyline element.

Parameters:
e - an SVG polyline as a DOM element (org.w3c.dom.Element)

createPolyline

public static VSegment[] createPolyline(Element e,
                                        Context ctx)
Create a set of VSegments from an SVG polyline element.

Parameters:
e - an SVG polyline as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createPolyline

public static VSegment[] createPolyline(Element e,
                                        Context ctx,
                                        boolean meta)
Create a set of VSegments from an SVG polyline element.

Parameters:
e - an SVG polyline as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createLine

public static VSegment createLine(Element e)
Create a VSegment from an SVG line element.

Parameters:
e - an SVG polyline as a DOM element (org.w3c.dom.Element)

createLine

public static VSegment createLine(Element e,
                                  Context ctx)
Create a VSegment from an SVG line element.

Parameters:
e - an SVG polyline as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)

createLine

public static VSegment createLine(Element e,
                                  Context ctx,
                                  boolean meta)
Create a VSegment from an SVG line element.

Parameters:
e - an SVG line as a DOM element (org.w3c.dom.Element)
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createPath

public static DPath createPath(Element e,
                               DPath ph)
Create a DPath from an SVG text element.

Parameters:
e - an SVG path as a DOM element (org.w3c.dom.Element)
ph - a DPath that is going to be modified to match the coordinates provided as first argument (you can simply use new DPath())

createPath

public static DPath createPath(Element e,
                               DPath ph,
                               Context ctx)
Create a DPath from an SVG text element.

Parameters:
e - an SVG path as a DOM element (org.w3c.dom.Element)
ph - a DPath that is going to be modified to match the coordinates provided as first argument (you can simply use new DPath())
ctx - used to propagate contextual style information (put null if none)

createPath

public static DPath createPath(Element e,
                               DPath ph,
                               Context ctx,
                               boolean meta)
Create a DPath from an SVG text element.

Parameters:
e - an SVG path as a DOM element (org.w3c.dom.Element)
ph - a DPath that is going to be modified to match the coordinates provided as first argument (you can simply use new DPath())
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

createPath

public static DPath createPath(String d,
                               DPath ph)
Create a DPath from an SVG text element.

Parameters:
d - the d attribute value of an SVG path
ph - a DPath that is going to be modified to match the coordinates provided as first argument (you can just use new DPath())

createPath

public static DPath createPath(String d,
                               DPath ph,
                               Context ctx)
Create a DPath from an SVG text element.

Parameters:
d - the d attribute value of an SVG path
ph - a DPath that is going to be modified to match the coordinates provided as first argument (you can just use new DPath())
ctx - used to propagate contextual style information (put null if none)

createPath

public static DPath createPath(String d,
                               DPath ph,
                               Context ctx,
                               boolean meta)
Create a DPath from an SVG text element.

Parameters:
d - the d attribute value of an SVG path
ph - a DPath that is going to be modified to match the coordinates provided as first argument (you can just use new DPath())
ctx - used to propagate contextual style information (put null if none)
meta - store metadata associated with this node (URL, title) in glyph's associated object

load

public static void load(Document d,
                        VirtualSpace vs,
                        boolean meta,
                        String documentURL)
Load a DOM-parsed SVG document d in VirtualSpace vs. This is a convenience method. An invocation of the form load(d, vs, meta, documentURL) behaves in exactly the same way as the invocation load(d, vs, meta, documentURL, null).

Parameters:
d - SVG document as a DOM tree
vs - virtual space
meta - store metadata associated with graphical elements (URL, title) in each Glyph's associated object
documentURL - the URL where the SVG/XML document was found. Provide an empty String if it is not know. This may however cause problems when retrieving bitmap images associated with this SVG document, unless there URL is expressed relative to the document's location.
See Also:
load(Document d, VirtualSpace vs, boolean meta, String documentURL, String fallbackParentURL)

load

public static void load(Document d,
                        VirtualSpace vs,
                        boolean meta,
                        String documentURL,
                        String fallbackParentURL)
Load a DOM-parsed SVG document d in VirtualSpace vs.

Parameters:
d - SVG document as a DOM tree
vs - virtual space
meta - store metadata associated with graphical elements (URL, title) in each Glyph's associated object
documentURL - the URL where the SVG/XML document was found. Provide an empty String if it is not know. This may however cause problems when retrieving bitmap images associated with this SVG document, unless there URL is expressed relative to the document's location.
fallbackParentURL - used to indicate a possible fallback directory from which to interpret relative paths in case the parent of documentURL is not the right place where to look for those images (this can happen e.g. if a file was generated somewhere and then moved alone, associated images staying in the original directory) ; set to null if no fallback directory is known.
See Also:
load(Document d, VirtualSpace vs, boolean meta, String documentURL)

getFont

public static Font getFont(String fontFamily,
                           int fontStyle,
                           int fontSize)
Returns the Font object corresponding to the provided description. The font is taken from the cache if in there, or created if not (and then stored for subsequent requests)

Parameters:
fontFamily - the font's family name as expected by AWT's Font constructor
fontStyle - the font's style (one of Font.{PLAIN, BOLD, ITALIC, BOLD+ITALIC})
fontSize - the font's size


Copyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2011 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.