Class TLcdFeaturedPolygonGXYLayerCodec

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

ILcdGXYLayerDecoder, ILcdGXYLayerEncoder and ILcdGXYLayerFactory for ILcdGXYLayers whose ILcdModel contains featured polygons (both ILcdPolygon and ILcdFeatured).

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.

See Also:
  • Constructor Details

    • TLcdFeaturedPolygonGXYLayerCodec

      public TLcdFeaturedPolygonGXYLayerCodec()
  • 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 (default), all ILcdModels will be accepted, otherwise only the ILcdModels for which the accept method of the ILcdFilter returns true will be accepted.
      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. If the filter is null (default), all ILcdModels will be accepted, otherwise only the ILcdModels for which the accept method of the ILcdFilter returns true will be accepted.
      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 TLcdGXYPainterProvider. One of the painters set to this provider is the TLcdGXYPointListPainter. If the layer is editable capable, the ILcdGXYEditorProvider will be a TLcdGXYEditorProvider. One of the editors set to this provider is the same instance of the TLcdGXYPointListPainter. If the layer is labeled capable, a TLcdGXYFeaturedPolygonLabelPainter will be used as the ILcdGXYLabelPainterProvider.

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

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

      protected TLcdGXYFeaturedPolygonLabelPainter createGXYFeaturedPolygonLabelPainter()
      This factory method creates a new, uninitialized TLcdGXYFeaturedPolygonLabelPainter. This method can be extended to for instance return an extension of TLcdGXYFeaturedPolygonLabelPainter.
      Returns:
      A new, uninitialized TLcdGXYFeaturedPolygonLabelPainter.
    • 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.