@LcdService(service=ILcdModelDecoder.class, priority=20000) @Deprecated public class TLcdSVGModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
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:
ILcdModelDescriptorFactory
is set and the factory implements
ILcdSVGModelDescriptorFactory
. This type of model descriptor factories can take
into account the attributes of the root XML element.
ILcdModelDescriptorFactory
is set which does not implement
ILcdSVGModelDescriptorFactory
. 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.
ILcdModelDescriptorFactory
is set. A TLcdSVGModelDescriptor
will be set to the
model. This model descriptor implements ILcdDataModelDescriptor
. It uses the TLcdDataModel
and TLcdDataType
instances defined in TLcdSVGDataTypes
. Note that the TLcdDataType
s
defined in this class are primitive, and as such, the default implementation of the ILcdSVGShapeFactory
will not create elements that implement ILcdDataObject
.
This class decodes the SVG - XML files using SAX
This class requires a JAXP 1.1 XML parser implementation.
TLcdSVGIcon
Modifier and Type | Class and Description |
---|---|
protected static interface |
TLcdSVGModelDecoder.ContentParser
Deprecated.
An interface for parsers of SVG data.
|
Constructor and Description |
---|
TLcdSVGModelDecoder()
Deprecated.
default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Deprecated.
Checks if this source can be decoded.
|
ILcdModel |
decode(String aSourceName)
Deprecated.
Decodes a svg file to a
TLcdVectorModel . |
protected ILcdModel |
decode(String aSourceName,
TLcdSVGModelDecoder.ContentParser aParser)
Deprecated.
Decodes SVG data to a vector model.
|
String |
getDisplayName()
Deprecated.
Gets the display name of the decoder.
|
protected String |
getFileExtension()
Deprecated.
Returns the extension of files that can be decoded by this decoder.
|
protected String |
getGroupElement()
Deprecated.
Returns the name of the grouping element for files decoded by this decoder.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Deprecated.
Gets the used
ILcdInputStreamFactory . |
ILcdModelDescriptorFactory |
getModelDescriptorFactory()
Deprecated.
Gets the
ILcdModelDescriptorFactory of this decoder. |
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Deprecated.
Returns the
ILcdModelReferenceDecoder used to decode a model reference based on the path to the file
to decode. |
protected String |
getRootElement()
Deprecated.
Returns the name of the expected root element for files decoded by this decoder.
|
ILcdSVGShapeFactoryFactory |
getSVGShapeFactoryFactory()
Deprecated.
Get the used
ILcdSVGShapeFactory to this decoder. |
static boolean |
isClassTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setCreateIndexedModel(boolean aCreateIndexedModel)
Deprecated.
When true, this decoder will return an
ILcd2DBoundsIndexedModel , if false a
TLcdVectorModel . |
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Deprecated.
Set a
ILcdInputStreamFactory to this decoder to manage the input. |
void |
setModelDescriptorFactory(ILcdModelDescriptorFactory aModelDescriptorFactory)
Deprecated.
Sets a
ILcdModelDescriptorFactory to the decoder. |
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Deprecated.
Set the
ILcdModelReferenceDecoder used to decode a model reference based on the path to the file to
decode. |
void |
setSVGShapeFactoryFactory(ILcdSVGShapeFactoryFactory aSVGShapeFactoryFactory)
Deprecated.
Set the implementation of
ILcdSVGShapeFactory , the default factory
decodes only the shapes not the additional style information. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdSVGModelDecoder()
public ILcdModelDescriptorFactory getModelDescriptorFactory()
ILcdModelDescriptorFactory
of this decoder.ILcdModelDescriptorFactory
.setModelDescriptorFactory(com.luciad.model.ILcdModelDescriptorFactory)
public void setModelDescriptorFactory(ILcdModelDescriptorFactory aModelDescriptorFactory)
ILcdModelDescriptorFactory
to the decoder. When the model descriptor
set implements ILcdSVGModelDescriptorFactory
, the attributes of the root
element can also be taken into account to create the model descriptor.aModelDescriptorFactory
- the ILcdModelDescriptorFactory
getModelDescriptorFactory()
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public static boolean isClassTraceOn()
true
if tracing is enabled for this class.public String getDisplayName()
getDisplayName
in interface ILcdModelDecoder
public ILcdModelReferenceDecoder getModelReferenceDecoder()
ILcdModelReferenceDecoder
used to decode a model reference based on the path to the file
to decode. The default value is a TLcdModelReferenceDecoder
object.ILcdModelReferenceDecoder
.setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
ILcdModelReferenceDecoder
used to decode a model reference based on the path to the file to
decode.aModelReferenceDecoder
- the ILcdModelReferenceDecoder
to retrieve a model reference for models
decoded with this decoder.getModelReferenceDecoder()
public boolean canDecodeSource(String aSourceName)
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- a String
with the path of the file to decode.MODELTYPE
ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
protected String getFileExtension()
canDecodeSource(java.lang.String)
public void setCreateIndexedModel(boolean aCreateIndexedModel)
ILcd2DBoundsIndexedModel
, if false a
TLcdVectorModel
.aCreateIndexedModel
- true to create a ILcd2DBoundsIndexedModel
.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactory
.getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
ILcdInputStreamFactory
.setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
ILcdInputStreamFactory
to this decoder to manage the input. A default factory is set.setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- a ILcdInpuStreamFactory
to be used.getInputStreamFactory()
public ILcdSVGShapeFactoryFactory getSVGShapeFactoryFactory()
ILcdSVGShapeFactory
to this decoder.ILcdShapeFactory
setSVGShapeFactoryFactory(com.luciad.format.svg.ILcdSVGShapeFactoryFactory)
public void setSVGShapeFactoryFactory(ILcdSVGShapeFactoryFactory aSVGShapeFactoryFactory)
ILcdSVGShapeFactory
, the default factory
decodes only the shapes not the additional style information.aSVGShapeFactoryFactory
- a ILcdSVGShapeFactory
getSVGShapeFactoryFactory()
public ILcdModel decode(String aSourceName) throws IOException
TLcdVectorModel
.decode
in interface ILcdModelDecoder
aSourceName
- a String
containing the path of the svg fileILcdModel
IOException
- when an I/O error occurred decoding the model.ILcdModelDecoder.canDecodeSource(String)
protected ILcdModel decode(String aSourceName, TLcdSVGModelDecoder.ContentParser aParser) throws IOException
aSourceName
- the path of the SVG file to decode. If this parameter is null, a
ILcdModelReferenceDecoder
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 fileILcdModel
IOException
- when an error occurs during the decoding of the SVG file.protected String getRootElement()
protected String getGroupElement()