Optional
opt_simRect: DoubleRectthe area to draw axes for in simulation coordinates.
Optional
opt_font: stringthe Font to draw numbers and names of axes with
Optional
opt_color: stringthe Color to draw the axes with
Private
drawthe color to draw the axes with
Font ascent in pixels (guesstimate).
Font descent in pixels (guesstimate). TO DO find a way to get this for the current font, similar to the TextMetrics object. http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript http://pomax.nihongoresources.com/pages/Font.js/
The number on vertical axis to align with when using VerticalAlign.VALUE
Private
horizlocation of the horizontal axis
Private
horizname of horizontal axis
Private
numNumber of fractional decimal places to show.
Private
numthe font to use for drawing numbers and text on the axis Oct 2014: increased from 10pt to 14pt because standard canvas is now larger
Private
simbounds rectangle of area to draw
The number on horizontal axis to align with when using HorizAlign.VALUE
Private
vertlocation of the vertical axis
Private
verticalname of vertical axis
Whether the DisplayObject contains the given world coordinates point.
the point in world coordinates
true
if this DisplayObject contains the given point
Draws this DisplayObject using the given CoordMap.
the canvas's context to draw this object into
the mapping to use for translating between simulation and screen coordinates
Private
drawDraws the tick marks for the horizontal axis.
the vertical placement of the horizontal axis, in screen coords
the canvas's context to draw into
the mapping to use for translating between simulation and screen coordinates
the view area in simulation coords
Private
drawDraws the tick marks for the vertical axis.
the horizontal placement of the vertical axis, in screen coords
the canvas's context to draw into
the mapping to use for translating between simulation and screen coordinates
the view area in simulation coords
Returns the set of MassObjects that this DisplayObject represents. Returns an empty list if this DisplayObject doesn't represent a MassObject.
the set of MassObjects that this DisplayObject represents
Private
getReturns an increment to use for spacing of tick marks on an axis. The increment should be a 'round' number, with few fractional decimal places. It should divide the given range into around 5 to 7 pieces.
Side effect: modifies the number of fractional digits to show
the span of the axis
an increment to use for spacing of tick marks on an axis.
Returns the bounding rectangle for this DisplayAxes in simulation coordinates, which determines the numbering scale shown.
the bounding rectangle for this DisplayAxes in simulation coordinates.
Returns the X-axis alignment: whether it should appear at bottom, top or middle of the simulation rectangle.
X-axis alignment option
Returns the Y-axis alignment: whether it should appear at left, right or middle of the simulation rectangle.
Y-axis alignment option
Sets this DisplayObject's position in simulation coordinates of the containing SimView. Each type of DisplayObject has a different policy regarding whether this will have an effect. Generally the policies are:
If the DisplayObject does not represent a SimObject, then the position can be set. Examples are DisplayClock, EnergyBarGraph.
If the SimObject's position is dependent on other objects, then the position cannot be set. Examples are DisplayConnector, DisplayRope, DisplaySpring.
If the SimObject can be moved independently and isDragable
is true
, then the position of the SimObject is modified. Example: DisplayShape.
this DisplayObject's position, in simulation coordinates.
Sets the bounding rectangle for this DisplayAxes in simulation coordinates; this determines the numbering scale shown.
the bounding rectangle for this DisplayAxes in simulation coordinates.
Sets the X-axis alignment: whether it should appear at bottom, top or middle of the simulation rectangle, or go thru a particular value of the Y-axis.
X-axis alignment option
Optional
value: numbernumber on vertical axis to align with when using VerticalAlign.VALUE
this object for chaining setters
Sets the Y-axis alignment: whether it should appear at left, right or middle of the simulation rectangle, or go thru a particular value of the X-axis.
Y-axis alignment option
Optional
value: numbernumber on horizontal axis to align with when using HorizAlign.VALUE
this object for chaining setters
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.
Static
Private
getGenerated using TypeDoc
Draws linear horizontal and vertical axes within a given simulation coordinates rectangle. The simulation rectangle determines where the axes are drawn, and the numbering scale shown, see setSimRect.
Axes are drawn with numbered tick marks. Axes are labeled with names which can be specified by setHorizName and setVerticalName. Axes are drawn using specified font and color, see setColor and setFont.
Options exist for drawing the vertical axis near the left, center, or right, and for drawing the horizontal axis near the top, center, or bottom of the screen. See setXAxisAlignment and setYAxisAlignment.
You can set the axes alignment to go thru particular points, like the origin:
To keep the DisplayAxes in sync with a SimView, when doing for example pan/zoom of the SimView, you can arrange for setSimRect to be called by an Observer. See for example CommonControls.makeAxes which makes a GenericObserver that keeps the DisplayAxes in sync with the SimView.
TO DO add option to set the number of tick marks (instead of automatic)?