How much extra margin to allocate when expanding the graph range: a fraction typically between 0.0 and 1.0, adds this fraction times the current horizontal or vertical range.
This does not guarantee a margin of this amount, it merely reduces the frequency of range expansion. You could for example expand the range, and then have succeeding points come very close to the new range so that the graph goes very close to the edge but stays within the range.
Private
graphThe GraphLines to auto-scale.
Private
lastIndex of last point seen within GraphPoints list of each GraphLine
Minimum size that range rectangle can be, for width and height.
Private
ownIndicates that the SIM_RECT_CHANGED event was generated by this AutoScale.
Private
rangefalse
indicates that the range has never been set based on graph data
Private
rangefalse
indicates that the range has never been set based on graph data
Private
rangeXHi_the maximum horizontal value of the range, used for calculating the scale
Private
rangeXLo_the minimum horizontal value of the range, used for calculating the scale
Private
rangeYHi_the maximum vertical value of the range, used for calculating the scale
Private
rangeYLo_the minimum vertical value of the range, used for calculating the scale
Private
timeLength of time to include in the range rectangle for a 'time graph'.
Static
Readonly
AUTO_Name of event broadcast when a new enclosing simulation rectangle has been calculated.
Static
Readonly
BOTH_Specifies both axes option for setAxis.
Static
Readonly
HORIZONTALSpecifies horizontal axis option for setAxis.
Static
Readonly
VERTICALSpecifies vertical axis option for setAxis.
Add a GraphLine which will be observed to calculate the range rectangle of points on the line.
the GraphLine to add
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 whether is AutoScale is active. See setActive.
whether is AutoScale is active
Protected
getReturns whether broadcasting is enabled for this Subject. See setBroadcast.
whether broadcasting is enabled for this Subject
Returns whether is AutoScale is enabled. See setEnabled.
whether is AutoScale is enabled
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 range rectangle that encloses points on the GraphLines, including any extra margin. Note that this rectangle might not correspond to the SimView's simulation rectangle, see setAxis.
the range rectangle that encloses points on the GraphLines
Notifies this Observer that a change has occurred in the Subject.
contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter
Remove a GraphLine, it will no longer be observed for calculating the range rectangle of points on the line.
the GraphLine to remove
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
Clears the range rectangle, and starts calculating from first entry in HistoryList. Note that you will need to call memorize to have the range recalculated.
Sets whether this AutoScale is active. When not active, the range rectangle is not updated and the SimView's simulation rectangle is not modified. When changed to be active, this will also call reset.
The AutoScale must be enabled in order to become active, see setEnabled. If not enabled, then this method can only make the AutoScale inactive.
whether this AutoScale should be active
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
Private
setSets whether this AutoScale is enabled. The AutoScale must be enabled in order to be active. See setActive.
whether this AutoScale should be enabled
Sets length of time to include in the range rectangle for a time graph, and sets the AutoScale to be active. See setActive.
length of time to include in the range 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.
Private
updateUpdates the graph range to include the given point. For time variable, limit the range to the timeWindow. For non-time variable, expand the range an extra amount when the range is exceeded; this helps avoid too many visually distracting updates.
Generated using TypeDoc
Watches the VarsList of one or more GraphLine to calculate the range rectangle that encloses the points on the graphs, and sets accordingly the
simRect
of a SimView. The range rectangle is the smallest rectangle that contains all the points, but possibly expanded by the extraMargin factor.Temporarily Deactivate
When the user pans or zooms the graph, we need to temporarily turn off the auto-scale behavior. When the user clicks the "reset" button in the middle of the pan-zoom control, this means "turn auto-scale back on".
To accomodate these behaviors, AutoScale observes the SimView and GraphLines and will react to their events as follows (assuming the AutoScale is enabled):
AutoScale becomes inactive when the SimView's
simRect
is changed by an entity other than this AutoScale. This happens when AutoScale observes a SimView event calledSIM_RECT_CHANGED
.AutoScale becomes active when one of its GraphLines broadcasts a
RESET
event. This happens when a graph is cleared, or when the X or Y variable is changed.You can also directly call setActive to make the AutoScale active or inactive (but it must also be enabled to actually do anything).
To entirely disable an AutoScale, use setEnabled.
Time Graph
For a time graph where one variable is time, the range rectangle in the time dimension has a fixed size specified by setTimeWindow. The default time window is 10 seconds.
Parameters Created
ParameterBoolean named
ACTIVE
, see setActiveParameterString named
AXIS
, see setAxis.ParameterBoolean named
ENABLED
, see setEnabledParameterNumber named
TIME_WINDOW
, see setTimeWindow.Events Broadcast
All the Parameters are broadcast when their values change. In addition:
AUTO_SCALE
is broadcast when the range rectangle changes. The new range rectangle is the value of the event.