name of this SimView.
specifies what area of the simulation to display, in simulation coordinates
Private
coordThe CoordMap that defines the simulation coordinates for this SimView.
Private
displayThis list of DisplayObjects that this SimView displays
The transparency used when painting the drawables; a number between 0.0 (fully transparent) and 1.0 (fully opaque).
when panning horizontally, this is percentage of width to move.
when panning vertically, this is percentage of height to move.
Private
ratio_ratio of height/width, used when scaleTogether_ is true.
Private
screenThe rectangle in screen coordinates where this SimView exists inside the LabCanvas.
Private
simThe boundary rectangle in simulation coordinates.
when zooming, this is percentage of size to zoom
Static
COORD_Name of event broadcast when the CoordMap changes, see setCoordMap.
Static
SCREEN_Name of event broadcast when the screen rectangle size changes, see setScreenRect.
Static
SIM_Name of event broadcast when the simulation rectangle size changes, see setSimRect.
Adds an object to the list of Memorizable objects. These object's memorize
methods will be called from this object's memorize
method.
object to add to the list of Memorizable objects
if called during the memorize
method.
Adds the given Observer to this Subject's list of Observers, so that the Observer
will be notified of changes in this Subject. An Observer may call Subject.addObserver
during its observe
method.
the Observer to add
Adds the Parameter to the list of this Subject's available Parameters.
the Parameter to add
if a Parameter with the same name already exists.
Notifies all Observers that this Subject has changed by calling observe on each Observer.
An Observer may call addObserver or removeObserver during its observe
method.
a SubjectEvent with information relating to the change
Notifies all Observers that the Parameter with the given name has changed by calling observe on each Observer.
the language-independent or English name of the Parameter that has changed
if there is no Parameter with the given name
Returns the ratio of 'pixels per simulation unit along y axis' divided by 'pixels per simulation unit along x axis' used when displaying this SimView. See CoordMap.
the aspect ratio used when displaying this SimView
Protected
getReturns whether broadcasting is enabled for this Subject. See setBroadcast.
whether broadcasting is enabled for this Subject
Returns the horizontal alignment to use when aligning the SimView's simulation rectangle within its screen rectangle. See CoordMap.
the horizontal alignment to use for aligning the simulation rectangle within the screen rectangle
Returns the list of Memorizable objects stored in this MemoList.
the list of Memorizable objects
Returns the ParameterBoolean with the given name.
the language-independent or English name of the ParameterBoolean
the ParameterBoolean with the given name
if there is no ParameterBoolean with the given name
Returns the ParameterNumber with the given name.
the language-independent or English name of the ParameterNumber
the ParameterNumber with the given name
if there is no ParameterNumber with the given name
Returns the ParameterString with the given name.
the language-independent or English name of the ParameterString
the ParameterString with the given name
if there is no ParameterString with the given name
Returns the screen rectangle that this SimView is occupying within the LabCanvas, in screen coordinates.
the screen rectangle of this SimView in screen coordinates
Returns the bounding rectangle for this SimView in simulation coordinates.
the bounding rectangle for this SimView in simulation coordinates
Returns the vertical alignment to use when aligning the SimView's simulation rectangle within its screen rectangle. See CoordMap.
the vertical alignment to use for aligning the simulation rectangle within the screen rectangle
Moves the center of the simulation rectangle (the 'camera') down by fraction panY, which causes the image to move up. Also broadcasts a SIM_RECT_CHANGED event.
Moves the center of the simulation rectangle (the 'camera') left by fraction panX, which causes the image to move right. Also broadcasts a SIM_RECT_CHANGED event.
Moves the center of the simulation rectangle (the 'camera') right by fraction panX, which causes the image to move left. Also broadcasts a SIM_RECT_CHANGED event.
Moves the center of the simulation rectangle (the 'camera') up by fraction panY, which causes the image to move down. Also broadcasts a SIM_RECT_CHANGED event.
Removes an object from the list of Memorizable objects.
object to remove from the list of Memorizable objects
if called during the memorize
method.
Removes the Observer from this Subject's list of Observers. An Observer may
call removeObserver
during its observe
method.
the Observer to detach from list of Observers
Removes the Parameter from the list of this Subject's available Parameters.
the Parameter to remove
Sets the ratio of 'pixels per simulation unit along y axis' divided by 'pixels per simulation unit along x axis' used when displaying this SimView. See CoordMap.
the aspect ratio used when displaying this SimView
Protected
setSets whether this Subject will broadcast events, typically used to temporarily disable broadcasting. Intended to be used in situations where a subclass overrides a method that broadcasts an event. This allows the subclass to prevent the superclass broadcasting that event, so that the subclass can broadcast the event when the method is completed.
whether this Subject should broadcast events
the previous value
Sets the horizontal coordinate of simulation rectangle's center, and broadcasts a SIM_RECT_CHANGED event.
the horizontal coordinate of simulation rectangle's center.
Sets the vertical coordinate of simulation rectangle's center, and broadcasts a SIM_RECT_CHANGED event.
the vertical coordinate of simulation rectangle's center.
Sets the CoordMap used by this SimView.
the CoordMap to use for this SimView
Sets height of the simulation rectangle, and broadcasts a SIM_RECT_CHANGED event
height of the simulation rectangle
Sets the horizontal alignment to use when aligning the SimView's simulation rectangle within its screen rectangle. See CoordMap.
the horizontal alignment to use for aligning the simulation rectangle within the screen rectangle
Sets the area that this SimView will occupy within the LabCanvas, in screen coordinates.
the screen coordinates of the area this SimView should occupy
Sets the bounding rectangle for this SimView, ensures this rectangle is visible, and turns off auto-scaling. The result is to generate a new CoordMap for this SimView so that the simulation rectangle maps to the current screen rectangle.
the bounding rectangle for this SimView in simulation coordinates.
Sets the vertical alignment to use when aligning the SimView's simulation rectangle within its screen rectangle. See CoordMap.
the vertical alignment to use for aligning the simulation rectangle within the screen rectangle
Sets width of the simulation rectangle, and broadcasts a SIM_RECT_CHANGED event.
width of the simulation rectangle
Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.
For an object whose main purpose is to represent another Printable object, it is
recommended to include the result of calling toStringShort
on that other object.
For example, calling toStringShort()
on a DisplayShape might return something like
this:
DisplayShape{polygon:Polygon{'chain3'}}
a minimal string representation of this object.
Makes the height of the simulation rectangle smaller by fraction 1/zoom, and also the width if getScaleTogether is true. Also broadcasts a SIM_RECT_CHANGED event.
Makes the height of the simulation rectangle bigger by factor zoom, and also the width if getScaleTogether is true. Also broadcasts a SIM_RECT_CHANGED event.
Generated using TypeDoc
A visual representation of a Simulation which can be displayed in a LabCanvas; has a DisplayList which represents the SimObjects of the Simulation; defines how to translate simulation coordinates to LabCanvas screen coordinates.
A SimView is shown inside a LabCanvas, possibly overlaid with other SimViews.
Boundary Rectangles
A SimView keeps track of two boundary rectangles: the simulation and screen rectangles.
The simulation rectangle specifies what area of the simulation space to display in this SimView. See getSimRect.
The screen rectangle specifies where to show this SimView within the containing LabCanvas. See getScreenRect. The screen rectangle is initially set to a default size of 800 by 600.
A CoordMap maps the simulation rectangle onto the screen rectangle, in accordance with various alignment options; see setHorizAlign, setVerticalAlign, setAspectRatio. The CoordMap is available via getCoordMap. The CoordMap is passed to each DisplayObject during the paint method.
Pan-Zoom Controls
The methods such as panUp, panLeft, zoomIn, zoomOut are used to make a 'pan-zoom control' in CommonControls.makePanZoomControls. The amount of pan-zoom that is done by each invocation of those methods can be changed via the properties panX, panY, zoom.
Parameters Created
ParameterBoolean named
SCALE_TOGETHER
, see setScaleTogether.ParameterNumber named
WIDTH
, see setWidthParameterNumber named
HEIGHT
, see setHeightParameterNumber named
CENTER_X
, see setCenterXParameterNumber named
CENTER_Y
, see setCenterYParameterString named
VERTICAL_ALIGN
, see setVerticalAlignParameterString named
HORIZONTAL_ALIGN
, see setHorizAlignParameterNumber named
ASPECT_RATIO
, see setAspectRatioEvents Broadcast
All the Parameters are broadcast when their values change. In addition:
GenericEvent named
SIM_RECT_CHANGED
when the simulation rectangle changes.GenericEvent named
COORD_MAP_CHANGED
when the CoordMap changes.