public abstract class ALcyLspStyleFileFormat extends ALcyLspGeneralFormat
This ALcyLspFormat
is designed for layers where the layer style is stored into a style
file. The format allows to configure a default style file
which will be applied to every layer created in the layer factory. It also supports to store a
style file next to the source file of the model. Those style files will be applied on the layer
created for that model.
It is up to the extensions of this class to create the ILcyLayerStyleProvider
and
ILcyLayerStyleCodec
. When your layer uses an ILspCustomizableStyler
, it might be better to extend from ALcyLspStyleFormat
directly. That format provides default implementations for the layer style provider and codec.
This format checks for the following properties in the ALcyProperties
:
# The path to the file containing the default style to apply on each created layer
shortPrefix.defaultStyleFile = path/to/defaultStyleFile.sty
Warning: this format should be wrapped with a TLcyLspSafeGuardFormatWrapper
before plugging it into the Lucy back-end.
ALcyLspStyleFormat
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_STYLE_FILE_SUFFIX
Suffix to use in the properties to specify the location of the default style file.
|
Modifier | Constructor and Description |
---|---|
protected |
ALcyLspStyleFileFormat(ILcyLucyEnv aLucyEnv,
String aLongPrefix,
String aShortPrefix,
ALcyProperties aProperties,
ILcdFilter<ILcdModel> aModelFilter)
Create a new style file format
|
Modifier and Type | Method and Description |
---|---|
boolean |
canHandleModel(ILcdModel aModel)
Returns
true if and only if the given model can be visualized by this format. |
protected ILspLayerFactory |
createLayerFactory()
Creates a layer factory for this format, based on a layer factory created by
createLayerFactoryImpl |
protected abstract ILspLayerFactory |
createLayerFactoryImpl()
Creates the layer factory for this format.
|
protected ALcyFileTypeDescriptor[] |
createLayerStyleCodecFileTypeDescriptors()
Creates
ALcyFileTypeDescriptor s for the ILcyLayerStyleCodec s. |
protected abstract ILcyLayerStyleCodec |
createLayerStyleCodecImpl()
Creates the actual
ILcyLayerStyleCodec |
protected ILcyLayerStyleCodec[] |
createLayerStyleCodecs()
Creates the
ILcyLayerStyleCodec instances which can encode/decode the style of
the layers created by the layer factory of this format. |
getLongPrefix, getLucyEnv, getProperties, getShortPrefix
checkInitialized, createAll, createBalloonContentProviders, createFormatBarFactory, createLayerContextOfFormatFilter, createLayerCustomizerPanelFactories, createLayerCustomizerPanelWorkspaceCodecs, createLayerMeasureProviderFactory, createLayerSelectionTransferHandlers, createLayerStyleProviders, createLayerWorkspaceCodecs, getBalloonContentProviders, getFormatBarFactory, getLayerCustomizerPanelFactories, getLayerCustomizerPanelWorkspaceCodecs, getLayerFactory, getLayerMeasureProviderFactory, getLayerSelectionTransferHandlers, getLayerStyleCodecFileTypeDescriptors, getLayerStyleCodecs, getLayerStyleProviders, getLayerWorkspaceCodecs, isLayerOfFormat, toString
public static final String DEFAULT_STYLE_FILE_SUFFIX
Suffix to use in the properties to specify the location of the default style file. This
style will be applied on every layer created by the layer factory of this format. The createLayerStyleCodecs()
will be used to apply this style on the layer.
Note that the default style file should be included in one of the created file type descriptors. If this is not the case, the default style file will be simply ignored.
The complete key to be used in the properties is the short
prefix of the format + DEFAULT_STYLE_FILE_SUFFIX
.
protected ALcyLspStyleFileFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aProperties, ILcdFilter<ILcdModel> aModelFilter)
aLucyEnv
- The Lucy back-endaLongPrefix
- The long prefix of this formataShortPrefix
- The short prefix of this formataProperties
- The propertiesaModelFilter
- Filter used to determine whether a model can be handled by this format.
When the model can be handled by this format, it should be accepted by the
filter. Filter must not be null
. null
models will
never be passed to the filter, but always rejected.public final boolean canHandleModel(ILcdModel aModel)
ALcyLspFormat
Returns true
if and only if the given model can be visualized by this format.
canHandleModel
in class ALcyLspFormat
aModel
- The model to checktrue
if and only if the given model can be visualized by this format.protected final ILspLayerFactory createLayerFactory()
Creates a layer factory for this format, based on a layer factory created by
createLayerFactoryImpl
. This method may return
null
.
createLayerFactory
in class ALcyLspFormat
ILspLayerFactory
for this format. May be null
ALcyLspFormat.getLayerFactory()
,
createLayerFactoryImpl()
protected ALcyFileTypeDescriptor[] createLayerStyleCodecFileTypeDescriptors()
Creates ALcyFileTypeDescriptor
s for the ILcyLayerStyleCodec
s. The
length of the returned array must be equal to that of ALcyLspFormat.createLayerStyleCodecs()
.
The default implementation returns a zero-length array.
This format uses these ALcyFileTypeDescriptor
instances to determine
whether a style file is located next to source file of a layer, and apply that style when
such a layer is created in the layer factory. The layer factory will only try to find style files
with an extension defined by the returned ALcyFileTypeDescriptor
s of this method.
Another example usage of these ALcyFileTypeDescriptor
instances is the File | Save layer style
action which is available in Lucy. It allows to save the style of a layer to a file ending with
an extension as specified by these ALcyFileTypeDescriptor
s. When no
ALcyFileTypeDescriptor
s are available (or only null
ALcyFileTypeDescriptor
s) it will not be possible to save
the layer style to file.
The default implementation returns a file type descriptor based on the info contained in the properties of this format, or a default file type descriptor in case the properties do not contain this info. The file type descriptor can be configured in the configuration file as follows (where "shortPrefix." stands for the short prefix of this format):
shortPrefix.style.fileTypeDescriptor.displayName=... shortPrefix.style.fileTypeDescriptor.defaultExtension=... shortPrefix.style.fileTypeDescriptor.filters=... shortPrefix.style.fileTypeDescriptor.groupIDs=...
Warning: when overriding this method, make sure to either return an array of length
1 or to override createLayerStyleCodecs()
()} as well.
createLayerStyleCodecFileTypeDescriptors
in class ALcyLspFormat
ALcyFileTypeDescriptor
instances. Must not be null
and its length must be equal to the length of the array of layer style encoders created
by this format. May contain null
.createLayerStyleCodecs()
protected ILcyLayerStyleCodec[] createLayerStyleCodecs()
Creates the ILcyLayerStyleCodec
instances which can encode/decode the style of
the layers created by the layer factory of this format.
The default implementation returns an empty array.
The default implementation returns an array containing the ILcyLayerStyleCodec
created
in createLayerStyleCodecImpl()
.
Warning: when overriding this method, make sure to either return an array of length
1 or to override createLayerStyleCodecFileTypeDescriptors()
as well.
createLayerStyleCodecs
in class ALcyLspFormat
ILcyLayerStyleCodec
instances. Must not be null
.
The array may be empty, but must not contain null
.createLayerStyleCodecFileTypeDescriptors()
protected abstract ILspLayerFactory createLayerFactoryImpl()
null
protected abstract ILcyLayerStyleCodec createLayerStyleCodecImpl()
ILcyLayerStyleCodec
ILcyLayerStyleCodec
for the layers of this format. Must not be null
.createLayerStyleCodecs()