Class ALcyLspStyleFormat
- Direct Known Subclasses:
TLcyLspRasterFormat
,TLcyLspVectorFormat
This ALcyLspFormat
implementation is designed for layers styled using SLD or for layers using an
ILspCustomizableStyler
.
The format provides full style support for such layers (saving, loading and copying of the style and workspace support
for both the layer and its style).
This format creates default implementations for the ILcyLayerStyleProvider
and
the ILcyLayerStyleCodec
.
The only thing remaining for the extensions of this class is to provide a layer factory
.
The layers created by this layer factory must fulfil the requirements listed in the javadoc of the
createLayerFactoryImpl()
method.
More specialized extensions of this class are available with a default layer factory. Consult the javadoc of these classes to see whether your format can benefit from this default implementation.
Configuration options 
This format checks for the following properties in the ALcyProperties
:
# Configuration of the file type descriptor for the style files
# These style files contain the settings for a layer styled using an ILspCustomizableStyler
shortPrefix.style.fileTypeDescriptor.displayName = Style Files
shortPrefix.style.fileTypeDescriptor.defaultExtension = sty
shortPrefix.style.fileTypeDescriptor.filters = *.sty
shortPrefix.style.fileTypeDescriptor.groupIDs = All Style Files
# The path to the file containing the default style to apply on each created layer
# This file should be a match for an SLD file (*.sld) or customizable style file type descriptor as defined above
shortPrefix.defaultStyleFile = path/to/defaultStyleFile.sty
Warning: this format should only be used when the created layers fulfill the requirements
documented in createLayerFactoryImpl()
.
If your layers cannot meet those requirements, it might be better to extend from ALcyLspStyleFileFormat
or
ALcyLspGeneralFormat
directly.
Warning: this format should be wrapped with a TLcyLspSafeGuardFormatWrapper
before plugging it into the Lucy back-end.
- Since:
- 2012.0
-
Field Summary
Fields inherited from class com.luciad.lucy.format.lightspeed.ALcyLspStyleFileFormat
DEFAULT_STYLE_FILE_SUFFIX
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ALcyLspStyleFormat
(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aPreferences, ILcdFilter<ILcdModel> aModelFilter) Create a new style format -
Method Summary
Modifier and TypeMethodDescriptionvoid
Creates all the instances of the concepts of this class by calling all the abstractcreate<Concept>
methods, and performs some validity checks on the created values.protected abstract ILspLayerFactory
Creates the layer factory for this format.protected ALcyFileTypeDescriptor[]
CreatesALcyFileTypeDescriptor
s for theILcyLayerStyleCodec
s.protected ILcyLayerStyleCodec
Creates the actualILcyLayerStyleCodec
protected ILcyLayerStyleCodec[]
Creates theILcyLayerStyleCodec
instances which can encode/decode the style of the layers created by the layer factory of this format.protected final ILcyLayerStyleProvider[]
Creates the style provider instances that can retrieve and encode the style of the layers created by the layer factory of this format.protected final TLcdSLDFeatureTypeStyle
retrieveFeatureTypeStyle
(ILcdModel aModel) Utility method which tries to find aTLcdSLDFeatureTypeStyle
for the specified model.Methods inherited from class com.luciad.lucy.format.lightspeed.ALcyLspStyleFileFormat
canHandleModel, createLayerFactory
Methods inherited from class com.luciad.lucy.format.lightspeed.ALcyLspGeneralFormat
getLongPrefix, getLucyEnv, getProperties, getShortPrefix
Methods inherited from class com.luciad.lucy.format.lightspeed.ALcyLspFormat
checkInitialized, createBalloonContentProviders, createFormatBarFactory, createLayerContextOfFormatFilter, createLayerCustomizerPanelFactories, createLayerCustomizerPanelWorkspaceCodecs, createLayerMeasureProviderFactory, createLayerSelectionTransferHandlers, createLayerWorkspaceCodecs, getBalloonContentProviders, getFormatBarFactory, getLayerCustomizerPanelFactories, getLayerCustomizerPanelWorkspaceCodecs, getLayerFactory, getLayerMeasureProviderFactory, getLayerSelectionTransferHandlers, getLayerStyleCodecFileTypeDescriptors, getLayerStyleCodecs, getLayerStyleProviders, getLayerWorkspaceCodecs, isLayerOfFormat, toString
-
Constructor Details
-
ALcyLspStyleFormat
protected ALcyLspStyleFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aPreferences, ILcdFilter<ILcdModel> aModelFilter) Create a new style format- Parameters:
aLucyEnv
- The Lucy back-endaLongPrefix
- The long prefix of this format.aShortPrefix
- The short prefix of this formataPreferences
- The preferencesaModelFilter
- 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 benull
.null
models will never be passed to the filter, but always rejected.
-
-
Method Details
-
createAll
public void createAll()Description copied from class:ALcyLspFormat
Creates all the instances of the concepts of this class by calling all the abstract
create<Concept>
methods, and performs some validity checks on the created values. All created instances can later on be retrieved by calling the appropriateget<Concept>
methods.- Overrides:
createAll
in classALcyLspFormat
-
createLayerFactoryImpl
Creates the layer factory for this format. This method will be called from the
ALcyLspStyleFileFormat.createLayerFactory()
method. This factory must not returnILcdLayerTreeNode
instances. In case you want to support empty nodes, consider using aTLcyLspLayerTreeNodeFormatWrapper
.Layer requirements
The layers returned by this layer factory should match the following requirements:
- The layers should implement the
ILspStyledLayer
interface. - When using SLD styling, the SLD must be set on the layer using
TLspShapeLayerBuilder.sldStyle(TLcdSLDFeatureTypeStyle)
orTLspRasterLayerBuilder.sldStyle(TLcdSLDFeatureTypeStyle)
. - When not using SLD styling, the
REGULAR_BODY
and theREGULAR_LABEL
stylers must beILspCustomizableStyler
instances containing regularALspStyle
instances.
Layer styling
The default style of this format as defined in the default style file will be automatically applied on each layer. If a style is present next to the model source file of the layer, this style will be applied as well. It is not necessary to include this functionality in the layer factory returned by this method.
Note however that an SLD style file can only be applied on layers which use SLD styling, and customizable styler based style files can only be applied on layers which use an
ILspCustomizableStyler
. This means that the layer factory decides which kind of styling is available for which layer.To facilitate this, this format has
a utility method
to check whether SLD styling can be found for a certain model. The layer factory can opt to use this method to decide between SLD based styling or customizable styler based styling.An example implementation of this method could be:
return new ALspSingleLayerFactory() { @Override public ILspLayer createLayer(ILcdModel aModel) { //This example implementation assumes the data is vector data TLcdSLDFeatureTypeStyle featureTypeStyle = retrieveFeatureTypeStyle(aModel); if(featureTypeStyle == null){ //create a customizable styler with default styles and set it on the layer TLspCustomizableStyler bodyStyler = new TLspCustomizableStyler( TLspLineStyle.newBuilder().elevationMode(ILspWorldElevationStyle.ElevationMode.ON_TERRAIN) .color(Color.WHITE) .width(2) .build(), TLspFillStyle.newBuilder().elevationMode(ILspWorldElevationStyle.ElevationMode.ON_TERRAIN) .color(new Color(255, 255, 0, 128)) .build(), TLspIconStyle.newBuilder().icon(new TLcdSymbol(TLcdSymbol.FILLED_RECT, 5)).build() ); return TLspShapeLayerBuilder.newBuilder() .model(aModel) .bodyStyler(TLspPaintState.REGULAR, bodyStyler) .build(); } else { //Create a layer which uses SLD styling return TLspShapeLayerBuilder.newBuilder() .model(aModel) .sldStyle(featureTypeStyle) .build(); } } @Override public boolean canCreateLayers(ILcdModel aModel) { //the format should be wrapped with a TLcyLspSafeGuardFormatWrapper so we can just return true return true; } };
- Specified by:
createLayerFactoryImpl
in classALcyLspStyleFileFormat
- Returns:
- The layer factory for this format. May be
null
- The layers should implement the
-
retrieveFeatureTypeStyle
Utility method which tries to find a
TLcdSLDFeatureTypeStyle
for the specified model. It will return:- The parsed SLD file located next to the source file of the model, if available.
- The configured default style file if that is an SLD file.
null
otherwise.
- Parameters:
aModel
- The model- Returns:
- The
TLcdSLDFeatureTypeStyle
foraModel
- Since:
- 2017.0
- See Also:
-
createLayerStyleProviders
Creates the style provider instances that can retrieve and encode the style of the layers created by the layer factory of this format.
The default implementation returns an empty array.
Returns an array of
ILcyLayerStyleProvider
instances, capable of handling the layers created by this format.- Overrides:
createLayerStyleProviders
in classALcyLspFormat
- Returns:
- The style provider to retrieve and encode the style of the layers. Must not be
null
. The array may be empty, but must not containnull
. - See Also:
-
createLayerStyleCodecs
Description copied from class:ALcyLspStyleFileFormat
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 inALcyLspStyleFileFormat.createLayerStyleCodecImpl()
.Warning: when overriding this method, make sure to either return an array of length 1 or to override
ALcyLspStyleFileFormat.createLayerStyleCodecFileTypeDescriptors()
as well.- Overrides:
createLayerStyleCodecs
in classALcyLspStyleFileFormat
- Returns:
- an array of
ILcyLayerStyleCodec
instances. Must not benull
. The array may be empty, but must not containnull
. - See Also:
-
createLayerStyleCodecFileTypeDescriptors
Description copied from class:ALcyLspStyleFileFormat
Creates
ALcyFileTypeDescriptor
s for theILcyLayerStyleCodec
s. The length of the returned array must be equal to that ofALcyLspFormat.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 returnedALcyFileTypeDescriptor
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 theseALcyFileTypeDescriptor
s. When noALcyFileTypeDescriptor
s are available (or onlynull
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
ALcyLspStyleFileFormat.createLayerStyleCodecs()
()} as well.- Overrides:
createLayerStyleCodecFileTypeDescriptors
in classALcyLspStyleFileFormat
- Returns:
- An array of
ALcyFileTypeDescriptor
instances. Must not benull
and its length must be equal to the length of the array of layer style encoders created by this format. May containnull
. - See Also:
-
createLayerStyleCodecImpl
Description copied from class:ALcyLspStyleFileFormat
Creates the actualILcyLayerStyleCodec
- Specified by:
createLayerStyleCodecImpl
in classALcyLspStyleFileFormat
- Returns:
- a new
ILcyLayerStyleCodec
for the layers of this format. Must not benull
. - See Also:
-