immutable
This subpackage contains a version of View
s that is not much used in O1: views to immutable domain models. In O1, the other implementation in o1.gui.mutable is more relevant.
Attributes
- Graph
-
- Supertypes
- Self type
-
immutable.type
Members list
Type members
Classlikes
A Swing-embeddable view (complete with a picture, a ticking clock, event handlers, etc.). It works like a ViewFrame except that it’s a Swing component, not a standalone GUI frame. See ViewFrame for an overview.
A Swing-embeddable view (complete with a picture, a ticking clock, event handlers, etc.). It works like a ViewFrame except that it’s a Swing component, not a standalone GUI frame. See ViewFrame for an overview.
Type parameters
- Model
-
the type of the states of the model
Parameters
- initialDelay
-
an additional delay in milliseconds between calling start and the clock starting (optional; defaults to 600)
- initialState
-
the initial state of the model to be displayed in the view (the only required parameter). This class has been designed to work conveniently with immutable model objects (cf. o1.gui.mutable.ViewComponent).
- refreshPolicy
-
a policy for how eagerly the view should try to update the graphical representation of its model (optional; changing this may improve efficiency in some circumstances)
- tickRate
-
the clock of the view will tick roughly this many times per second (optional; defaults to 24)
Attributes
- Supertypes
- Known subtypes
-
class Traced[TraceData]
This class provides a framework for building simple GUIs. Each instance of the class is a graphical view to objects that represent the states of a domain model; those states can be (but are not required to be) immutable objects. A ViewFrame
displays the model as graphics within a GUI frame.
This class provides a framework for building simple GUIs. Each instance of the class is a graphical view to objects that represent the states of a domain model; those states can be (but are not required to be) immutable objects. A ViewFrame
displays the model as graphics within a GUI frame.
Note to students: this is not the view class that we commonly use in O1 but an alternative implementation. For the usual View
, see here.
The key method in the class is makePic, which the view calls automatically and repeatedly to determine which Pic to display in the frame at each moment in time. Concrete view objects must add an implementation for this abstract method.
A view listens to GUI events within the frame, but it doesn’t really do anything when notified of an event; concrete instances of the class can override this behavior by overriding one of the “on methods” (onClick
, onMouseMove
, etc.). The view also runs an internal clock and can react to the passing of time (onTick
).
Just creating a view object is not enough to display it onscreen and start the clock; see the start method.
Please note that even though this class is designed to work with immutable model states, the actual ViewFrame
is not itself immutable.
Type parameters
- Model
-
the type of the states of the model
Parameters
- closeWhenDone
-
whether the
ViewFrame
should be hidden and its clock stopped once the view has reached a “done state” (as per isDone) (optional; defaults tofalse
) - initialDelay
-
an additional delay in milliseconds between calling start and the clock starting (optional; defaults to 600)
- initialState
-
the initial state of the model to be displayed in the view (the only required parameter). This class has been designed to work conveniently with immutable model objects (cf. o1.gui.mutable.ViewFrame).
- refreshPolicy
-
a policy for how eagerly the view should try to update the graphical representation of its model (optional; changing this may improve efficiency in some circumstances)
- terminateOnClose
-
whether the entire application should exit when the
ViewFrame
is closed (optional; defaults totrue
) - tickRate
-
the clock of the view will tick roughly this many times per second (optional; defaults to 24)
- title
-
a string to be displayed in the frame’s title bar (optional)
Attributes
- Supertypes
- Known subtypes
-
class Traced[TraceData]
Types
An alias for ViewFrame, which is the default sort of View
. (Cf. the alternative, ViewComponent.)
An alias for ViewFrame, which is the default sort of View
. (Cf. the alternative, ViewComponent.)