Class TLcdRasterGXYLayerCodec

java.lang.Object
com.luciad.view.gxy.TLcdRasterGXYLayerCodec
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdOutputStreamFactoryCapable, ILcdGXYLayerDecoder, ILcdGXYLayerEncoder, ILcdGXYLayerFactory

ILcdGXYLayerDecoder, ILcdGXYLayerEncoder and ILcdGXYLayerFactory for ILcdGXYLayers whose ILcdModel contains (single level) rasters (ILcdRaster).

This codec should only be used to encode the ILcdGXYLayers that were created by using createGXYLayer( ILcdModel ) or by using decodeGXYLayer( ILcdModel, String ).

This codec should only be used to decode ILcdGXYLayers for the correct ILcdModels (see above) and for files that were created by its encodeGXYLayer method.

This codec should only be used to create ILcdGXYLayers for the correct models (see above).

This codec is capable of writing all layer and painter properties in a style file (encodeGXYLayer). These style files can also be decoded (decodeGXYLayer), meaning that all properties defined in the style file will be set to the decoded layer. When a layer is created using createGXYLayer it will automatically try to find an associated style file next to the source of the ILcdModel (ILcdModel.getModelDescriptor().getSourceName()). If such a layer file is found, it will be decoded, if not the default properties will be used.

Note that this codec supports the encoding/decoding of raster coloring when a TLcdIndexColorModel is used. However layers created by createGXYLayer(ILcdModel) method do not have this specific color model set by default. For example, it does not make sense to color a satellite picture with a TLcdIndexColorModel, but it does make sense to color elevation data with a TLcdIndexColorModel.

See Also:
  • Constructor Details

    • TLcdRasterGXYLayerCodec

      public TLcdRasterGXYLayerCodec()
      Creates a new TLcdRasterGXYLayerCodec, ready to be used.
  • Method Details

    • 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.
    • setTraceOn

      public void setTraceOn(boolean aTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for this class instance. Calling this method with either true or false as argument automatically turns off tracing for all other class instances for which setTraceOn has not been called. If the argument is false then only the informative, warning and error log messages are recorded.
      Parameters:
      aTraceOn - if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
    • isTraceOn

      public boolean isTraceOn()
      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()
      Returns the display name of this codec.
      Specified by:
      getDisplayName in interface ILcdGXYLayerDecoder
      Specified by:
      getDisplayName in interface ILcdGXYLayerEncoder
      Returns:
      the display name of this codec.
      See Also:
    • setDisplayName

      public void setDisplayName(String aDisplayName)
      Sets the display name that will be returned by getDisplayName.
      Parameters:
      aDisplayName - The new display name for this codec.
      See Also:
    • getFileExtension

      public String getFileExtension()
      Returns the file extension that is used by this encoder/decoder. The extension is without the dot.

      This decoder/encoder reads/writes from/to files. These files must have the extension returned by this method.

      Returns:
      the file extension (without the dot).
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the ILcdInputStreamFactory that is used to create input streams for the source names passed in decodeGXYLayer and canDecodeGXYLayer.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      The associated ILcdInputStreamFactory.
      See Also:
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the ILcdInputStreamFactory that is used to create input streams for the source names passed in decodeGXYLayer and canDecodeGXYLayer.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - The ILcdInputStreamFactory to set.
      See Also:
    • getOutputStreamFactory

      public ILcdOutputStreamFactory getOutputStreamFactory()
      Returns the ILcdOutputStreamFactory that is used to create output streams for the destination names passed in encodeGXYLayer.
      Specified by:
      getOutputStreamFactory in interface ILcdOutputStreamFactoryCapable
      Returns:
      The associated ILcdOutputStreamFactory.
      See Also:
    • setOutputStreamFactory

      public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
      Sets the ILcdOutputStreamFactory that is used to create output streams for the destination names passed in encodeGXYLayer.
      Specified by:
      setOutputStreamFactory in interface ILcdOutputStreamFactoryCapable
      Parameters:
      aOutputStreamFactory - The ILcdOutputStreamFactory to set.
      See Also:
    • getModelFilter

      public ILcdFilter getModelFilter()
      Returns the ILcdFilter that is used to filter the ILcdModels that are accepted in canDecodeGXYLayer and canEncodeGXYLayer. If the filter is null, all ILcdModels will be accepted, otherwise only the ILcdModels for which the accept method of the ILcdFilter returns true will be accepted. The default model filter only accepts ILcdModels of which the ILcdModelDescriptor is an instance of TLcdRasterModelDescriptor.
      Returns:
      The ILcdFilter that is used to filter the ILcdModels.
      See Also:
    • setModelFilter

      public void setModelFilter(ILcdFilter aModelFilter)
      Sets the ILcdFilter that is used to filter the ILcdModels that are accepted in canDecodeGXYLayer and canEncodeGXYLayer.
      Parameters:
      aModelFilter - The new ILcdFilter that is used to filter the ILcdModels.
      See Also:
    • getScreenResolution

      public int getScreenResolution()
      Returns the screen resolution in dots per inch (dpi).

      The screen resolution is used to accurately convert map scales (e.g. 1/100000) to LuciadLightspeed scales (e.g. pixels per meter).

      The default value is Toolkit.getDefaultToolkit().getScreenResolution().

      Returns:
      the screen resolution in dots per inch (dpi).
      See Also:
    • setScreenResolution

      public void setScreenResolution(int aScreenResolution)
      Sets the screen resolution in dots per inch (dpi).

      Parameters:
      aScreenResolution - The screen resolution in dots per inch (dpi).
      See Also:
    • getDefaultProperties

      public Properties getDefaultProperties()
      Returns the default Properties for this codec. In case a property is missing in the file that needs to be decoded, or in case a ILcdGXYLayer is created using createGXYLayer( ILcdModel ), the values in this Properties object will be used. If a necessary value is also missing in the default Properties object, or if the default Properties are null (default), a hardcoded default will be used.

      The properties that can be set as default properties are the same properties as those that are available in a style file. Use encodeGXYLayer(ILcdGXYLayer, String) on a ILcdGXYLayer created using createGXYLayer(com.luciad.model.ILcdModel) with a valid ILcdModel (valid means getModelFilter() accepts the model) to quickly create such a style file.

      Returns:
      The default properties.
      See Also:
    • setDefaultProperties

      public void setDefaultProperties(Properties aDefaultProperties)
      Sets the default Properties for this codec.
      Parameters:
      aDefaultProperties - The new default Properties.
      See Also:
    • canDecodeGXYLayer

      public boolean canDecodeGXYLayer(ILcdModel aModel, String aSourceName)
      Prints out useful debug information in case false is returned. Use setClassTraceOn or setTraceOn to enable trace output.
      Specified by:
      canDecodeGXYLayer in interface ILcdGXYLayerDecoder
      Parameters:
      aModel - The ILcdModel of the ILcdGXYLayer to decode.
      aSourceName - The source name of the layer, e.g. a file name or a database name, ...
      Returns:
      true if an ILcdGXYLayer can be decoded from a given source name, false otherwise.
      See Also:
    • canEncodeGXYLayer

      public boolean canEncodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName)
      Prints out useful debug information in case false is returned. Use setClassTraceOn or setTraceOn to enable trace output.
      Specified by:
      canEncodeGXYLayer in interface ILcdGXYLayerEncoder
      Parameters:
      aGXYLayer - The layer to be encoded.
      aDestinationName - The destination name to encode the layer to, e.g. a file name, a database name, ...
      Returns:
      true if the given layer can be encoded to the given destination name, false otherwise.
      See Also:
    • decodeGXYLayer

      public ILcdGXYLayer decodeGXYLayer(ILcdModel aModel, String aSourceName) throws IOException
      Reads the given source name as a Properties file and then creates a ILcdGXYLayer for the given model while respecting the read properties. If values are missing in the read Properties object, the values of the default Properties object will be used. If the necessary values are missing there as well, a hardcoded default will be used.

      The painters and editors of the layer are specified in createGXYLayer.

      Specified by:
      decodeGXYLayer in interface ILcdGXYLayerDecoder
      Parameters:
      aModel - See super.
      aSourceName - The file name of the Properties file.
      Returns:
      See super.
      Throws:
      IOException - See super.
      See Also:
    • encodeGXYLayer

      public void encodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName) throws IOException
      Description copied from interface: ILcdGXYLayerEncoder
      Encodes the given layer to the given destination name.

      The method canEncodeGXYLayer should return true (for the same arguments) before this method is used.

      Specified by:
      encodeGXYLayer in interface ILcdGXYLayerEncoder
      Parameters:
      aGXYLayer - The layer to encode.
      aDestinationName - The destination name to encode the layer to, e.g. a file name, a database name, ...
      Throws:
      IOException - In case of io failure.
      See Also:
    • createGXYLayer

      public ILcdGXYLayer createGXYLayer(ILcdModel aModel)
      Creates a ILcdGXYLayer for the given ILcdModel (see super).

      Tries to find a layer file next to the model source name (ILcdModel.getModelDescriptor().getSourceName) that has the same name, but a different extension (getFileExtension()). If this file exists, it will be decoded. Otherwise, the default properties will be used. If some necessary values are missing there as well, a hardcoded default will be used.

      The ILcdGXYPainterProvider of the returned ILcdGXYLayer will be a TLcdRasterPainter. Although no color model is set to this painter by default, the encoding and decoding process can handle a color model of type TLcdIndexColorModel. If you want to use the encoding/decoding of the coloring, you must overwrite this method and set a TLcdIndexColorModel to the TLcdRasterPainter of the returned layer if no such color model is already set.

      Specified by:
      createGXYLayer in interface ILcdGXYLayerFactory
      Parameters:
      aModel - The ILcdModel that will be set to the ILcdGXYLayer.
      Returns:
      The newly created ILcdGXYLayer.
      See Also:
    • createGXYLayer

      protected TLcdGXYLayer createGXYLayer()
      This factory method creates a new, uninitialized TLcdGXYLayer. This method can be extended to for instance return an extension of TLcdGXYLayer.
      Returns:
      A new, uninitialized TLcdGXYLayer.
    • createRasterPainter

      protected TLcdRasterPainter createRasterPainter()
      This factory method creates a new, uninitialized TLcdRasterPainter. This method can be extended to for instance return an extension of TLcdRasterPainter.
      Returns:
      A new, uninitialized TLcdRasterPainter.
    • createGXYLayer

      protected ILcdGXYLayer createGXYLayer(ILcdModel aModel, String aPrefix, Properties aProperties)
      Creates a ILcdGXYLayer from the given Properties object. This method is used by decodeGXYLayer and createGXYLayer(ILcdModel). This method can be extended to read additional properties.
      Parameters:
      aModel - aModel The ILcdModel that will be set to the ILcdGXYLayer.
      aPrefix - The prefix to be used to read keys from the Properties object.
      aProperties - The properties object to read. If values are missing in these Properties, a hardcoded default will be used.
      Returns:
      The newly created ILcdGXYLayer.
    • encodeGXYLayer

      protected void encodeGXYLayer(ILcdGXYLayer aGXYLayer, String aPrefix, Properties aPropertiesSFCT)
      Encodes the given ILcdGXYLayer into the given Properties object. This method can be extended to write additional properties.
      Parameters:
      aGXYLayer - The ILcdGXYLayer to encode.
      aPrefix - The prefix to be used to write keys into the Properties object.
      aPropertiesSFCT - The properties object to write to.