Class TLcdSVGModelDecoder

java.lang.Object
com.luciad.format.svg.TLcdSVGModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder

Deprecated.
we do not recommend using SVG for georeferenced data. Use TLcdSVGIcon to decode SVG as an icon.
This 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:

  1. a 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.
  2. a 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.
  3. no 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 TLcdDataTypes 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.

See Also:
  • Constructor Details

    • TLcdSVGModelDecoder

      public TLcdSVGModelDecoder()
      Deprecated.
      default constructor.
  • Method Details

    • getModelDescriptorFactory

      public ILcdModelDescriptorFactory getModelDescriptorFactory()
      Deprecated.
      Gets the ILcdModelDescriptorFactory of this decoder.
      Returns:
      the used ILcdModelDescriptorFactory.
      See Also:
    • setModelDescriptorFactory

      public void setModelDescriptorFactory(ILcdModelDescriptorFactory aModelDescriptorFactory)
      Deprecated.
      Sets a 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.
      Parameters:
      aModelDescriptorFactory - the ILcdModelDescriptorFactory
      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 is true 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.
      Returns true if tracing is enabled for this class.
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • getDisplayName

      public String getDisplayName()
      Deprecated.
      Gets the display name of the decoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the display name for this decoder.
    • getModelReferenceDecoder

      public ILcdModelReferenceDecoder getModelReferenceDecoder()
      Deprecated.
      Returns the ILcdModelReferenceDecoder used to decode a model reference based on the path to the file to decode. The default value is a TLcdModelReferenceDecoder object.
      Returns:
      the ILcdModelReferenceDecoder.
      See Also:
    • setModelReferenceDecoder

      public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
      Deprecated.
      Set the ILcdModelReferenceDecoder used to decode a model reference based on the path to the file to decode.
      Parameters:
      aModelReferenceDecoder - the ILcdModelReferenceDecoder to retrieve a model reference for models decoded with this decoder.
      See Also:
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Deprecated.
      Checks if this source can be decoded.
      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceName - a String with the path of the file to decode.
      Returns:
      true if the argument contains MODELTYPE
      See Also:
    • getFileExtension

      protected String 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 an ILcd2DBoundsIndexedModel, if false a TLcdVectorModel.
      Parameters:
      aCreateIndexedModel - true to create a ILcd2DBoundsIndexedModel.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Deprecated.
      Gets the used ILcdInputStreamFactory.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the used implementation of ILcdInputStreamFactory.
      See Also:
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Deprecated.
      Set a ILcdInputStreamFactory to this decoder to manage the input. A default factory is set.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - a ILcdInpuStreamFactory to be used.
      See Also:
    • getSVGShapeFactoryFactory

      public ILcdSVGShapeFactoryFactory getSVGShapeFactoryFactory()
      Deprecated.
      Get the used ILcdSVGShapeFactory to this decoder.
      Returns:
      the used implementation of ILcdShapeFactory
      See Also:
    • setSVGShapeFactoryFactory

      public void setSVGShapeFactoryFactory(ILcdSVGShapeFactoryFactory aSVGShapeFactoryFactory)
      Deprecated.
      Set the implementation of ILcdSVGShapeFactory, the default factory decodes only the shapes not the additional style information.
      Parameters:
      aSVGShapeFactoryFactory - a ILcdSVGShapeFactory
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Deprecated.
      Decodes a svg file to a TLcdVectorModel.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSourceName - a String 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, 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 file
      Returns:
      the new created ILcdModel
      Throws:
      IOException - when an error occurs during the decoding of the SVG file.
    • getRootElement

      protected String getRootElement()
      Deprecated.
      Returns the name of the expected root element for files decoded by this decoder.
      Returns:
      svg
    • getGroupElement

      protected String getGroupElement()
      Deprecated.
      Returns the name of the grouping element for files decoded by this decoder.
      Returns:
      ILcdSVGConstants.SHAPELIST.