Class TLcyLspSafeGuardFormatWrapper
Decorator for an ALcyLspFormat that safe guards all operations on layers to make
sure no invalid layers are ever accepted or handled. It relies on the implementation of ALcyLspFormat.canHandleModel(com.luciad.model.ILcdModel) of the given format to determine which models
are passed to the layer factory. In order to decide which layers are accepted or handled, it keeps track
of all layers created by this format in either the layer factory or the layer workspace codec. Only the instances
created in this format will be accepted.
As a result, implementers of an ALcyLspFormat can simplify this type of code:
protected ALcyWorkspaceObjectCodec[] createLayerWorkspaceObjectCodec() {
return new ALcyWorkspaceObjectCodec[]{new ALcyWorkspaceObjectCodec() {
public boolean canEncodeObject( ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent ) {
return aObject instanceof ILspLayer && isLayerOfFormat( ( ILspLayer ) aObject );
}
public void encodeObject( ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent, OutputStream aOut ) throws IOException, TLcyWorkspaceAbortedException {
//do something
}
}};
}
to this:
protected ALcyWorkspaceObjectCodec[] createLayerWorkspaceObjectCodec() {
return new ALcyWorkspaceObjectCodec[]{new ALcyWorkspaceObjectCodec() {
public boolean canEncodeObject( ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent ) {
return true;
}
public void encodeObject( ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent, OutputStream aOut ) throws IOException, TLcyWorkspaceAbortedException {
//do something
}
}};
}
which is easier and less error prone. Similar simplifications apply to all other concepts
such as ILspLayerFactory, ILcyCustomizerPanelFactory etc.- Since:
- 2012.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTLcyLspSafeGuardFormatWrapperaround the givenALcyLspFormat -
Method Summary
Modifier and TypeMethodDescriptionbooleancanHandleModel(ILcdModel aModel) Returnstrueif and only if the given model can be visualized by this format.protected ILcdBalloonContentProvider[]Creates theILcdBalloonContentProviders for this format.protected ALcyFormatBarFactoryCreates theALcyFormatBarFactorythat can create a bar to manipulate layers of this format.protected ILcyCustomizerPanelFactory[]Creates theILcyCustomizerPanelFactoryfactories that can createILcyCustomizerPanelinstances for the layers created by the layer factories of this format.protected ALcyWorkspaceObjectCodec[]Creates theALcyWorkspaceObjectCodeccodecs for theILcyCustomizerPanelinstances for the layers created by the layer factories of this format.Creates the layer factory for this format.protected ILcdLayerMeasureProviderFactoryCreates aILcdLayerMeasureProviderFactorythat can create measure providers for a layer created by the layer factories of this format.protected ALcyLayerSelectionTransferHandler[]Creates theALcyLayerSelectionTransferHandlertransfer handlers that can transfer the selection of the layers created by the layer factories of this format.Creates theILcyLayerStyleCodecinstances which can encode/decode the style of the layers created by the layer factory of this format.Creates the style provider instances that can retrieve and encode the style of the layers created by the layer factory of this format.Creates theALcyWorkspaceObjectCodecs that can encode the state of the layers created by the layer factory of this format.booleanisLayerOfFormat(ILspLayer aLayer) Returnstrueif and only if the given layer is a layer of this format.Methods inherited from class com.luciad.lucy.format.lightspeed.ALcyLspFormatWrapper
createAll, createLayerStyleCodecFileTypeDescriptors, getFormat, getLongPrefix, getLucyEnv, getShortPrefixMethods inherited from class com.luciad.lucy.format.lightspeed.ALcyLspFormat
checkInitialized, createLayerContextOfFormatFilter, getBalloonContentProviders, getFormatBarFactory, getLayerCustomizerPanelFactories, getLayerCustomizerPanelWorkspaceCodecs, getLayerFactory, getLayerMeasureProviderFactory, getLayerSelectionTransferHandlers, getLayerStyleCodecFileTypeDescriptors, getLayerStyleCodecs, getLayerStyleProviders, getLayerWorkspaceCodecs, toString
-
Constructor Details
-
TLcyLspSafeGuardFormatWrapper
Creates a newTLcyLspSafeGuardFormatWrapperaround the givenALcyLspFormat- Parameters:
aFormat- The format to wrap
-
-
Method Details
-
createLayerFactory
Creates the layer factory for this format. The default implementation returns
null.This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against model instances which do not pass the
canHandleModelmethod of this format.- Overrides:
createLayerFactoryin classALcyLspFormatWrapper- Returns:
- The
ILspLayerFactoryfor this format. May benull - See Also:
-
createBalloonContentProviders
Creates the
ILcdBalloonContentProviders for this format.The default implementation returns an empty array.
This implementations returns the instance created by the decorated format.
The returned instances will be safe-guarded against
TLcdModelElementBalloonDescriptorinstances where the layer does not belong to the format.- Overrides:
createBalloonContentProvidersin classALcyLspFormatWrapper- Returns:
- the
ILcdBalloonContentProviders for this format. Must not benull. The array may be empty but must not containnull. - 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.
This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createLayerStyleProvidersin classALcyLspFormatWrapper- 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
Creates the
ILcyLayerStyleCodecinstances which can encode/decode the style of the layers created by the layer factory of this format.The default implementation returns an empty array.
This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createLayerStyleCodecsin classALcyLspFormatWrapper- Returns:
- an array of
ILcyLayerStyleCodecinstances. Must not benull. The array may be empty, but must not containnull. - See Also:
-
createLayerCustomizerPanelFactories
Creates the
ILcyCustomizerPanelFactoryfactories that can createILcyCustomizerPanelinstances for the layers created by the layer factories of this format.The default implementation returns a zero-length array.
If you're looking for the fall back behavior when no factories are registered, see
TLcyLspLayerCustomizerAddOn. If you want to customize the behavior for this format only, seeTLcyLspStyledLayerCustomizerPanelFactory.This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createLayerCustomizerPanelFactoriesin classALcyLspFormatWrapper- Returns:
- An array of
ILcyCustomizerPanelFactoryinstances. Must not benull. The array may be empty, but must not containnull. - See Also:
-
createLayerCustomizerPanelWorkspaceCodecs
Creates the
ALcyWorkspaceObjectCodeccodecs for theILcyCustomizerPanelinstances for the layers created by the layer factories of this format.This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createLayerCustomizerPanelWorkspaceCodecsin classALcyLspFormatWrapper- Returns:
- An array containing the
ALcyWorkspaceObjectCodecinstances. Must not benull, but may have length0. Must not containnull. - See Also:
-
createLayerWorkspaceCodecs
Creates the
ALcyWorkspaceObjectCodecs that can encode the state of the layers created by the layer factory of this format.The default implementation returns an array with a single codec which uses the layer factory and the layer style codecs of the format.
This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createLayerWorkspaceCodecsin classALcyLspFormatWrapper- Returns:
- The array of
ALcyWorkspaceObjectCodecs to encode the state of the layers. May be empty but notnull. Must not containnull - See Also:
-
createLayerSelectionTransferHandlers
Creates the
ALcyLayerSelectionTransferHandlertransfer handlers that can transfer the selection of the layers created by the layer factories of this format.The default implementation returns a zero-length array.
This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createLayerSelectionTransferHandlersin classALcyLspFormatWrapper- Returns:
- An array of
ALcyLayerSelectionTransferHandlerinstances. Must not benullbut may have length0. Must not containnull. - See Also:
-
createFormatBarFactory
Creates the
ALcyFormatBarFactorythat can create a bar to manipulate layers of this format.The default implementation returns
null.This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createFormatBarFactoryin classALcyLspFormatWrapper- Returns:
- An
ALcyFormatBarFactory. May benull.
-
createLayerMeasureProviderFactory
Creates a
ILcdLayerMeasureProviderFactorythat can create measure providers for a layer created by the layer factories of this format.The default implementation returns
null.This implementations returns the instance created by the decorated format.
The returned instance will be safe-guarded against layer instances that were not created by this format.
- Overrides:
createLayerMeasureProviderFactoryin classALcyLspFormatWrapper- Returns:
- an
ILcdLayerMeasureProviderFactoryinstance. Can benull. - See Also:
-
isLayerOfFormat
Returns
trueif and only if the given layer is a layer of this format.The default implementation uses the
ALcyLspFormat.canHandleModel(com.luciad.model.ILcdModel)to determine whetheraLayeris a layer of this format.This class keeps track of all layers created in this format, and only returns
truefor those layers.- Overrides:
isLayerOfFormatin classALcyLspFormatWrapper- Parameters:
aLayer- The layer to check- Returns:
trueif and only if the given layer is a layer of this format
-
canHandleModel
Description copied from class:ALcyLspFormatReturns
trueif and only if the given model can be visualized by this format.- Overrides:
canHandleModelin classALcyLspFormatWrapper- Parameters:
aModel- The model to check- Returns:
trueif and only if the given model can be visualized by this format.
-