public class TLcyLspRasterFormat extends ALcyLspStyleFormat
Extension of ALcyLspStyleFormat
for raster and Earth formats. It provides a custom
implementation of the createLayerFactoryImpl()
method, which supports the
same models as documented in TLspRasterLayerBuilder
. This layer factory allows
to make small changes to the created layers before they leave the layer factory by calling
customizeLayer
for
each layer it creates.
Extensions of this class can override the customizeLayer
method but this only makes sense for small changes (e.g. changing the icon of the layer).
Warning: this format should be wrapped with a TLcyLspSafeGuardFormatWrapper
before plugging it into the Lucy back-end.
TLcyLspVectorFormat
DEFAULT_STYLE_FILE_SUFFIX
Constructor and Description |
---|
TLcyLspRasterFormat(ILcyLucyEnv aLucyEnv,
String aLongPrefix,
String aShortPrefix,
ALcyProperties aPreferences,
ILcdFilter<ILcdModel> aModelFilter)
Create a new raster format
|
Modifier and Type | Method and Description |
---|---|
protected ILspLayerFactory |
createLayerFactoryImpl()
Creates the layer factory for this format.
|
protected ILcdLayerMeasureProviderFactory |
createLayerMeasureProviderFactory()
Creates a
ILcdLayerMeasureProviderFactory that can create measure providers for
a layer created by the layer factories of this format. |
protected void |
customizeLayer(ILspEditableStyledLayer aRasterLayer)
Each layer created by the layer factory of this format is passed to this method.
|
createAll, createLayerStyleCodecFileTypeDescriptors, createLayerStyleCodecImpl, createLayerStyleCodecs, createLayerStyleProviders, retrieveFeatureTypeStyle
canHandleModel, createLayerFactory
getLongPrefix, getLucyEnv, getProperties, getShortPrefix
checkInitialized, createBalloonContentProviders, createFormatBarFactory, createLayerContextOfFormatFilter, createLayerCustomizerPanelFactories, createLayerCustomizerPanelWorkspaceCodecs, createLayerSelectionTransferHandlers, createLayerWorkspaceCodecs, getBalloonContentProviders, getFormatBarFactory, getLayerCustomizerPanelFactories, getLayerCustomizerPanelWorkspaceCodecs, getLayerFactory, getLayerMeasureProviderFactory, getLayerSelectionTransferHandlers, getLayerStyleCodecFileTypeDescriptors, getLayerStyleCodecs, getLayerStyleProviders, getLayerWorkspaceCodecs, isLayerOfFormat, toString
public TLcyLspRasterFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aPreferences, ILcdFilter<ILcdModel> aModelFilter)
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 be null
. null
models will
never be passed to the filter, but always rejected.protected final ILspLayerFactory createLayerFactoryImpl()
ALcyLspStyleFormat
Creates the layer factory for this format. This method will be called from the ALcyLspStyleFileFormat.createLayerFactory()
method. This factory must not return ILcdLayerTreeNode
instances. In case you want
to support empty nodes, consider using a TLcyLspLayerTreeNodeFormatWrapper
.
The layers returned by this layer factory should match the following requirements:
ILspStyledLayer
interface.TLspShapeLayerBuilder.sldStyle(TLcdSLDFeatureTypeStyle)
or TLspRasterLayerBuilder.sldStyle(TLcdSLDFeatureTypeStyle)
.REGULAR_BODY
and the
REGULAR_LABEL
stylers must be ILspCustomizableStyler
instances containing regular
ALspStyle
instances.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;
}
};
createLayerFactoryImpl
in class ALcyLspStyleFormat
null
protected void customizeLayer(ILspEditableStyledLayer aRasterLayer)
Each layer created by the layer factory of this format is passed to this method. Overriding this method allows to make changes to the created layers, for example adjusting the icon of the layer.
If you need to make major changes to the layer (for example setting a new painter), it is recommended
to extend from ALcyLspStyleFormat
directly instead of using this format.
Warning: the layers must fulfil the requirements documented in the createLayerFactoryImpl()
method.
aRasterLayer
- The layer created by the layer factory.protected ILcdLayerMeasureProviderFactory createLayerMeasureProviderFactory()
Creates a ILcdLayerMeasureProviderFactory
that can create measure providers for
a layer created by the layer factories of this format.
These measurements could for example used by a mouse readout to display the measure value at the current location of the mouse cursor.
createLayerMeasureProviderFactory
in class ALcyLspFormat
ILcdLayerMeasureProviderFactory
instance. Can be null
.ALcyLspFormat.getLayerMeasureProviderFactory()