public class TLcyLspSafeGuardFormatWrapper extends ALcyLspFormatWrapper
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.Constructor and Description |
---|
TLcyLspSafeGuardFormatWrapper(ALcyLspFormat aFormat)
Creates a new
TLcyLspSafeGuardFormatWrapper around the given
ALcyLspFormat |
Modifier and Type | Method and Description |
---|---|
boolean |
canHandleModel(ILcdModel aModel)
Returns
true if and only if the given model can be visualized by this format. |
protected ILcdBalloonContentProvider[] |
createBalloonContentProviders()
Creates the
ILcdBalloonContentProvider s for this format. |
protected ALcyFormatBarFactory |
createFormatBarFactory()
Creates the
ALcyFormatBarFactory that can create a bar to manipulate layers of
this format. |
protected ILcyCustomizerPanelFactory[] |
createLayerCustomizerPanelFactories()
Creates the
ILcyCustomizerPanelFactory factories that can create
ILcyCustomizerPanel instances for the layers created by the layer factories of
this format. |
protected ALcyWorkspaceObjectCodec[] |
createLayerCustomizerPanelWorkspaceCodecs()
Creates the
ALcyWorkspaceObjectCodec codecs for the
ILcyCustomizerPanel instances for the layers created by the layer factories of
this format. |
ILspLayerFactory |
createLayerFactory()
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 ALcyLayerSelectionTransferHandler[] |
createLayerSelectionTransferHandlers()
Creates the
ALcyLayerSelectionTransferHandler transfer handlers that can
transfer the selection of the layers created by the layer factories of this format. |
ILcyLayerStyleCodec[] |
createLayerStyleCodecs()
Creates the
ILcyLayerStyleCodec instances which can encode/decode the style of
the layers created by the layer factory of this format. |
ILcyLayerStyleProvider[] |
createLayerStyleProviders()
Creates the style provider instances that can retrieve and encode the style of the layers
created by the layer factory of this format.
|
ALcyWorkspaceObjectCodec[] |
createLayerWorkspaceCodecs()
Creates the
ALcyWorkspaceObjectCodec s that can encode the state of the layers
created by the layer factory of this format. |
boolean |
isLayerOfFormat(ILspLayer aLayer)
Returns
true if and only if the given layer is a layer of this format. |
createAll, createLayerStyleCodecFileTypeDescriptors, getFormat, getLongPrefix, getLucyEnv, getShortPrefix
checkInitialized, createLayerContextOfFormatFilter, getBalloonContentProviders, getFormatBarFactory, getLayerCustomizerPanelFactories, getLayerCustomizerPanelWorkspaceCodecs, getLayerFactory, getLayerMeasureProviderFactory, getLayerSelectionTransferHandlers, getLayerStyleCodecFileTypeDescriptors, getLayerStyleCodecs, getLayerStyleProviders, getLayerWorkspaceCodecs, toString
public TLcyLspSafeGuardFormatWrapper(ALcyLspFormat aFormat)
TLcyLspSafeGuardFormatWrapper
around the given
ALcyLspFormat
aFormat
- The format to wrappublic ILspLayerFactory 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.
createLayerFactory
in class ALcyLspFormatWrapper
ILspLayerFactory
for this format. May be null
ALcyLspFormat.getLayerFactory()
protected ILcdBalloonContentProvider[] 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.
createBalloonContentProviders
in class ALcyLspFormatWrapper
ILcdBalloonContentProvider
s for this format. Must not be
null
. The array may be empty but must not contain null
.ALcyLspFormat.getBalloonContentProviders()
public ILcyLayerStyleProvider[] 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.
createLayerStyleProviders
in class ALcyLspFormatWrapper
null
. The array may be empty, but must not contain null
.ALcyLspFormat.getLayerStyleProviders()
public ILcyLayerStyleCodec[] 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.
createLayerStyleCodecs
in class ALcyLspFormatWrapper
ILcyLayerStyleCodec
instances. Must not be null
.
The array may be empty, but must not contain null
.ALcyLspFormat.getLayerStyleCodecs()
,
ALcyLspFormat.createLayerStyleCodecFileTypeDescriptors()
protected ILcyCustomizerPanelFactory[] createLayerCustomizerPanelFactories()
Creates the ILcyCustomizerPanelFactory
factories that can create
ILcyCustomizerPanel
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, see
TLcyLspStyledLayerCustomizerPanelFactory
.
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.
createLayerCustomizerPanelFactories
in class ALcyLspFormatWrapper
ILcyCustomizerPanelFactory
instances. Must not be
null
. The array may be empty, but must not contain null
.ALcyLspFormat.getLayerCustomizerPanelFactories()
protected ALcyWorkspaceObjectCodec[] createLayerCustomizerPanelWorkspaceCodecs()
Creates the ALcyWorkspaceObjectCodec
codecs for the
ILcyCustomizerPanel
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.
createLayerCustomizerPanelWorkspaceCodecs
in class ALcyLspFormatWrapper
ALcyWorkspaceObjectCodec
instances. Must not be
null
, but may have length 0
. Must not contain
null
.ALcyLspFormat.getLayerCustomizerPanelWorkspaceCodecs()
public ALcyWorkspaceObjectCodec[] 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.
createLayerWorkspaceCodecs
in class ALcyLspFormatWrapper
ALcyWorkspaceObjectCodec
s to encode the state of the layers.
May be empty but not null
. Must not contain null
ALcyLspFormat.getLayerWorkspaceCodecs()
protected ALcyLayerSelectionTransferHandler[] 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.
createLayerSelectionTransferHandlers
in class ALcyLspFormatWrapper
ALcyLayerSelectionTransferHandler
instances. Must not be
null
but may have length 0
. Must not contain
null
.ALcyLspFormat.getLayerSelectionTransferHandlers()
protected ALcyFormatBarFactory 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.
createFormatBarFactory
in class ALcyLspFormatWrapper
ALcyFormatBarFactory
. May be null
.protected ILcdLayerMeasureProviderFactory 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.
createLayerMeasureProviderFactory
in class ALcyLspFormatWrapper
ILcdLayerMeasureProviderFactory
instance. Can be null
.ALcyLspFormat.getLayerMeasureProviderFactory()
public boolean isLayerOfFormat(ILspLayer aLayer)
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 whether aLayer
is a layer of this format.
This class keeps track of all layers created in this format, and only returns true
for those layers.
isLayerOfFormat
in class ALcyLspFormatWrapper
aLayer
- The layer to checktrue
if and only if the given layer is a layer of this formatpublic boolean canHandleModel(ILcdModel aModel)
ALcyLspFormat
Returns true
if and only if the given model can be visualized by this format.
canHandleModel
in class ALcyLspFormatWrapper
aModel
- The model to checktrue
if and only if the given model can be visualized by this format.