Skip to content
This repository was archived by the owner on Jan 4, 2020. It is now read-only.

Latest commit

 

History

History
687 lines (404 loc) · 11.6 KB

API.md

File metadata and controls

687 lines (404 loc) · 11.6 KB

Table of Contents

assertType

Assert given type is the expected one

Parameters

  • given Given type

  • expected Expected type

  • Throws UnexpectedTypeException When the assertion is false

assertObjectType

Assert given object is the expected type

Parameters

  • given Object Given type

  • expected Object Expected type

  • Throws UnexpectedTypeException When the assertion is false

isHTMLElement

Test whether or not given object is a HTML element

Parameters

Returns boolean Whether or not it's a HTML element

filterDefault

Merge the given value with the default value

Parameters

  • def Object Default value

  • val Object Given value

  • Throws UnexpectedTypeException When the data type in default value failed to match the one inside of the given one.

Returns Object Merged object

test

Perform the compatibility test

  • Throws IncompatibleContextException When current running context is incompatibiable with ImageMarker

Events

Event manager

add

Insert new event listener into a type

Parameters

  • type string Type of the target event
  • listener function The listener that will be called when event fired

remove

Remove the given event listener from a type

Parameters

  • type string Type of the target event
  • listener function The listener which was going to be called when event fired

fire

Fire a event

Parameters

  • type string Event type
  • data Event data

teardown

Remove all event listeners

Exception

Base Exception

Parameters

  • message string The error message

toString

Return the error message into a string

Returns string The error message

imagemarker

Creating a new ImageMarker instance

Parameters

Examples

import imageMarker from '~ImageMarker/imagemarker.js'
let marker = imageMarker(driver)

Returns ImageMarker a new Image Marker instance

ImageMarker

The main class, manages the status (from creation to destroy) of the ImageMarker

Parameters

  • stageDriver Object Instance of the stage driver

teardown

Tears down current instance, unrecoverablely

clear

Clear current stage without destroying it

open

Open a new stage

Parameters

  • background Background Background object
  • waitLoad boolean Whether or not to wait until the background is loaded
  • controlBuilder Object Builder of user controls

Returns Promise<Opened> An opened stage

refit

Re-adjecting current stage

addEventListener

Insert new event listener to an internal event

Parameters

removeEventListener

Remove a listener from listening an internal event

Parameters

Background

Background object

Parameters

  • url string URL address of the background image
  • width number Width of the image in px
  • height number Height of the image in px

URL

Return the URL

Returns string

width

Return the width of the background image

Returns number

height

Return the height of the background image

Returns number

ratio

Return the ratio of the background image

Returns number

zoom

Return the zoom level according to the given target width and height

Parameters

  • targetWidth number Target width
  • targetHeight number Target height

Returns number The zoom level

zoomable

Return whether or not given target width and height can be zoomed to

Parameters

Returns boolean Whether or not zoomable

defaultStageControl

Creating a default user controls of the stage

Returns Object User controls

Drawn

Drawn element on the stage

Parameters

element

Return the raw element of current drawn object

Returns Object

remove

Remove current element from the stage

set

Set the properties of current drawn object. Actual effect depends on the stage driver

Parameters

  • properties Object New properties

dimension

Return the dimension of current drawn object

Returns Object

data

Export the data of current drawn object

Returns Object

Opened

Represents an opened stage

Parameters

  • stage Stage Stage object
  • controls Object User control builder
  • events Events Events manager

reset

Reset current opened stage to it's initial configuation

zoom

Zoom the stage

Parameters

  • screenCenterX number X coordinate of the center view point
  • screenCenterY number Y coordinate of the center view point
  • panXOffset number X pan offset
  • panYOffset number Y pan offset
  • zoomShift number Zoom offset

insert

Insert a drawing

Parameters

Returns Drawn Drawn object

compose

Compose a drawing

Parameters

  • properties Object Properties

  • drawingControl Object User drawning control

  • composeType string Drawing type

  • Throws StageAlreadyComposing When the stage already at composing status

Returns Promise<Drawn> Drawn object

close

Close current stage

Stage

Stage control

Parameters

element

Return current stage element

Returns Object

open

Open a new stage

Parameters

  • background Background Stage background

  • onSuccess function Successful callback

  • onFail function Failure callback

  • controls Object User controls

  • waitLoad boolean Whether or not to wait until the background is loaded

  • Throws StageAlreadyOpened When the stage already been opened

clear

Clear current stage

teardown

Destroy current stage

refit

Re-adjust current stage

HandlerResult

Handler result

Parameters

  • context
  • continueNext

UserCtl

User control manager

Parameters

  • rootElement Object The root element which the control handler will be binded to
  • events Events Event manager

listens

Listen to the given UI control listener set

Parameters

  • listeners Object Listeners set
  • data Object Context data which will be delievered to control listeners when control event is fired

removes

Remove UI control listener set

Parameters

  • listeners Object Listeners set

teardown

Destroy current user control manager