Displays one or more Path's within a specified screen rectangle in the canvas. The screen rectangle is initially empty, so it must be set with setScreenRect. Paths can be added or removed with methods addPath, removePath.

  • TO DO make DRAW_POINTS settable.

  • TO DO Could allow setting background color.

  • TO DO getPosition() and contains() should return something related to position of screenRect.

Implements

Constructors

Properties

defaultStyle_: undefined | DrawingStyle

Default style for drawing a path, used as default in addPath.

lastMap_: null | CoordMap = null

to detect when redraw needed; when the coordmap changes, we need to redraw.

redraw_: boolean = true

tells when need to redraw the bitmap from the paths

sequence_: number[] = []

sequence numbers indicate when a path has changed.

useBuffer_: undefined | boolean

Whether to draw into the offscreen buffer.

Methods

  • Adds a Path to the set of paths to display.

    Parameters

    • path: Path

      the Path to display

    • Optional opt_style: DrawingStyle

      the DrawingStyle to use for drawing this Path; uses the default style if not specified, see setStyle.

    Returns void

  • Whether the DisplayObject contains the given world coordinates point.

    Parameters

    • _p_world: Vector

      the point in world coordinates

    Returns boolean

    true if this DisplayObject contains the given point

  • Whether the Path is in the set of paths to display.

    Parameters

    • path: Path

      the Path of interest

    Returns boolean

    true if path is in the set of paths to display

  • Draws this DisplayObject using the given CoordMap.

    Parameters

    • context: CanvasRenderingContext2D

      the canvas's context to draw this object into

    • map: CoordMap

      the mapping to use for translating between simulation and screen coordinates

    Returns void

  • Returns the specified Path.

    Parameters

    • arg: string | number

      index number or name of Path. Name should be English or language-independent version of name.

    Returns Path

    path the Path of interest

  • Returns the screen rectangle that this DisplayPath is occupying within the LabCanvas, in screen coordinates.

    Returns ScreenRect

    the screen rectangle of this DisplayPath in screen coordinates

  • Returns true when drawing the Paths into an offscreen buffer.

    Returns boolean

    true when drawing the Paths into an offscreen buffer

  • Sets the z-index which specifies front-to-back ordering of objects; objects with a higher zIndex are drawn over (in front of) objects with a lower zIndex.

    Returns number

    the zIndex of this DisplayObject

  • Removes a Path from the set of paths to display.

    Parameters

    • path: Path

      the Path to remove

    Returns void

  • Sets whether this DisplayObject is currently dragable; has no effect on objects that are not dragable.

    Parameters

    • _dragable: boolean

      whether this DisplayObject should be dragable

    Returns void

  • 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.

    Parameters

    • _position: GenericVector

      this DisplayObject's position, in simulation coordinates.

    Returns void

  • Sets the screen rectangle that this DisplayPath should occupy within the LabCanvas, in screen coordinates.

    Parameters

    • screenRect: ScreenRect

      the screen coordinates of the area this DisplayPath should occupy.

    Returns void

  • Sets DrawingStyle used for drawing a Path.

    Parameters

    • idx: number

      index of Path

    • value: DrawingStyle

      the DrawingStyle to use for drawing the Path

    Returns void

  • Whether to draw the Paths into an offscreen buffer. For a Path that changes every frame, it saves time to not use an offscreen buffer.

    Parameters

    • value: undefined | boolean

      Whether to draw the Paths into an offscreen buffer

    Returns DisplayPath

    this object for chaining setters

  • Sets the z-index which specifies front-to-back ordering of objects; objects with a higher zIndex are drawn over objects with a lower zIndex. Default is zero.

    Parameters

    • zIndex: number

      the zIndex of this DisplayObject

    Returns void

  • 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'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc