Class TLcdSVGModelEncoder

java.lang.Object
com.luciad.format.svg.TLcdSVGModelEncoder
All Implemented Interfaces:
ILcdOutputStreamFactoryCapable, ILcdModelEncoder, Serializable

@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdSVGModelEncoder extends Object implements ILcdModelEncoder, ILcdOutputStreamFactoryCapable
This ILcdModelEncoder allows to encode models to SVG files. It does not encode styling elements or ILcdDataObject properties.

It 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/
SVG supports the shapes:

  • rectangle (ILcdBounds)
  • circle (ILcdCircle)
  • polygon (ILcdPolygon)
  • polyline (ILcdPolyline)
  • shapelist (ILcdShapeList)
  • ellipse (ILcdEllipse)
  • line (ILcdPolyline)
  • text (ILcdText)
Additional to the SVG standard this class encodes
  • ILcdPoint
  • ILcdArcBand
if the TrueSVG property is set to false. This class has an default ILcdOutputStreamFactory ( which provides a stream for writing the encoded file to, by default a BufferedOutputStream ( FileOutputStream )) and a default ILcdSVGShapeWriter ( TLcdSVGUnStyledShapeWriter) , to encodes a given shape to a StringBuffer. These 2 classes can be set.
See Also:
  • Constructor Details

    • TLcdSVGModelEncoder

      public TLcdSVGModelEncoder()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Gets the display name of this encoder.
      Specified by:
      getDisplayName in interface ILcdModelEncoder
      Returns:
      a String containing the display name of the encoder.
    • canSave

      public boolean canSave(ILcdModel aModel)
      Checks on the destination and then checks if shapes can be exported.
      Specified by:
      canSave in interface ILcdModelEncoder
      Parameters:
      aModel - the ILcdModel to save.
      Returns:
      true if the destination is set and is true.
      See Also:
    • getOutputStreamFactory

      public ILcdOutputStreamFactory getOutputStreamFactory()
      Get the used ILcdOutputStreamfactory to this decoder.
      Specified by:
      getOutputStreamFactory in interface ILcdOutputStreamFactoryCapable
      Returns:
      the used ILcdOutputStreamfactory
      See Also:
    • setOutputStreamFactory

      public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
      Sets a ILcdOutputFactory to this encoder. A default implementation is set.
      Specified by:
      setOutputStreamFactory in interface ILcdOutputStreamFactoryCapable
      Parameters:
      aOutputStreamFactory - the ILcdOytputStreamFactory to use.
      See Also:
    • getModelReferenceEncoder

      public ILcdModelReferenceEncoder getModelReferenceEncoder()
      Returns the ILcdModelReferenceEncoder used to save the model reference.
      Returns:
      the ILcdModelReferenceEncoder used to save the model reference.
      See Also:
    • setModelReferenceEncoder

      public void setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
      Sets the ILcdModelReferenceEncoder to use to encode the model reference.
      Parameters:
      aModelReferenceEncoder - the ILcdModelReferenceEncoder to use to encode the model reference.
      See Also:
    • getSVGShapeWriter

      public ILcdSVGShapeWriter getSVGShapeWriter()
      Gets the ILcdSVGShapeWriter that is used to write the shapes. If no ILcdSVGShapeWriter is set, the default one will be returned.
      Returns:
      the used ILcdSVGShapeWriter
      See Also:
    • setSVGShapeWriter

      public void setSVGShapeWriter(ILcdSVGShapeWriter aShapeWriter)
      Sets a ILcdSVGShapeWriter to this encoder. The default ILcdSVGShapeWriter is the TLcdSVGUnStyledShapeWriter
      Parameters:
      aShapeWriter - the ILcdShapeWriter to be used.
      See Also:
    • save

      public void save(ILcdModel aModel) throws IOException
      Saves the ILcdModel.
      Specified by:
      save in interface ILcdModelEncoder
      Parameters:
      aModel - the ILcdModel to save.
      Throws:
      IOException - when an I/O error occurs while saving the model.
    • canExport

      public boolean canExport(ILcdModel aModel, String aSource)
      Checks if there is at least one shape that can be exported.
      Specified by:
      canExport in interface ILcdModelEncoder
      Parameters:
      aModel - the ILcdModel containing the shapes.
      aSource - the destination to export the ILcdModel to.
      Returns:
      true if at least one ILcdShape of the ILcdModel can be exported.
      See Also:
    • setTrueSVG

      public void setTrueSVG(boolean aTrueSVG)
      Sets whether only objects that have an SVG counterpart shall be encoded. Default value is false, which implies that points and arcbands will be encoded.
      Parameters:
      aTrueSVG - If true the encoder will not encode ILcd2DEditableArcBand and ILcdPoint objects. These classes have no counterparts in SVG.
    • isTrueSVG

      public boolean isTrueSVG()
      Returns whether only objects that have an SVG counterpart shall be encoded.
      Returns:
      whether only objects that have an SVG counterpart shall be encoded.
    • export

      public void export(ILcdModel aModel, String aSource) throws IOException
      Exports the ILcdModel to the destination file and saves the model reference. If the ModelReferenceEncoder is unset, this method will write a aSource.ref file. The exported file is created by:
      Specified by:
      export in interface ILcdModelEncoder
      Parameters:
      aModel - the ILcdModel to export.
      aSource - the destination to export to.
      Throws:
      IOException - when an I/O error occurs while exporting the model.
      See Also:
    • getRootElement

      protected String getRootElement()
      Returns the name of the root element.
      Returns:
      the name of the root element.
      See Also:
    • getDefaultExtension

      protected String getDefaultExtension()
      Returns the default extension for files saved with this encoder.
      Returns:
      the default extension for files saved with this encoder.
    • writeHeader

      protected void writeHeader(Writer aWriter, ILcdModel aModel) throws IOException
      Writes the header of the file. This should open the root element of the section in which all shape elements will be created. This implementation writes an xml version line and opens the root element.
      Parameters:
      aWriter - the writer to write to.
      aModel - the model that we are writing
      Throws:
      IOException - when an I/O error occurred while writing the header.
      See Also:
    • writeFooter

      protected void writeFooter(Writer aWriter) throws IOException
      Writes the footer of the file. This should close the section, in which all shape elements are created. This implementation closes the root element.
      Parameters:
      aWriter - the writer to write to.
      Throws:
      IOException - when an I/O error occurred while writing the footer.
      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.