Class TLcdSVGModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
ILcdModelDecoder
allows to decode SVG files to ILcdShape
.
Typically SVG documents are not directly decoded as models but rather used as styled icons to decorate existing models.
For that use case, consider using TLcdSVGIcon
instead.
This decoder does not decode object styling elements, nor transformations of the elements except for text rotations.
The decoder supports the Scalable Vector Graphics (SVG) format as described in:
Scalable Vector Graphics (SVG)
1.0 Specification W3C Candidate Recommendation 02 November 2000 http://www.w3.org/TR/2000/CR-SVG-20001102/
Additional to the SVG standard this class decodes points and arcbands.
The objects in the SVG file are decoded directly into shapes in ILcdSVGShapeFactory
implementations.
The implementations provided consider the coordinates as expressed in the model reference (see below).
Transformations to these elements are not taken into account, except for text rotations.
The table below shows how SVG tags are decoded to ILcdShape
objects. Every tag has a constant defined in
ILcdSVGConstants
.
SVG tag | constant | decoded as ... |
<circle> |
ILcdSVGConstants.CIRCLE
|
ILcdCircle
|
<polyline> |
ILcdSVGConstants.POLYLINE
|
ILcdPolyline
|
<line> |
ILcdSVGConstants.LINE
|
ILcdPolyline
|
<ellipse> |
ILcdSVGConstants.ELLIPSE
|
ILcdEllipse
|
<polygon> |
ILcdSVGConstants.POLYGON
|
ILcdPolygon
|
<path> |
ILcdSVGConstants.PATH
|
ILcdShape
|
<rect> |
ILcdSVGConstants.BOUNDS
|
ILcdBounds
|
<text> |
ILcdSVGConstants.TEXT
|
ILcdText
|
<g> |
ILcdSVGConstants.SHAPELIST
|
ILcdShapeList
|
If the default model reference is set to null, the method createModelReference
is
responsible for creating an ILcdModelReference
corresponding to the data to decode. The user can set a
ILcdModelReferenceDecoder
to specify the way of decoding the reference. If no
ILcdModelReference
is set, the method will use the TLcdModelReferenceFactory
and look for a
.ref file ( MODELREFERENCEFACTORY
). This method can be redefined in order, for
instance, to pop up a Dialog
asking the user to enter an ILcdModelReference
.
This class needs an ILcdInputStreamFactory
(which provides streams for decoding, which allows for
example to monitor the loading) and an ILcdSVGShapeFactoryFactory
(which creates a instance of
ILcdSVGShapeFactory
, needed to create ILcdShape
according to a set of properties). The
default settings are a BufferedInpusStream
and TLcdSVGUnStyledShapeFactoryFactory
, which
will create shapes without style.
The ILcdModelDescriptor
for this model can be created in 3 ways:
- a
ILcdModelDescriptorFactory
is set and the factory implementsILcdSVGModelDescriptorFactory
. This type of model descriptor factories can take into account the attributes of the root XML element. - a
ILcdModelDescriptorFactory
is set which does not implementILcdSVGModelDescriptorFactory
. The model descriptor will be based on the source name of the data. A display name and a type name will be derived from it. - no
ILcdModelDescriptorFactory
is set. ATLcdSVGModelDescriptor
will be set to the model. This model descriptor implementsILcdDataModelDescriptor
. It uses theTLcdDataModel
andTLcdDataType
instances defined inTLcdSVGDataTypes
. Note that theTLcdDataType
s defined in this class are primitive, and as such, the default implementation of theILcdSVGShapeFactory
will not create elements that implementILcdDataObject
.
This class decodes the SVG - XML files using SAX
This class requires a JAXP 1.1 XML parser implementation.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Deprecated.An interface for parsers of SVG data. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(String aSourceName) Deprecated.Checks if this source can be decoded.Deprecated.Decodes a svg file to aTLcdVectorModel
.protected ILcdModel
decode
(String aSourceName, TLcdSVGModelDecoder.ContentParser aParser) Deprecated.Decodes SVG data to a vector model.Deprecated.Gets the display name of the decoder.protected String
Deprecated.Returns the extension of files that can be decoded by this decoder.protected String
Deprecated.Returns the name of the grouping element for files decoded by this decoder.Deprecated.Gets the usedILcdInputStreamFactory
.Deprecated.Gets theILcdModelDescriptorFactory
of this decoder.Deprecated.Returns theILcdModelReferenceDecoder
used to decode a model reference based on the path to the file to decode.protected String
Deprecated.Returns the name of the expected root element for files decoded by this decoder.Deprecated.Get the usedILcdSVGShapeFactory
to this decoder.static boolean
Deprecated.This method has been deprecated.static void
setClassTraceOn
(boolean aClassTraceOn) Deprecated.This method has been deprecated.void
setCreateIndexedModel
(boolean aCreateIndexedModel) Deprecated.When true, this decoder will return anILcd2DBoundsIndexedModel
, if false aTLcdVectorModel
.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Deprecated.Set aILcdInputStreamFactory
to this decoder to manage the input.void
setModelDescriptorFactory
(ILcdModelDescriptorFactory aModelDescriptorFactory) Deprecated.Sets aILcdModelDescriptorFactory
to the decoder.void
setModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Deprecated.Set theILcdModelReferenceDecoder
used to decode a model reference based on the path to the file to decode.void
setSVGShapeFactoryFactory
(ILcdSVGShapeFactoryFactory aSVGShapeFactoryFactory) Deprecated.Set the implementation ofILcdSVGShapeFactory
, the default factory decodes only the shapes not the additional style information.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdSVGModelDecoder
public TLcdSVGModelDecoder()Deprecated.default constructor.
-
-
Method Details
-
getModelDescriptorFactory
Deprecated.Gets theILcdModelDescriptorFactory
of this decoder.- Returns:
- the used
ILcdModelDescriptorFactory
. - See Also:
-
setModelDescriptorFactory
Deprecated.Sets aILcdModelDescriptorFactory
to the decoder. When the model descriptor set implementsILcdSVGModelDescriptorFactory
, the attributes of the root element can also be taken into account to create the model descriptor.- Parameters:
aModelDescriptorFactory
- theILcdModelDescriptorFactory
- See Also:
-
setClassTraceOn
public static void setClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for all instances of this class. If the argument istrue
then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.- Parameters:
aClassTraceOn
- if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
-
isClassTraceOn
public static boolean isClassTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-
getDisplayName
Deprecated.Gets the display name of the decoder.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the display name for this decoder.
-
getModelReferenceDecoder
Deprecated.Returns theILcdModelReferenceDecoder
used to decode a model reference based on the path to the file to decode. The default value is aTLcdModelReferenceDecoder
object.- Returns:
- the
ILcdModelReferenceDecoder
. - See Also:
-
setModelReferenceDecoder
Deprecated.Set theILcdModelReferenceDecoder
used to decode a model reference based on the path to the file to decode.- Parameters:
aModelReferenceDecoder
- theILcdModelReferenceDecoder
to retrieve a model reference for models decoded with this decoder.- See Also:
-
canDecodeSource
Deprecated.Checks if this source can be decoded.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- aString
with the path of the file to decode.- Returns:
- true if the argument contains
MODELTYPE
- See Also:
-
getFileExtension
Deprecated.Returns the extension of files that can be decoded by this decoder.- Returns:
- the extension of files that can be decoded by this decoder.
- See Also:
-
setCreateIndexedModel
public void setCreateIndexedModel(boolean aCreateIndexedModel) Deprecated.When true, this decoder will return anILcd2DBoundsIndexedModel
, if false aTLcdVectorModel
.- Parameters:
aCreateIndexedModel
- true to create aILcd2DBoundsIndexedModel
.
-
getInputStreamFactory
Deprecated.Gets the usedILcdInputStreamFactory
.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the used implementation of
ILcdInputStreamFactory
. - See Also:
-
setInputStreamFactory
Deprecated.Set aILcdInputStreamFactory
to this decoder to manage the input. A default factory is set.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- aILcdInpuStreamFactory
to be used.- See Also:
-
getSVGShapeFactoryFactory
Deprecated.Get the usedILcdSVGShapeFactory
to this decoder.- Returns:
- the used implementation of
ILcdShapeFactory
- See Also:
-
setSVGShapeFactoryFactory
Deprecated.Set the implementation ofILcdSVGShapeFactory
, the default factory decodes only the shapes not the additional style information.- Parameters:
aSVGShapeFactoryFactory
- aILcdSVGShapeFactory
- See Also:
-
decode
Deprecated.Decodes a svg file to aTLcdVectorModel
.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- aString
containing the path of the svg file- Returns:
- the new created
ILcdModel
- Throws:
IOException
- when an I/O error occurred decoding the model.- See Also:
-
decode
protected ILcdModel decode(String aSourceName, TLcdSVGModelDecoder.ContentParser aParser) throws IOException Deprecated.Decodes SVG data to a vector model. The data itself will be retrieved from the content parser.- Parameters:
aSourceName
- the path of the SVG file to decode. If this parameter is null, aILcdModelReferenceDecoder
should be set that can obtain a model reference without a source file name.aParser
- the parser and data source which will decode the SVG file- Returns:
- the new created
ILcdModel
- Throws:
IOException
- when an error occurs during the decoding of the SVG file.
-
getRootElement
Deprecated.Returns the name of the expected root element for files decoded by this decoder.- Returns:
- svg
-
getGroupElement
Deprecated.Returns the name of the grouping element for files decoded by this decoder.- Returns:
- ILcdSVGConstants.SHAPELIST.
-