Class TLcdCGMModelDecoder

java.lang.Object
com.luciad.format.cgm.TLcdCGMModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder

Deprecated.
we do not recommend using CGM for georeferenced data. Use TLcdCGMIcon to decode CGM as an icon.
This ILcdModelDecoder decodes data in CGM format (Computer Graphics Metafile), as defined by MIL-STD-2301.

Typically CGM documents are not directly decoded as models but rather used as styled icons to decorate existing models. For that use case, consider using TLcdCGMIcon instead.

The following CGM elements are currently supported:

CGM element name Decoded object
POLYLINE TLcdCGMPolyline
TEXT TLcdCGMText
POLYGON TLcdCGMPolygon
RECTANGLE TLcdCGMRectangle
CIRCLE TLcdCGMCircle
CIRCULAR ARC TLcdCGMArc
CIRCULAR ARC, CLOSED TLcdCGMArc
ELLIPSE TLcdCGMEllipse
ELLIPTICAL ARC TLcdCGMArc
ELLIPTICAL ARC, CLOSEDTLcdCGMArc

Coordinates can be scaled and then shifted by means of the shift and scale properties.

The model reference is obtained from an ILcdModelReferenceDecoder. The default reference decoder set on this model decoder is based on all model reference decoders annotated with the LcdService annotation, and can handle

If this fails, the decoder's default model reference is returned. Unless set by the user, the default model reference is null.

All domain objects of CGM implement ILcdDataObject. Their data types can be found in TLcdCGMDataTypes.

The decode method of this model decoder will make sure that the model descriptor of the decoded model will have all the data types of elements of the model. This can be queried at runtime using the TLcdCGMModelDescriptor.getModelElementTypes() method. If the model is updated after decoding to feature more model element data types, a new model descriptor will have to be added with an updated list of model element data types.

  • Constructor Details

    • TLcdCGMModelDecoder

      public TLcdCGMModelDecoder()
      Deprecated.
      Creates a new TLcdCGMModelDecoder.
    • TLcdCGMModelDecoder

      public TLcdCGMModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
      Deprecated.
      Creates a new TLcdCGMModelDecoder.
      Parameters:
      aModelReferenceDecoder - the model reference decoder that can assign references to decoded models.
    • TLcdCGMModelDecoder

      public TLcdCGMModelDecoder(ILcdModelReference aDefaultModelReference)
      Deprecated.
      Creates a new TLcdCGMModelDecoder.
      Parameters:
      aDefaultModelReference - the model reference that decoded models will get if the model reference decoder can't decode one.
    • TLcdCGMModelDecoder

      public TLcdCGMModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference)
      Deprecated.
      Creates a new TLcdCGMModelDecoder.
      Parameters:
      aModelReferenceDecoder - the model reference decoder that can assign references to decoded models.
      aDefaultModelReference - the model reference that decoded models will get if the model reference decoder can't decode one.
  • Method Details

    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Deprecated.
      Sets the input stream factory that will be used for creating input streams given source names.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Deprecated.
      Description copied from interface: ILcdInputStreamFactoryCapable
      Returns the input stream factory that is used.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is used.
    • setModelReferenceDecoder

      public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
      Deprecated.
      Sets the model reference decoder that will be used for creating model references for decoded models.
    • getModelReferenceDecoder

      public ILcdModelReferenceDecoder getModelReferenceDecoder()
      Deprecated.
      Returns the model reference decoder that is used for creating model references for decoded models. The default value supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg).
      Returns:
      the model reference decoder used by this decoder
      See Also:
    • setDefaultModelReference

      public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
      Deprecated.
      Sets the default model reference for decoded models, in case the model reference decoder doesn't provide one.
    • getDefaultModelReference

      public ILcdModelReference getDefaultModelReference()
      Deprecated.
    • setShiftX

      public void setShiftX(double aShiftX)
      Deprecated.
      Sets the distance by which x ordinates are shifted, after having been scaled.
    • getShiftX

      public double getShiftX()
      Deprecated.
    • setShiftY

      public void setShiftY(double aShiftY)
      Deprecated.
      Sets the distance by which y ordinates are shifted, after having been scaled.
    • getShiftY

      public double getShiftY()
      Deprecated.
    • setScaleX

      public void setScaleX(double aScaleX)
      Deprecated.
      Sets the factor by which x ordinates are scaled.
    • getScaleX

      public double getScaleX()
      Deprecated.
    • setScaleY

      public void setScaleY(double aScaleY)
      Deprecated.
      Sets the factor by which y ordinates are scaled.
    • getScaleY

      public double getScaleY()
      Deprecated.
    • getDefaultExtension

      public String getDefaultExtension()
      Deprecated.
      Returns:
      "cgm".
    • getDisplayName

      public String getDisplayName()
      Deprecated.
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Deprecated.
      Description copied from interface: ILcdModelDecoder
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return true for a source name while decode throws an exception for that same source name.

      For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be verified; typically a file name or a URL.
      Returns:
      true if this decoder can likely decode the data specified by the source name, false otherwise.
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Deprecated.
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be decoded; typically a file name or a URL.
      Returns:
      A model containing the decoded data. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.
      
         public ILcdModel decode( String aSourceName ) throws IOException {
            try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
               // Perform decoding ...
            } catch (RuntimeException e) {
               throw new IOException(e);
            }
         }
       
      See Also:
    • decodeElements

      public void decodeElements(String aSourceName, int aOffset, ILcdModel aModelSFCT) throws IOException
      Deprecated.
      Decodes the CGM elements from the given source and adds them to the given model.
      Parameters:
      aSourceName - the name of the source containing CGM data.
      aOffset - the offset indicating the start of the CGM data
      aModelSFCT - the model to which the decoded elements are added.
      Throws:
      IOException
    • decodeElements

      public void decodeElements(DataInputStream aStream, ILcdModel aModelSFCT) throws IOException
      Deprecated.
      Decodes the CGM elements from the given stream and adds them to the given model.
      Parameters:
      aStream - the stream containing CGM data.
      aModelSFCT - the model to which the decoded elements are added.
      Throws:
      IOException