Package com.luciad.lucy.map.asynchronous
Class TLcyGXYAsynchronousLayerWorkspaceCodec
java.lang.Object
com.luciad.lucy.workspace.ALcyWorkspaceObjectCodec
com.luciad.lucy.map.asynchronous.TLcyGXYAsynchronousLayerWorkspaceCodec
Asynchronous layer workspace codec, wrapping around an existing codec.
It allows to easily convert a layer workspace codec into a codec that supports asynchronous painting.
In particular, the wrapper enables asynchronous painting for the wrapped codec's created layers. It also ensures that the codec methods do not interfere with asynchronous painting.
-
Constructor Summary
ConstructorsConstructorDescriptionTLcyGXYAsynchronousLayerWorkspaceCodec(ILcyLucyEnv aLucyEnv, ALcyWorkspaceObjectCodec aCodec, ILcdFilter aAsynchronousLayerFilter) Creates a new layer workspace codec. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEncodeObject(ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent) This method returns true if the givenObjectcan be encoded, false otherwise.createObject(ALcyWorkspaceCodec aWSCodec, Object aParent, InputStream aIn) This method creates an asynchronously paintedILcdGXYLayerfor representing anILcdModelon anILcdGXYView.voiddecodeObject(ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent, InputStream aIn) This method decodes the properties of anObjectcreated byALcyWorkspaceObjectCodec.createObject(ALcyWorkspaceCodec, Object, java.io.InputStream)from the givenInputStream.voidencodeObject(ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent, OutputStream aOut) This method writes the givenObjectto the givenOutputStream.getUID()A unique identifier for thisALcyWorkspaceObjectCodec.
-
Constructor Details
-
TLcyGXYAsynchronousLayerWorkspaceCodec
public TLcyGXYAsynchronousLayerWorkspaceCodec(ILcyLucyEnv aLucyEnv, ALcyWorkspaceObjectCodec aCodec, ILcdFilter aAsynchronousLayerFilter) Creates a new layer workspace codec.- Parameters:
aLucyEnv- Lucy environmentaCodec- existing codec to wrap. Calls pertaining to an asynchronously painted layer will be delegated using a safe layer. Created layers will be made asynchronous.aAsynchronousLayerFilter- the filter to use to determine if a created layer should be painted asynchronously. If null, all created layers are painted asynchronously.
-
-
Method Details
-
getUID
Description copied from class:ALcyWorkspaceObjectCodecA unique identifier for thisALcyWorkspaceObjectCodec. The UID will be used to make sure that a workspace part that is encoded by aALcyWorkspaceObjectCodecwith some UID can only be decoded by aALcyWorkspaceObjectCodecwith the same UID. For this purpose it is mandatory that, whenever the application is restarted,ALcyWorkspaceObjectCodec's with the same UID's are registered with theTLcyWorkspaceManager. Unique means that at any time no twoALcyWorkspaceObjectCodecs orALcyWorkspaceCodecDelegates with the samegetUID()must be registered with the sameTLcyWorkspaceManager. Therefore it is suggested to use a package name prefix for the UID's. The UID's of allALcyWorkspaceCodecDelegates added by Lucy itself start with "com.luciad". The UID must not be 'null', must not be the empty string "", must not contain spaces and must not start with '%'- Specified by:
getUIDin classALcyWorkspaceObjectCodec- Returns:
- The UID for this
ALcyWorkspaceObjectCodec.
-
canEncodeObject
Description copied from class:ALcyWorkspaceObjectCodecThis method returns true if the givenObjectcan be encoded, false otherwise. This method should only be invoked by anALcyWorkspaceCodec, never by user code. Instead user code must useALcyWorkspaceCodec.canEncodeReference(Object, Object)when an object reference needs to be restored.- Specified by:
canEncodeObjectin classALcyWorkspaceObjectCodec- Parameters:
aWSCodec- TheALcyWorkspaceCodec, provided in case object references need to be stored.aObject- The object to encode.aParent- The parent of the object to encode. The parent will often be null, or for example when a domain objects needs to be saved (e.g. a polyline), the parent will normally be theILcdModelthat contains the domain object. The exact value of the parent is defined by theALcyWorkspaceObjectCodecthat will encode the object. Please check the javadoc of the addon responsible for the object to encode or refer to the Lucy Developer Guide for more information.- Returns:
- True if the given
Objectcan be encoded, false otherwise.
-
encodeObject
public void encodeObject(ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent, OutputStream aOut) throws IOException Description copied from class:ALcyWorkspaceObjectCodecThis method writes the givenObjectto the givenOutputStream. This method should only be invoked by anALcyWorkspaceCodec, never by user code. Instead user code must useALcyWorkspaceCodec.encodeReference(Object, Object)when an object reference needs to be stored. Note that this method must, in general, be re-entrant: this method can be invoked by a thread before the previous call on that same thread is terminated. This happens when this method stores references (ALcyWorkspaceCodec.encodeReference(Object, Object)) to objects that are encoded by this codec as well. Or if it stores references to objects that (indirectly) refer objects that are encoded by this codec.- Specified by:
encodeObjectin classALcyWorkspaceObjectCodec- Parameters:
aWSCodec- TheALcyWorkspaceCodec, provided in case object references need to be stored.aObject- The object to encode.aParent- The parent of the object to encode. The parent will often be null, or for example when a domain objects needs to be saved (e.g. a polyline), the parent will normally be theILcdModelthat contains the domain object. The exact value of the parent is defined by theALcyWorkspaceObjectCodecthat will encode the object. Please check the javadoc of the addon responsible for the object to encode or refer to the Lucy Developer Guide for more information.aOut- TheOutputStreamto write to.- Throws:
IOException- In case of IO failure.
-
createObject
public Object createObject(ALcyWorkspaceCodec aWSCodec, Object aParent, InputStream aIn) throws IOException This method creates an asynchronously paintedILcdGXYLayerfor representing anILcdModelon anILcdGXYView. It creates a layer using the wrapped codec and makes it asynchronous if it is accepted by the asynchronous layer filter, usingALcyAsynchronousPaintFacade.createGXYAsynchronousLayer(com.luciad.view.gxy.ILcdGXYLayer)- Specified by:
createObjectin classALcyWorkspaceObjectCodec- Parameters:
aWSCodec- TheALcyWorkspaceCodec.aParent- The parent of the object to decode. The parent will often be null, or for example when a domain objects needs to be restored (e.g. a polyline), the parent will normally be theILcdModelthat must contain the domain object. The exact value of the parent is defined by theALcyWorkspaceObjectCodecthat will decode the object. Please check the javadoc of the addon responsible for the object to decode or refer to the Lucy Developer Guide for more information.aIn- TheInputStream. Normally this method will not read from the input stream!- Returns:
- a synchronously or asynchronously painted
ILcdGXYLayer - Throws:
IOException- In case of an io failure.
-
decodeObject
public void decodeObject(ALcyWorkspaceCodec aWSCodec, Object aObject, Object aParent, InputStream aIn) throws IOException Description copied from class:ALcyWorkspaceObjectCodecThis method decodes the properties of anObjectcreated byALcyWorkspaceObjectCodec.createObject(ALcyWorkspaceCodec, Object, java.io.InputStream)from the givenInputStream. The decision if this codec can read from theInputStreamis based on theALcyWorkspaceObjectCodec.getUID()of this codec. If theObjectwas written by a codec with the same UID as this codec, it is assumed that this codec can read from theInputStream. The decoding of an object is split intocreateObjectanddecodeObjectto be able to deal with circular references. Preferably object references should be restored from this method. (by usingALcyWorkspaceCodec.decodeReference(String)). There are however a lot of codecs which don't need to do anything in this method. Therefore this method is not abstract, and the default implementation does nothing. This method should only be invoked by anALcyWorkspaceCodec, never by user code. Instead user code must useALcyWorkspaceCodec.decodeReference(String)when an object reference needs to be restored. Note that this method must, in general, be re-entrant: this method can be invoked by a thread before the previous call on that same thread is terminated. This happens when this method restores references (ALcyWorkspaceCodec.decodeReference(String)) to objects that are decoded by this codec as well. Or if it restores references to objects that (indirectly) refer objects that are decoded by this codec.- Overrides:
decodeObjectin classALcyWorkspaceObjectCodec- Parameters:
aWSCodec- TheALcyWorkspaceCodec, provided in case object references need to be restored.aObject- The object to decode the properties of. It was created usingALcyWorkspaceObjectCodec.createObject(ALcyWorkspaceCodec, Object, java.io.InputStream).aParent- The parent of the object to decode. The parent will often be null, or for example when a domain objects needs to be restored (e.g. a polyline), the parent will normally be theILcdModelthat must contain the domain object. The exact value of the parent is defined by theALcyWorkspaceObjectCodecthat will decode the object. Please check the javadoc of the addon responsible for the object to decode or refer to the Lucy Developer Guide for more information.aIn- TheInputStreamto read from.- Throws:
IOException- In case of IO failure.
-