org.ascape.view.nonvis
Class ScapeStateView

java.lang.Object
  extended by org.ascape.model.event.DefaultScapeListener
      extended by org.ascape.view.nonvis.NonGraphicView
          extended by org.ascape.view.nonvis.ScapeStateView
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.EventListener, ScapeListener, HasName

public class ScapeStateView
extends NonGraphicView

A view providing notification when a scape transitions from one state to another. For example, when a scape was paused and is now resumed, an apporiate method will be called. Additionally, this view also guarantees that updateScapeGraphics of the view at least 6 times a second regardless of the nature of the scape notification. This will allow pauses and resumes to be noticed in time to immediatly alert the user, regardless of what is happening with the model.

Since:
3.0
Version:
5.0
Author:
Miles Parker
See Also:
Serialized Form

Field Summary
protected  boolean lastScapeAppearsPaused
          Did the scape appear to be paused last iteration?.
 
Fields inherited from class org.ascape.model.event.DefaultScapeListener
listeningToScape, name, scape
 
Constructor Summary
ScapeStateView()
           
 
Method Summary
 void environmentNowNoScape()
          Environment now no scape.
 void environmentNowScape()
          Environment now scape.
protected  long getLastUpdateInMillis()
           
protected  long getMaxMillisBetweenUpdates()
           
 boolean isLifeOfScape()
          Returns true if the listener is intended to be used only for the current scape; in this case returns false because control views typically will exist for multiple scapes.
 void scapeAdded(ScapeEvent scapeEvent)
          Called on interation; delays models return by delay slider setting.
 void scapeNotification(ScapeEvent scapeEvent)
          Notifies this view that something has happened on the scape.
 void scapeNowPaused()
          Scape now paused.
 void scapeNowResumed()
          Scape now resumed.
 void scapeNowRunning()
          Scape now running.
 void scapeNowSteppable()
          Scape now steppable.
 void scapeNowStopped()
          Scape now stopped.
 void scapeRemoved(ScapeEvent scapeEvent)
          Called on interation; delays models return by delay slider setting.
protected  void setLastUpdateInMillis(long lastUpdateInMillis)
           
protected  void setMaxMillisBetweenUpdates(long maxMillisBetweenUpdates)
           
 void updateScapeState()
          Allow for overriding thread implementations.
 void updateScapeStateImpl()
          Update the components.
 
Methods inherited from class org.ascape.view.nonvis.NonGraphicView
isGraphic
 
Methods inherited from class org.ascape.model.event.DefaultScapeListener
clone, environmentQuiting, getName, getScape, isNotifyScapeAutomatically, notifyScapeUpdated, scapeClosing, scapeDeserialized, scapeInitialized, scapeIterated, scapeSetup, scapeStarted, scapeStopped, setName, setNotifyScapeAutomatically, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lastScapeAppearsPaused

protected boolean lastScapeAppearsPaused
Did the scape appear to be paused last iteration?.

Constructor Detail

ScapeStateView

public ScapeStateView()
Method Detail

scapeNowRunning

public void scapeNowRunning()
Scape now running.


scapeNowStopped

public void scapeNowStopped()
Scape now stopped.


scapeNowPaused

public void scapeNowPaused()
Scape now paused.


scapeNowResumed

public void scapeNowResumed()
Scape now resumed.


scapeNowSteppable

public void scapeNowSteppable()
Scape now steppable.


environmentNowScape

public void environmentNowScape()
Environment now scape.


environmentNowNoScape

public void environmentNowNoScape()
Environment now no scape.


scapeAdded

public void scapeAdded(ScapeEvent scapeEvent)
                throws java.util.TooManyListenersException
Called on interation; delays models return by delay slider setting.

Specified by:
scapeAdded in interface ScapeListener
Overrides:
scapeAdded in class DefaultScapeListener
Parameters:
scapeEvent - the scape event
Throws:
java.util.TooManyListenersException - the too many listeners exception

scapeRemoved

public void scapeRemoved(ScapeEvent scapeEvent)
Called on interation; delays models return by delay slider setting.

Specified by:
scapeRemoved in interface ScapeListener
Overrides:
scapeRemoved in class DefaultScapeListener
Parameters:
scapeEvent - the scape event
See Also:
scapeAdded

updateScapeState

public void updateScapeState()
Allow for overriding thread implementations.


updateScapeStateImpl

public void updateScapeStateImpl()
Update the components. Ensures that the state of all buttons matchhes the state of the observed scape.


isLifeOfScape

public boolean isLifeOfScape()
Returns true if the listener is intended to be used only for the current scape; in this case returns false because control views typically will exist for multiple scapes.

Specified by:
isLifeOfScape in interface ScapeListener
Overrides:
isLifeOfScape in class DefaultScapeListener
Returns:
true, if is life of scape

scapeNotification

public void scapeNotification(ScapeEvent scapeEvent)
Notifies this view that something has happened on the scape. This view then has a chance to update itself, and this super method then notifies the scape that the view itself has been updated. By default, calls the onStart, updateScapeGraphics, or onStop method as appropriate, and then notifies scape.

Specified by:
scapeNotification in interface ScapeListener
Overrides:
scapeNotification in class DefaultScapeListener
Parameters:
scapeEvent - a scape event update

getLastUpdateInMillis

protected long getLastUpdateInMillis()

setLastUpdateInMillis

protected void setLastUpdateInMillis(long lastUpdateInMillis)

getMaxMillisBetweenUpdates

protected long getMaxMillisBetweenUpdates()

setMaxMillisBetweenUpdates

protected void setMaxMillisBetweenUpdates(long maxMillisBetweenUpdates)


Copyright © 1998-2008 The Brookings Institution, NuTech Solutions, Metascape, LLC All Rights Reserved.