mutable
This subpackage contains the version of View
s that we primarily use in O1: views to mutable domain models.
The top-level package o1 provides an alias to the ViewFrame class in this package, so it is available to students as View
simply by importing o1.*
.
There is an alternative implementation of View
s in o1.gui.immutable.
Attributes
- Graph
-
- Supertypes
- Self type
-
mutable.type
Members list
Type members
Classlikes
This class provides a framework for building simple GUIs. It is a further simplified version of ViewFrame. A BasicViewFrame
is like a ViewFrame
except that it doesn’t have an explicit model
object at all; you don’t need to pass in one as a constructor parameter. (This is useful for certain educational purposes.)
This class provides a framework for building simple GUIs. It is a further simplified version of ViewFrame. A BasicViewFrame
is like a ViewFrame
except that it doesn’t have an explicit model
object at all; you don’t need to pass in one as a constructor parameter. (This is useful for certain educational purposes.)
For other details, please see the ViewFrame supertype.
Attributes
- Companion
- object
- Supertypes
-
class ViewFrame[ImplicitModel]trait Controls[ImplicitModel]trait Fastclass ViewFrameImpl[ImplicitModel]class Objecttrait Matchableclass AnyShow all
This companion object just provides a singleton value that is used as a model
by BasicViewFrame
s that aren’t explictly given a model
via a constructor parameter.
This companion object just provides a singleton value that is used as a model
by BasicViewFrame
s that aren’t explictly given a model
via a constructor parameter.
Attributes
- Companion
- class
- Supertypes
- Self type
-
BasicViewFrame.type
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 model object
Parameters
- initialDelay
-
an additional delay in milliseconds between calling start and the clock starting (optional; defaults to 600)
- initialModel
-
the model to be displayed in the view (the only required parameter). It usually makes sense to use a mutable object here and change its state via the event handlers (cf. o1.gui.immutable.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 an object that represents a particular domain; that object is the model of the view. 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 an object that represents a particular domain; that object is the model of the view. A ViewFrame
displays the model as graphics within a GUI frame.
This class is available under the alias View
in the top-level package o1, so students can access it simply by importing o1.*
.
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.
Type parameters
- Model
-
the type of the model object
Parameters
- closeWhenDone
-
whether the
ViewFrame
should be hidden and its clock stopped once the view has reached a “done state” (as perisDone
) (optional; defaults tofalse
) - initialDelay
-
an additional delay in milliseconds between calling start and the clock starting (optional; defaults to 600)
- initialModel
-
the model to be displayed in the view (the only required parameter). It usually makes sense to use a mutable object here and change its state via the event handlers (cf. o1.gui.immutable.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]class BasicViewFrame
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.)