public class TLcyLspVectorFormat extends ALcyLspStyleFormat
Extension of ALcyLspStyleFormat
for simple vector formats. It provides a custom
implementation of the createLayerFactoryImpl()
method, which supports most ILcdShape
objects. 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. setting the layer
labeled by default). When you have to set another painter, ... it is recommended to extend from
ALcyLspStyleFileFormat
directly.
This format assumes all objects can be draped. You can adjust the draping settings in the default
style file associated to the format (see DEFAULT_STYLE_FILE_SUFFIX
). In case you have different
draping settings for individual objects you should extend from ALcyLspStyleFormat
directly and
implement a custom styler.
Warning: this format should be wrapped with a TLcyLspSafeGuardFormatWrapper
before plugging it into the Lucy back-end.
TLcyLspRasterFormat
DEFAULT_STYLE_FILE_SUFFIX
Constructor and Description |
---|
TLcyLspVectorFormat(ILcyLucyEnv aLucyEnv,
String aLongPrefix,
String aShortPrefix,
ALcyProperties aPreferences,
ILcdFilter<ILcdModel> aModelFilter)
Create a new vector format
|
Modifier and Type | Method and Description |
---|---|
protected ILspLayerFactory |
createLayerFactoryImpl()
Creates the layer factory for this format.
|
protected void |
customizeLayer(ILspInteractivePaintableLayer aLayer)
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, createLayerMeasureProviderFactory, createLayerSelectionTransferHandlers, createLayerWorkspaceCodecs, getBalloonContentProviders, getFormatBarFactory, getLayerCustomizerPanelFactories, getLayerCustomizerPanelWorkspaceCodecs, getLayerFactory, getLayerMeasureProviderFactory, getLayerSelectionTransferHandlers, getLayerStyleCodecFileTypeDescriptors, getLayerStyleCodecs, getLayerStyleProviders, getLayerWorkspaceCodecs, isLayerOfFormat, toString
public TLcyLspVectorFormat(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(ILspInteractivePaintableLayer aLayer)
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 visibility of the labels.
If you need to make major changes to the layer (for example setting a new styler), 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.
aLayer
- The layer created by the layer factory.