public class SVGReader extends Object
Constructor and Description |
---|
SVGReader() |
Modifier and Type | Method and Description |
---|---|
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.
|
public static final String _polyline
public static final String _line
public static final String _rect
public static final String _image
public static final String _ellipse
public static final String _circle
public static final String _path
public static final String _text
public static final String _polygon
public static final String _g
public static final String _a
public static final String _title
public static final String _fill
public static final String _stroke
public static final String _strokewidth
public static final String _strokedasharray
public static final String _fillopacity
public static final String _fontfamily
public static final String _fontsize
public static final String _fontweight
public static final String _fontstyle
public static final String _fillCSS
public static final String _strokeCSS
public static final String _strokewidthCSS
public static final String _strokedasharrayCSS
public static final String _fillopacityCSS
public static final String _fontfamilyCSS
public static final String _fontsizeCSS
public static final String _fontweightCSS
public static final String _fontstyleCSS
public static final String _style
public static final String _class
public static final String _cx
public static final String _cy
public static final String _rx
public static final String _ry
public static final String _r
public static final String _d
public static final String _x
public static final String _y
public static final String _x1
public static final String _y1
public static final String _x2
public static final String _y2
public static final String _width
public static final String _height
public static final String _points
public static final String _textanchor
public static final String _start
public static final String _middle
public static final String _end
public static final String _inherit
public static final String _pt
public static final String _id
public static final String _transform
public static final String _translate
public static final String _viewBox
public static final String xlinkURI
public static final String _href
public static final String HTTP_SCHEME
public static final String FILE_SCHEME
public static final String FILE_PROTOCOL
public static final String EMPTY_STRING
public static final String COMMA_SEP
public static final String SPACE_SEP
public static final String LINE_SEP
public static float RRARCR
protected static Hashtable strokes
protected static String SOLID_DASH_PATTERN
public static void setPositionOffset(double dx, double dy)
public static Point2D.Double getPositionOffset()
public static boolean checkSVGPath(String svg)
public static Color getColor(String s)
s
- string representation of a color (as an SVG style attribute)public static SVGStyle getStyle(String s, Element e)
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-widthpublic static void translateSVGPolygon(String s, Vector<Point2D.Double> res)
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)public static boolean isRectangle(Vector<Point2D.Double> v)
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.public static VEllipse createEllipse(Element e)
e
- an SVG ellipse as a DOM element (org.w3c.dom.Element)public static VEllipse createEllipse(Element e, Context ctx)
e
- an SVG ellipse as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VEllipse createEllipse(Element e, Context ctx, boolean meta)
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 objectpublic static VCircle createCircle(Element e)
e
- an SVG circle as a DOM element (org.w3c.dom.Element)public static VCircle createCircle(Element e, Context ctx)
e
- an SVG circle as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VCircle createCircle(Element e, Context ctx, boolean meta)
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 objectpublic static VText createText(Element e)
e
- an SVG text as a DOM element (org.w3c.dom.Element)public static VText createText(Element e, Context ctx)
e
- an SVG text as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VText createText(Element e, Context ctx, boolean meta)
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 objectpublic static VRectangleOr createRectangleFromPolygon(Element e)
e
- an SVG polygon as a DOM element (org.w3c.dom.Element)public static VRectangleOr createRectangleFromPolygon(Element e, Context ctx)
e
- an SVG polygon as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VRectangleOr createRectangleFromPolygon(Element e, Context ctx, boolean meta)
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 objectpublic static VRoundRect createRoundRectFromPolygon(Element e)
e
- an SVG polygon as a DOM element (org.w3c.dom.Element)public static VRoundRect createRoundRectFromPolygon(Element e, Context ctx)
e
- an SVG polygon as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VRoundRect createRoundRectFromPolygon(Element e, Context ctx, boolean meta)
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 objectpublic static VRectangleOr createRectangle(Element e)
e
- an SVG rect(angle) as a DOM element (org.w3c.dom.Element)public static VRectangleOr createRectangle(Element e, Context ctx)
e
- an SVG rect(angle) as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VRectangleOr createRectangle(Element e, Context ctx, boolean meta)
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 objectpublic static Glyph createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL)
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 objectimageStore
- 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.createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL, String fallbackParentURL)
public static VImage createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL, String fallbackParentURL)
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 objectimageStore
- 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.createImage(Element e, Context ctx, boolean meta, Hashtable imageStore, String documentParentURL)
public static VPolygon createPolygon(Element e)
e
- an SVG polygon as a DOM element (org.w3c.dom.Element)public static VPolygon createPolygon(Element e, Context ctx)
e
- an SVG polygon as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VPolygon createPolygon(Element e, Context ctx, boolean meta)
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 objectpublic static VSegment[] createPolyline(Element e)
e
- an SVG polyline as a DOM element (org.w3c.dom.Element)public static VSegment[] createPolyline(Element e, Context ctx)
e
- an SVG polyline as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VSegment[] createPolyline(Element e, Context ctx, boolean meta)
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 objectpublic static VSegment createLine(Element e)
e
- an SVG polyline as a DOM element (org.w3c.dom.Element)public static VSegment createLine(Element e, Context ctx)
e
- an SVG polyline as a DOM element (org.w3c.dom.Element)ctx
- used to propagate contextual style information (put null if none)public static VSegment createLine(Element e, Context ctx, boolean meta)
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 objectpublic static DPath createPath(Element e, DPath ph)
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())public static DPath createPath(Element e, DPath ph, Context ctx)
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)public static DPath createPath(Element e, DPath ph, Context ctx, boolean meta)
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 objectpublic static DPath createPath(String d, DPath ph)
d
- the d attribute value of an SVG pathph
- a DPath that is going to be modified to match the coordinates provided as first argument (you can just use new DPath())public static DPath createPath(String d, DPath ph, Context ctx)
d
- the d attribute value of an SVG pathph
- 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)public static DPath createPath(String d, DPath ph, Context ctx, boolean meta)
d
- the d attribute value of an SVG pathph
- 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 objectpublic static void load(Document d, VirtualSpace vs, boolean meta, String documentURL)
d
- SVG document as a DOM treevs
- virtual spacemeta
- store metadata associated with graphical elements (URL, title) in each Glyph's associated objectdocumentURL
- 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.load(Document d, VirtualSpace vs, boolean meta, String documentURL, String fallbackParentURL)
public static void load(Document d, VirtualSpace vs, boolean meta, String documentURL, String fallbackParentURL)
d
- SVG document as a DOM treevs
- virtual spacemeta
- store metadata associated with graphical elements (URL, title) in each Glyph's associated objectdocumentURL
- 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.load(Document d, VirtualSpace vs, boolean meta, String documentURL)
public static Font getFont(String fontFamily, int fontStyle, int fontSize)
fontFamily
- the font's family name as expected by AWT's Font constructorfontStyle
- the font's style (one of Font.{PLAIN, BOLD, ITALIC, BOLD+ITALIC})fontSize
- the font's sizeCopyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2015 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.