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
ConstructorDescriptionCreates a newTLcyLspSafeGuardFormatWrapper
around the givenALcyLspFormat
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandleModel
(ILcdModel aModel) Returnstrue
if and only if the given model can be visualized by this format.protected ILcdBalloonContentProvider[]
Creates theILcdBalloonContentProvider
s for this format.protected ALcyFormatBarFactory
Creates theALcyFormatBarFactory
that can create a bar to manipulate layers of this format.protected ILcyCustomizerPanelFactory[]
Creates theILcyCustomizerPanelFactory
factories that can createILcyCustomizerPanel
instances for the layers created by the layer factories of this format.protected ALcyWorkspaceObjectCodec[]
Creates theALcyWorkspaceObjectCodec
codecs for theILcyCustomizerPanel
instances for the layers created by the layer factories of this format.Creates the layer factory for this format.protected ILcdLayerMeasureProviderFactory
Creates aILcdLayerMeasureProviderFactory
that can create measure providers for a layer created by the layer factories of this format.protected ALcyLayerSelectionTransferHandler[]
Creates theALcyLayerSelectionTransferHandler
transfer handlers that can transfer the selection of the layers created by the layer factories of this format.Creates theILcyLayerStyleCodec
instances 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 theALcyWorkspaceObjectCodec
s that can encode the state of the layers created by the layer factory of this format.boolean
isLayerOfFormat
(ILspLayer aLayer) Returnstrue
if 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, getShortPrefix
Methods 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 newTLcyLspSafeGuardFormatWrapper
around 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
canHandleModel
method of this format.- Overrides:
createLayerFactory
in classALcyLspFormatWrapper
- Returns:
- The
ILspLayerFactory
for this format. May benull
- See Also:
-
createBalloonContentProviders
Creates the
ILcdBalloonContentProvider
s 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
TLcdModelElementBalloonDescriptor
instances where the layer does not belong to the format.- Overrides:
createBalloonContentProviders
in classALcyLspFormatWrapper
- Returns:
- the
ILcdBalloonContentProvider
s 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:
createLayerStyleProviders
in 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
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.
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:
createLayerStyleCodecs
in classALcyLspFormatWrapper
- Returns:
- an array of
ILcyLayerStyleCodec
instances. Must not benull
. The array may be empty, but must not containnull
. - See Also:
-
createLayerCustomizerPanelFactories
Creates the
ILcyCustomizerPanelFactory
factories that can createILcyCustomizerPanel
instances 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:
createLayerCustomizerPanelFactories
in classALcyLspFormatWrapper
- Returns:
- An array of
ILcyCustomizerPanelFactory
instances. Must not benull
. The array may be empty, but must not containnull
. - See Also:
-
createLayerCustomizerPanelWorkspaceCodecs
Creates the
ALcyWorkspaceObjectCodec
codecs for theILcyCustomizerPanel
instances 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:
createLayerCustomizerPanelWorkspaceCodecs
in classALcyLspFormatWrapper
- Returns:
- An array containing the
ALcyWorkspaceObjectCodec
instances. Must not benull
, but may have length0
. Must not containnull
. - See Also:
-
createLayerWorkspaceCodecs
Creates the
ALcyWorkspaceObjectCodec
s 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:
createLayerWorkspaceCodecs
in classALcyLspFormatWrapper
- Returns:
- The array of
ALcyWorkspaceObjectCodec
s to encode the state of the layers. May be empty but notnull
. Must not containnull
- See Also:
-
createLayerSelectionTransferHandlers
Creates the
ALcyLayerSelectionTransferHandler
transfer 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:
createLayerSelectionTransferHandlers
in classALcyLspFormatWrapper
- Returns:
- An array of
ALcyLayerSelectionTransferHandler
instances. Must not benull
but may have length0
. Must not containnull
. - See Also:
-
createFormatBarFactory
Creates the
ALcyFormatBarFactory
that 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:
createFormatBarFactory
in classALcyLspFormatWrapper
- Returns:
- An
ALcyFormatBarFactory
. May benull
.
-
createLayerMeasureProviderFactory
Creates a
ILcdLayerMeasureProviderFactory
that 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:
createLayerMeasureProviderFactory
in classALcyLspFormatWrapper
- Returns:
- an
ILcdLayerMeasureProviderFactory
instance. Can benull
. - See Also:
-
isLayerOfFormat
Returns
true
if 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 whetheraLayer
is a layer of this format.This class keeps track of all layers created in this format, and only returns
true
for those layers.- Overrides:
isLayerOfFormat
in classALcyLspFormatWrapper
- Parameters:
aLayer
- The layer to check- Returns:
true
if and only if the given layer is a layer of this format
-
canHandleModel
Description copied from class:ALcyLspFormat
Returns
true
if and only if the given model can be visualized by this format.- Overrides:
canHandleModel
in classALcyLspFormatWrapper
- Parameters:
aModel
- The model to check- Returns:
true
if and only if the given model can be visualized by this format.
-