Package org.eclipse.nebula.cwt.svg
Class SvgDocument
- java.lang.Object
-
- org.eclipse.nebula.cwt.svg.SvgElement
-
- org.eclipse.nebula.cwt.svg.SvgGraphic
-
- org.eclipse.nebula.cwt.svg.SvgContainer
-
- org.eclipse.nebula.cwt.svg.SvgDocument
-
public class SvgDocument extends SvgContainer
The SvgDocument is the base for all svg graphics. It is used to load an svg document from an inputstream or directly from a String.
An svg document may contain one or more svg fragments, each of which can be accessed individually.
See also: http://www.w3.org/TR/SVG
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,SvgFragment>fragmentMap-
Fields inherited from class org.eclipse.nebula.cwt.svg.SvgContainer
elements
-
Fields inherited from class org.eclipse.nebula.cwt.svg.SvgGraphic
description, fill, stroke, title, transform
-
-
Constructor Summary
Constructors Constructor Description SvgDocument()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidadd(SvgElement element)voidapply(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds)Apply this svg document to the given graphics context, scaled to fit within the given bounds.java.lang.StringgetDescription()Returns the value of thedescelement that is a child of this svg element.SvgFragmentgetFragment()SvgFragmentgetFragment(java.lang.String id)Returns the SvgFragment element within this document that corresponds to the given id.SvgFragment[]getFragments()Returns an array of all the SvgFragment elements contained by this document.java.lang.StringgetTitle()Returns the value of thetitleelement that is a child of this svg element.booleanhasFragment(java.lang.String id)Returns true if this document contains an SvgFragment with the given id.booleanisEmpty()Returns true if this list contains no elements.static SvgDocumentload(java.io.InputStream in)Create a new SvgDocument from the contents of the givenInputStream.static SvgDocumentload(java.lang.String src)Create a new SvgDocument from the contents of the givenString.-
Methods inherited from class org.eclipse.nebula.cwt.svg.SvgContainer
apply, getElements
-
Methods inherited from class org.eclipse.nebula.cwt.svg.SvgGraphic
getFill, getStroke, getTransform
-
Methods inherited from class org.eclipse.nebula.cwt.svg.SvgElement
getAncestry, getContainer, getElement, getId, getViewport, setContainer
-
-
-
-
Field Detail
-
fragmentMap
private java.util.Map<java.lang.String,SvgFragment> fragmentMap
-
-
Method Detail
-
load
public static SvgDocument load(java.io.InputStream in)
Create a new SvgDocument from the contents of the givenInputStream.- Parameters:
in- anInputStreamcontaining the svg source.- Returns:
- a newly created SvgDocument
-
load
public static SvgDocument load(java.lang.String src)
Create a new SvgDocument from the contents of the givenString.- Parameters:
src- anStringcontaining the svg source.- Returns:
- a newly created SvgDocument
-
add
void add(SvgElement element)
- Overrides:
addin classSvgContainer
-
apply
public void apply(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds)Apply this svg document to the given graphics context, scaled to fit within the given bounds. This method will recursive call the apply methods of all contained svg elements, thereby painting the entire document to the given graphics context.- Parameters:
gc- the graphics contextbounds- the bounds to which this document will be scaled
-
getDescription
public java.lang.String getDescription()
Description copied from class:SvgGraphicReturns the value of thedescelement that is a child of this svg element. If there is nodescelement that is a direct decendent of this element, null is returned.- Overrides:
getDescriptionin classSvgGraphic- Returns:
- the
descof this svg element
-
getFragment
public SvgFragment getFragment()
- Overrides:
getFragmentin classSvgElement
-
getFragment
public SvgFragment getFragment(java.lang.String id)
Returns the SvgFragment element within this document that corresponds to the given id.- Parameters:
id-- Returns:
- an SvgFragment with the given id, or null if one does not exist
-
getFragments
public SvgFragment[] getFragments()
Returns an array of all the SvgFragment elements contained by this document. This is a new array - modification to it will not affect the underlying collection.- Returns:
- an array of SvgFragments
-
getTitle
public java.lang.String getTitle()
Description copied from class:SvgGraphicReturns the value of thetitleelement that is a child of this svg element. If there is notitleelement that is a direct decendent of this element, null is returned.- Overrides:
getTitlein classSvgGraphic- Returns:
- the
titleof this svg element
-
hasFragment
public boolean hasFragment(java.lang.String id)
Returns true if this document contains an SvgFragment with the given id.- Parameters:
id- the id of the fragment- Returns:
- true if the fragment exists, false otherwise
-
isEmpty
public boolean isEmpty()
Description copied from class:SvgContainerReturns true if this list contains no elements.- Overrides:
isEmptyin classSvgContainer- Returns:
- true if this list contains no elements.
-
-