public class MeshUpdateHandler extends java.lang.Object implements IUpdateableListener
MeshComponent
updates for a
MeshAppState
. The reason this is handled in this class is two-fold:
First, the IUpdateableListener.update(IUpdateable)
method does not
give away any more information about the prospective update other than that
something has changed. This means that each update from the
MeshComponent
requires a comprehensive comparison with what is
currently displayed in the MeshAppState
. In other words, the
method implementing the update is heavy-weight, and multiple updates cannot
be performed simultaneously.
Second, we need to process all updates. Since the update process may take a significant period, it is possible that several consecutive notifications from the MeshComponent arrive while the MeshApplication is already updating. Instead of running the update n times for n calls, only the current update and the last remaining update need to be handled.
component
Constructor and Description |
---|
MeshUpdateHandler()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
setMesh(MeshComponent mesh)
Changes the mesh that is currently being listened to.
|
void |
start(MeshAppState app)
Starts the
MeshUpdateHandler so that updates from a
MeshComponent can be handled one at a time and reduced in
number when multiple updates are required at the same time. |
void |
stop()
Stops the
MeshUpdateHandler . |
void |
update(IUpdateable component)
Notifies the
MeshUpdateHandler of another mesh update. |
public void setMesh(MeshComponent mesh)
mesh
- The new mesh to listen to.public void start(MeshAppState app)
MeshUpdateHandler
so that updates from a
MeshComponent
can be handled one at a time and reduced in
number when multiple updates are required at the same time.app
- The MeshAppState
that needs to update based on
changes in the mesh.public void stop()
MeshUpdateHandler
.public void update(IUpdateable component)
MeshUpdateHandler
of another mesh update.update
in interface IUpdateableListener
component
- The component that was updated in some way.