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 ILcdShapeaccording 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
ILcdModelDescriptorFactoryis set and the factory implementsILcdSVGModelDescriptorFactory. This type of model descriptor factories can take into account the attributes of the root XML element. - a
ILcdModelDescriptorFactoryis 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
ILcdModelDescriptorFactoryis set. ATLcdSVGModelDescriptorwill be set to the model. This model descriptor implementsILcdDataModelDescriptor. It uses theTLcdDataModelandTLcdDataTypeinstances defined inTLcdSVGDataTypes. Note that theTLcdDataTypes defined in this class are primitive, and as such, the default implementation of theILcdSVGShapeFactorywill 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
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceDeprecated.An interface for parsers of SVG data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeSource(String aSourceName) Deprecated.Checks if this source can be decoded.Deprecated.Decodes a svg file to aTLcdVectorModel.protected ILcdModeldecode(String aSourceName, TLcdSVGModelDecoder.ContentParser aParser) Deprecated.Decodes SVG data to a vector model.Deprecated.Gets the display name of the decoder.protected StringDeprecated.Returns the extension of files that can be decoded by this decoder.protected StringDeprecated.Returns the name of the grouping element for files decoded by this decoder.Deprecated.Gets the usedILcdInputStreamFactory.Deprecated.Gets theILcdModelDescriptorFactoryof this decoder.Deprecated.Returns theILcdModelReferenceDecoderused to decode a model reference based on the path to the file to decode.protected StringDeprecated.Returns the name of the expected root element for files decoded by this decoder.Deprecated.Get the usedILcdSVGShapeFactoryto this decoder.static booleanDeprecated.This method has been deprecated.static voidsetClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated.voidsetCreateIndexedModel(boolean aCreateIndexedModel) Deprecated.When true, this decoder will return anILcd2DBoundsIndexedModel, if false aTLcdVectorModel.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Deprecated.Set aILcdInputStreamFactoryto this decoder to manage the input.voidsetModelDescriptorFactory(ILcdModelDescriptorFactory aModelDescriptorFactory) Deprecated.Sets aILcdModelDescriptorFactoryto the decoder.voidsetModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder) Deprecated.Set theILcdModelReferenceDecoderused to decode a model reference based on the path to the file to decode.voidsetSVGShapeFactoryFactory(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, waitMethods 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 theILcdModelDescriptorFactoryof this decoder.- Returns:
- the used
ILcdModelDescriptorFactory. - See Also:
-
setModelDescriptorFactory
Deprecated.Sets aILcdModelDescriptorFactoryto 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 istruethen 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.Returnstrueif 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:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the display name for this decoder.
-
getModelReferenceDecoder
Deprecated.Returns theILcdModelReferenceDecoderused to decode a model reference based on the path to the file to decode. The default value is aTLcdModelReferenceDecoderobject.- Returns:
- the
ILcdModelReferenceDecoder. - See Also:
-
setModelReferenceDecoder
Deprecated.Set theILcdModelReferenceDecoderused to decode a model reference based on the path to the file to decode.- Parameters:
aModelReferenceDecoder- theILcdModelReferenceDecoderto retrieve a model reference for models decoded with this decoder.- See Also:
-
canDecodeSource
Deprecated.Checks if this source can be decoded.- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- aStringwith 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:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Returns:
- the used implementation of
ILcdInputStreamFactory. - See Also:
-
setInputStreamFactory
Deprecated.Set aILcdInputStreamFactoryto this decoder to manage the input. A default factory is set.- Specified by:
setInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Parameters:
aInputStreamFactory- aILcdInpuStreamFactoryto be used.- See Also:
-
getSVGShapeFactoryFactory
Deprecated.Get the usedILcdSVGShapeFactoryto 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:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- aStringcontaining 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, aILcdModelReferenceDecodershould 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.
-