public class TLcdFeaturedPolygonGXYLayerCodec extends Object implements ILcdGXYLayerDecoder, ILcdGXYLayerEncoder, ILcdGXYLayerFactory, ILcdInputStreamFactoryCapable, ILcdOutputStreamFactoryCapable
ILcdGXYLayerDecoder
, ILcdGXYLayerEncoder
and
ILcdGXYLayerFactory
for ILcdGXYLayer
s whose
ILcdModel
contains featured polygons (both ILcdPolygon
and ILcdFeatured
).
This codec should only be used to encode the ILcdGXYLayer
s that
were created by using createGXYLayer( ILcdModel )
or by using
decodeGXYLayer( ILcdModel, String )
.
This codec should only be used to decode ILcdGXYLayer
s for the
correct ILcdModel
s (see above) and for files that were created
by its encodeGXYLayer
method.
This codec should only be used to create ILcdGXYLayer
s 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.
Constructor and Description |
---|
TLcdFeaturedPolygonGXYLayerCodec() |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeGXYLayer(ILcdModel aModel,
String aSourceName)
Prints out useful debug information in case false is returned.
|
boolean |
canEncodeGXYLayer(ILcdGXYLayer aGXYLayer,
String aDestinationName)
Prints out useful debug information in case false is returned.
|
protected TLcdGXYFeaturedPolygonLabelPainter |
createGXYFeaturedPolygonLabelPainter()
This factory method creates a new, uninitialized
TLcdGXYFeaturedPolygonLabelPainter . |
protected TLcdGXYLayer |
createGXYLayer()
This factory method creates a new, uninitialized
TLcdGXYLayer . |
ILcdGXYLayer |
createGXYLayer(ILcdModel aModel)
Creates a
ILcdGXYLayer for the given ILcdModel
(see super). |
protected ILcdGXYLayer |
createGXYLayer(ILcdModel aModel,
String aPrefix,
Properties aProperties)
Creates a
ILcdGXYLayer from the given Properties
object. |
protected TLcdGXYPointListPainter |
createGXYPointListPainter()
This factory method creates a new, uninitialized
TLcdGXYPointListPainter . |
ILcdGXYLayer |
decodeGXYLayer(ILcdModel aModel,
String aSourceName)
Reads the given source name as a
Properties file and then
creates a ILcdGXYLayer for the given model while respecting
the read properties. |
void |
encodeGXYLayer(ILcdGXYLayer aGXYLayer,
String aDestinationName)
Encodes the given layer to the given destination name.
|
protected void |
encodeGXYLayer(ILcdGXYLayer aGXYLayer,
String aPrefix,
Properties aPropertiesSFCT)
Encodes the given
ILcdGXYLayer into the given
Properties object. |
Properties |
getDefaultProperties()
Returns the default
Properties for this codec. |
String |
getDisplayName()
Returns the display name of this codec.
|
String |
getFileExtension()
Returns the file extension that is used by this encoder/decoder.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the
ILcdInputStreamFactory that is used to create
input streams for the source names passed in decodeGXYLayer and
canDecodeGXYLayer . |
ILcdFilter |
getModelFilter()
Returns the
ILcdFilter that is used to filter the
ILcdModel s that are accepted in canDecodeGXYLayer
and canEncodeGXYLayer . |
ILcdOutputStreamFactory |
getOutputStreamFactory()
Returns the
ILcdOutputStreamFactory that is used to create
output streams for the destination names passed in encodeGXYLayer . |
int |
getScreenResolution()
Returns the screen resolution in dots per inch (dpi).
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setDefaultProperties(Properties aDefaultProperties)
Sets the default
Properties for this codec. |
void |
setDisplayName(String aDisplayName)
Sets the display name that will be returned by
getDisplayName . |
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the
ILcdInputStreamFactory that is used to create input
streams for the source names passed in decodeGXYLayer and
canDecodeGXYLayer . |
void |
setModelFilter(ILcdFilter aModelFilter)
Sets the
ILcdFilter that is used to filter the
ILcdModel s that are accepted in canDecodeGXYLayer
and canEncodeGXYLayer . |
void |
setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
Sets the
ILcdOutputStreamFactory that is used to create
output streams for the destination names passed in encodeGXYLayer . |
void |
setScreenResolution(int aScreenResolution)
Sets the screen resolution in dots per inch (dpi).
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
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.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.public boolean isTraceOn()
true
if tracing is enabled for this class.public String getDisplayName()
getDisplayName
in interface ILcdGXYLayerDecoder
getDisplayName
in interface ILcdGXYLayerEncoder
setDisplayName(java.lang.String)
public void setDisplayName(String aDisplayName)
getDisplayName
.aDisplayName
- The new display name for this codec.getDisplayName()
public String getFileExtension()
This decoder/encoder reads/writes from/to files. These files must have the extension returned by this method.
public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactory
that is used to create
input streams for the source names passed in decodeGXYLayer
and
canDecodeGXYLayer
.getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
ILcdInputStreamFactory
.setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)
,
decodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
,
canDecodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
ILcdInputStreamFactory
that is used to create input
streams for the source names passed in decodeGXYLayer
and
canDecodeGXYLayer
.setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- The ILcdInputStreamFactory
to set.getInputStreamFactory()
,
decodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
,
canDecodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
public ILcdOutputStreamFactory getOutputStreamFactory()
ILcdOutputStreamFactory
that is used to create
output streams for the destination names passed in encodeGXYLayer
.getOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
ILcdOutputStreamFactory
.setOutputStreamFactory(com.luciad.io.ILcdOutputStreamFactory)
,
encodeGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, java.lang.String)
public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
ILcdOutputStreamFactory
that is used to create
output streams for the destination names passed in encodeGXYLayer
.setOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
aOutputStreamFactory
- The ILcdOutputStreamFactory
to
set.getOutputStreamFactory()
,
encodeGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, java.lang.String)
public ILcdFilter getModelFilter()
ILcdFilter
that is used to filter the
ILcdModel
s that are accepted in canDecodeGXYLayer
and canEncodeGXYLayer
. If the filter is null (default), all
ILcdModel
s will be accepted, otherwise only the
ILcdModel
s for which the accept
method of the
ILcdFilter
returns true
will be accepted.ILcdFilter
that is used to filter the
ILcdModel
s.setModelFilter(com.luciad.util.ILcdFilter)
,
canDecodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
,
canEncodeGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, java.lang.String)
public void setModelFilter(ILcdFilter aModelFilter)
ILcdFilter
that is used to filter the
ILcdModel
s that are accepted in canDecodeGXYLayer
and canEncodeGXYLayer
. If the filter is null (default), all
ILcdModel
s will be accepted, otherwise only the
ILcdModel
s for which the accept
method of the
ILcdFilter
returns true
will be accepted.aModelFilter
- The new ILcdFilter
that is used to filter
the ILcdModel
s.setModelFilter(com.luciad.util.ILcdFilter)
,
canDecodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
,
canEncodeGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, java.lang.String)
public int getScreenResolution()
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()
.
setScreenResolution(int)
public void setScreenResolution(int aScreenResolution)
aScreenResolution
- The screen resolution in dots per inch (dpi).getScreenResolution()
public Properties getDefaultProperties()
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.setDefaultProperties(java.util.Properties)
public void setDefaultProperties(Properties aDefaultProperties)
Properties
for this codec.aDefaultProperties
- The new default Properties
.getDefaultProperties()
public boolean canDecodeGXYLayer(ILcdModel aModel, String aSourceName)
setClassTraceOn
or setTraceOn
to enable trace
output.canDecodeGXYLayer
in interface ILcdGXYLayerDecoder
aModel
- The ILcdModel
of the ILcdGXYLayer
to decode.aSourceName
- The source name of the layer, e.g. a file name or a
database name, ...ILcdGXYLayer
can be decoded from a given
source name, false otherwise.ILcdGXYLayerDecoder.canDecodeGXYLayer(com.luciad.model.ILcdModel, String)
,
setTraceOn(boolean)
,
setClassTraceOn(boolean)
public boolean canEncodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName)
setClassTraceOn
or setTraceOn
to enable trace
output.canEncodeGXYLayer
in interface ILcdGXYLayerEncoder
aGXYLayer
- The layer to be encoded.aDestinationName
- The destination name to encode the layer to, e.g.
a file name, a database name, ...ILcdGXYLayerEncoder.canEncodeGXYLayer(ILcdGXYLayer, String)
,
setTraceOn(boolean)
,
setClassTraceOn(boolean)
public ILcdGXYLayer decodeGXYLayer(ILcdModel aModel, String aSourceName) throws IOException
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
.
decodeGXYLayer
in interface ILcdGXYLayerDecoder
aModel
- See super.aSourceName
- The file name of the Properties
file.IOException
- See super.ILcdGXYLayerDecoder.canDecodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
public void encodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName) throws IOException
ILcdGXYLayerEncoder
The method canEncodeGXYLayer
should return true
(for the same arguments) before this method is used.
encodeGXYLayer
in interface ILcdGXYLayerEncoder
aGXYLayer
- The layer to encode.aDestinationName
- The destination name to encode the layer to, e.g.
a file name, a database name, ...IOException
- In case of io failure.ILcdGXYLayerEncoder.canEncodeGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, java.lang.String)
public ILcdGXYLayer createGXYLayer(ILcdModel aModel)
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
.
createGXYLayer
in interface ILcdGXYLayerFactory
aModel
- The ILcdModel
that will be set to the
ILcdGXYLayer
.ILcdGXYLayer
.TLcdGXYViewJPanel.setGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
protected TLcdGXYLayer createGXYLayer()
TLcdGXYLayer
.
This method can be extended to for instance return an extension of
TLcdGXYLayer
.TLcdGXYLayer
.protected TLcdGXYPointListPainter createGXYPointListPainter()
TLcdGXYPointListPainter
. This method can be extended to for
instance return an extension of TLcdGXYPointListPainter
.TLcdGXYPointListPainter
.protected TLcdGXYFeaturedPolygonLabelPainter createGXYFeaturedPolygonLabelPainter()
TLcdGXYFeaturedPolygonLabelPainter
. This method can be
extended to for instance return an extension of
TLcdGXYFeaturedPolygonLabelPainter
.TLcdGXYFeaturedPolygonLabelPainter
.protected ILcdGXYLayer createGXYLayer(ILcdModel aModel, String aPrefix, Properties aProperties)
ILcdGXYLayer
from the given Properties
object. This method is used by decodeGXYLayer
and
createGXYLayer(ILcdModel)
. This method can be extended to read
additional properties.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.ILcdGXYLayer
.protected void encodeGXYLayer(ILcdGXYLayer aGXYLayer, String aPrefix, Properties aPropertiesSFCT)
ILcdGXYLayer
into the given
Properties
object. This method can be extended to write
additional properties.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.