Class JXG.Board
↳ JXG.Board
JXG.Board controls all properties and methods used to manage a geonext board like managing geometric
elements, managing mouse and touch events, etc. You probably don't want to use this constructor directly.
Please use JXG.JSXGraph#initBoard to initialize a board.
Defined in: board.js.
Constructor Attributes | Constructor Name and Description |
---|---|
JXG.Board(container, renderer, id, origin, zoomX, zoomY, unitX, unitY, canvasWidth, canvasHeight, attributes)
Constructs a new Board object.
|
Field Attributes | Field Name and Description |
---|---|
Alias of JXG.Board#on.
|
|
Stores all the objects that are currently running an animation.
|
|
<constant> |
Board is in drag mode, objects aren't highlighted on mouse over and the object referenced in
{JXG.Board#mouse} is updated on mouse movement.
|
<constant> |
In this mode a mouse move changes the origin's screen coordinates.
|
<constant> |
Board is in no special mode, objects are highlighted on mouse over and objects may be
clicked to start drag&drop.
|
<constant> |
Update is made with high quality, e.g.
|
<constant> |
Update is made with high quality, e.g.
|
<constant> |
Update is made with low quality, e.g.
|
Canvas Height
|
|
Canvas width.
|
|
The html-id of the html element containing the board.
|
|
Pointer to the html element containing the board.
|
|
Cached ressult of getCoordsTopLeftCorner for touch/mouseMove-Events to save some DOM operations.
|
|
Deprecated name for JXG.Board#create.
|
|
The current color blindness deficiency is stored in this property.
|
|
An array containing all other boards that are updated after this board has been updated.
|
|
Dimension of the board.
|
|
Collects all elements that triggered a mouse down event.
|
|
The distance from the mouse to the dragged object in x direction when the user clicked the mouse button.
|
|
The distance from the mouse to the dragged object in y direction when the user clicked the mouse button.
|
|
An associative array to store the objects of the board by name.
|
|
Holds the registered event handlers.
|
|
If GEONExT constructions are displayed, then this property should be set to true.
|
|
Grids keeps track of all grids attached to this board.
|
|
An associative array containing all groups belonging to the board.
|
|
This bool flag stores the current state of the mobile Safari specific gesture event handlers.
|
|
A flag which tells if the board registers mouse events.
|
|
A flag which tells if the board the JXG.Board#mouseUpListener is currently registered.
|
|
A flag which stores if the board registered pointer events.
|
|
A flag which tells us if the board has a pointerUp event registered at the moment.
|
|
A flag which tells if the board the JXG.Board#touchEndListener is currently registered.
|
|
A flag which tells if the board registers touch events.
|
|
An associative array containing all highlighted elements belonging to the board.
|
|
During the update process this is set to false to prevent an endless loop.
|
|
If true updates are skipped.
|
|
The board mode the board is currently in.
|
|
References to the object that is dragged with the mouse on the board.
|
|
Full updates are needed after zoom and axis translates.
|
|
Number of objects ever created on this board.
|
|
An associative array containing all geometric objects belonging to the board.
|
|
An array containing all geometric objects on the board in the order of construction.
|
|
Some standard options
|
|
Coordinates of the boards origin.
|
|
If reducedUpdate is set to true then only the dragged element and few (e.g.
|
|
Alias of JXG.Board#off.
|
|
A reference to this boards renderer.
|
|
Keeps track on touched elements, like JXG.Board#mouse does for mouse events.
|
|
Contains the last time (epoch, msec) since the last touchMove event which was not thrown away or since
touchStart because Android's Webkit browser fires too much of them.
|
|
The number of pixels which represent one unit in user-coordinates in x direction.
|
|
The number of pixels which represent one unit in user-coordinates in y direction.
|
|
The update quality of the board.
|
|
A string containing the XML text of the construction.
|
|
Zoom factor in X direction.
|
|
Zoom factor in Y direction.
|
Method Attributes | Method Name and Description |
---|---|
addAnimation(element)
Adds an animation.
|
|
addChild(board)
Adds a dependent board to this board.
|
|
addConditions(str)
Add conditional updates to the elements.
|
|
Add all possible event handlers to the board object
|
|
addGrid()
Adds a grid to the board according to the settings given in board.options.
|
|
addHook(hook, m, context)
Please use JXG.Board#on instead.
|
|
Registers mouse move, down and wheel event handlers.
|
|
Registers the MSPointer* event handlers.
|
|
addTouchEventHandlers(appleGestures)
Register touch start and move and gesture start and change event handlers.
|
|
animate()
General purpose animation function.
|
|
Apply update on all objects with the new zoom-factors.
|
|
Calculates adequate snap sizes.
|
|
Delete the elements drawn as part of a trace of an element.
|
|
Handler for click on down arrow in the navigation bar
|
|
Handler for click on left arrow in the navigation bar
|
|
Handler for click on right arrow in the navigation bar
|
|
Handler for click on up arrow in the navigation bar
|
|
create(elementType, parents, attributes)
Creates a new geometric element of type elementType.
|
|
createRoulette(c1, c2, start_c1, stepsize, direction, time, pointlist)
Function to animate a curve rolling on another curve.
|
|
Remove highlighting of all elements.
|
|
emulateColorblindness(deficiency)
Initializes color blindness simulation.
|
|
finalizeAdding(obj)
After construction of the object the visibility is set
and the label is constructed if necessary.
|
|
Runs through all elements and calls their update() method and update the conditions.
|
|
Generates unique id for a board.
|
|
generateName(object)
Generates an unique name for the given object.
|
|
Triggered on iOS/Safari while the user inputs a gesture (e.g.
|
|
gestureStartListener(evt)
Called by iOS/Safari as soon as the user starts a gesture (only works on iOS/Safari).
|
|
Collects all elements under current mouse position.
|
|
getAllUnderMouse(evt)
Collects all elements under current mouse position plus current user coordinates of mouse cursor.
|
|
Get the bounding box of the board.
|
|
Calculates mouse coordinates relative to the boards container.
|
|
getMousePosition(e, i)
Get the position of the mouse in screen coordinates, relative to the upper left corner
of the host tag.
|
|
getScrCoordsOfMouse(x, y)
Returns the input parameters in an array.
|
|
getUsrCoordsOfMouse(evt)
This method calculates the user coords of the current mouse coordinates.
|
|
hasPoint(x, y)
Checks if the given point is inside the boundingbox.
|
|
highlightCustomInfobox(text, el)
Changes the text of the info box to what is provided via text.
|
|
highlightInfobox(x, y, el)
Changes the text of the info box to show the given coordinates.
|
|
Initialize some objects which are contained in every GEONExT construction by default,
but are not contained in the gxt files.
|
|
Initialize the info box object which is used to display
the coordinates of points near the mouse pointer,
|
|
initMoveObject(x, y, evt, type)
Collects all elements below the current mouse pointer and fulfilling the following constraints:
|
|
initMoveOrigin(x, y)
Initiate moving the origin.
|
|
migratePoint(src, dest, copyName)
Migrate the dependency properties of the point src
to the point dest and delete the point src.
|
|
mouseDownListener(evt, object)
This method is called by the browser when the mouse button is clicked.
|
|
mouseMoveListener(evt)
This method is called by the browser when the mouse is moved.
|
|
mouseUpListener(evt)
This method is called by the browser when the mouse button is released.
|
|
mouseWheelListener(evt)
Handler for mouse wheel events.
|
|
moveObject(x, y, o, evt, type)
Moves an object.
|
|
moveOrigin(x, y, diff)
Moves the origin and initializes an update of all elements.
|
|
off(event, handler)
Unregister an event handler.
|
|
on(event, handler, context)
Register a new event handler.
|
|
pointerDownListener(evt, object)
This method is called by the browser when a pointing device is pressed on the screen.
|
|
pointerMoveListener(evt)
Called periodically by the browser while the user moves a pointing device across the screen.
|
|
pointerUpListener(evt)
Triggered as soon as the user stops touching the device with at least one finger.
|
|
Sets for all objects the needsUpdate flag to "true".
|
|
removeAncestors(object)
Removes the ancestors of an object an the object itself from board and renderer.
|
|
removeChild(board)
Deletes a board from the list of dependent boards.
|
|
Remove all event handlers from the board object
|
|
Removes all grids assigned to this board.
|
|
removeHook(id)
Please use JXG.Board#off instead.
|
|
De-register mouse event handlers.
|
|
removeObject(object)
Removes object from board and renderer.
|
|
Remove MSPointer* Event handlers.
|
|
Remove all registered touch event handlers.
|
|
resizeContainer(canvasWidth, canvasHeight, dontset)
Change the height and width of the board's container.
|
|
<private> |
saveStartPos(obj, targets)
Helper function which returns a reasonable starting point for the object being dragged.
|
select(str)
Select a single or multiple elements at once.
|
|
setBoundingBox(bbox, keepaspectratio)
Set the bounding box of the board.
|
|
setId(obj, type)
Composes an id for an element.
|
|
setZoom(fX, fY)
Sets the zoom level to fX resp fY.
|
|
Lists the dependencies graph in a new HTML-window.
|
|
showXML()
Lists the XML code of the construction in a new HTML-window.
|
|
Cancels all running animations.
|
|
Stop updates of the board.
|
|
touchEndListener(evt)
Triggered as soon as the user stops touching the device with at least one finger.
|
|
touchMoveListener(evt)
Called periodically by the browser while the user moves his fingers across the device.
|
|
touchStartListener(evt, object)
This method is called by the browser when a finger touches the surface of the touch-device.
|
|
triggerEventHandlers(event, args)
Triggers all event handlers of this element for a given event.
|
|
twoFingerMove(p1, p2, o, evt)
Moves elements in multitouch mode.
|
|
twoFingerTouchObject(np1c, np2c, o, drag)
Moves a line or polygon with two fingers
|
|
Enable updates of the board.
|
|
update(drag)
Runs through most elements and calls their update() method and update the conditions.
|
|
updateConditions()
|
|
Update the coords object of all elements which possess this
property.
|
|
Update CSS transformations of sclaing type.
|
|
updateElements(drag)
Runs through all elements and calls their update() method.
|
|
updateHooks(m)
Runs through all hooked functions and calls them.
|
|
updateInfobox(el)
Updates and displays a little info box to show coordinates of current selected points.
|
|
Runs through all elements and calls their update() method.
|
|
Runs through all elements and calls their update() method.
|
|
zoom100()
Resets zoom factor to 100%.
|
|
Zooms the board so every visible point is shown.
|
|
zoomElements(elements)
Reset the bounding box and the zoom level to 100% such that a given set of elements is within the board's viewport.
|
|
zoomIn(x, y)
Zooms into the board by the factors board.attr.zoom.factorX and board.attr.zoom.factorY and applies the zoom.
|
|
zoomOut(x, y)
Zooms out of the board by the factors board.attr.zoom.factorX and board.attr.zoom.factorY and applies the zoom.
|
Event Attributes | Event Name and Description |
---|---|
The bounding box of the board has changed.
|
|
down(e)
Whenever the user starts to touch or click the board.
|
|
hit(e, el, target)
Whenever an element is highlighted this event is fired.
|
|
mousedown(e)
Whenever the user starts to click on the board.
|
|
mousehit(e, el, target)
Whenever an element is highlighted this event is fired.
|
|
mousemove(e, mode)
This event is fired whenever the user is moving the mouse over the board.
|
|
mouseup(e)
Whenever the user releases the mousebutton over the board.
|
|
move(e, mode)
This event is fired whenever the user is moving the finger or mouse pointer over the board.
|
|
touchend(e)
Whenever the user stops touching the board.
|
|
touchmove(e, mode)
This event is fired whenever the user is moving the finger over the board.
|
|
touchstart(e)
Whenever the user starts to touch the board.
|
|
up(e)
Whenever the user stops to touch or click the board.
|
|
update()
This board is updated.
|
Class Detail
JXG.Board(container, renderer, id, origin, zoomX, zoomY, unitX, unitY, canvasWidth, canvasHeight, attributes)
Constructs a new Board object.
- Parameters:
- {String} container
- The id or reference of the HTML DOM element the board is drawn in. This is usually a HTML div.
- {JXG.AbstractRenderer} renderer
- The reference of a renderer.
- {String} id
- Unique identifier for the board, may be an empty string or null or even undefined.
- {JXG.Coords} origin
- The coordinates where the origin is placed, in user coordinates.
- {Number} zoomX
- Zoom factor in x-axis direction
- {Number} zoomY
- Zoom factor in y-axis direction
- {Number} unitX
- Units in x-axis direction
- {Number} unitY
- Units in y-axis direction
- {Number} canvasWidth
- The width of canvas
- {Number} canvasHeight
- The height of canvas
- {Object} attributes
- The attributes object given to JXG.JSXGraph#initBoard
Field Detail
addEvent
Alias of JXG.Board#on.
{Object}
animationObjects
Stores all the objects that are currently running an animation.
<constant>
{Number}
BOARD_MODE_DRAG
Board is in drag mode, objects aren't highlighted on mouse over and the object referenced in
{JXG.Board#mouse} is updated on mouse movement.
- See:
- JXG.Board#drag_obj
<constant>
{Number}
BOARD_MODE_MOVE_ORIGIN
In this mode a mouse move changes the origin's screen coordinates.
<constant>
{Number}
BOARD_MODE_NONE
Board is in no special mode, objects are highlighted on mouse over and objects may be
clicked to start drag&drop.
<constant>
{Number}
BOARD_MODE_ZOOM
Update is made with high quality, e.g. graphs are evaluated at much more points.
<constant>
{Number}
BOARD_QUALITY_HIGH
Update is made with high quality, e.g. graphs are evaluated at much more points.
<constant>
{Number}
BOARD_QUALITY_LOW
Update is made with low quality, e.g. graphs are evaluated at a lesser amount of points.
{Number}
canvasHeight
Canvas Height
{Number}
canvasWidth
Canvas width.
{String}
container
The html-id of the html element containing the board.
{Object}
containerObj
Pointer to the html element containing the board.
{Array}
cPos
Cached ressult of getCoordsTopLeftCorner for touch/mouseMove-Events to save some DOM operations.
createElement
Deprecated name for JXG.Board#create.
currentCBDef
The current color blindness deficiency is stored in this property. If color blindness is not emulated
at the moment, it's value is 'none'.
{Array}
dependentBoards
An array containing all other boards that are updated after this board has been updated.
{Number}
dimension
Dimension of the board.
- Default Value:
- 2
{Array}
downObjects
Collects all elements that triggered a mouse down event.
{Number}
drag_dx
The distance from the mouse to the dragged object in x direction when the user clicked the mouse button.
- See:
- JXG.Board#drag_dy
- JXG.Board#drag_obj
{Number}
drag_dy
The distance from the mouse to the dragged object in y direction when the user clicked the mouse button.
- See:
- JXG.Board#drag_dx
- JXG.Board#drag_obj
{Object}
elementsByName
An associative array to store the objects of the board by name. the name of the object is the key and value is a reference to the object.
{Object}
eventHandlers
Holds the registered event handlers.
Defined in: event.js.
Defined in: event.js.
{Boolean}
geonextCompatibilityMode
If GEONExT constructions are displayed, then this property should be set to true.
At the moment there should be no difference. But this may change.
This is set in JXG.GeonextReader#readGeonext.
- See:
- JXG.GeonextReader#readGeonext
- Default Value:
- false
grids
Grids keeps track of all grids attached to this board.
{Object}
groups
An associative array containing all groups belonging to the board. Key is the id of the group and value is a reference to the object.
hasGestureHandlers
This bool flag stores the current state of the mobile Safari specific gesture event handlers.
- Default Value:
- false
{Boolean}
hasMouseHandlers
A flag which tells if the board registers mouse events.
- Default Value:
- false
{Boolean}
hasMouseUp
A flag which tells if the board the JXG.Board#mouseUpListener is currently registered.
- Default Value:
- false
hasPointerHandlers
A flag which stores if the board registered pointer events.
- Default Value:
- false
hasPointerUp
A flag which tells us if the board has a pointerUp event registered at the moment.
- Default Value:
- false
{Boolean}
hasTouchEnd
A flag which tells if the board the JXG.Board#touchEndListener is currently registered.
- Default Value:
- false
{Boolean}
hasTouchHandlers
A flag which tells if the board registers touch events.
- Default Value:
- false
{Object}
highlightedObjects
An associative array containing all highlighted elements belonging to the board.
{Boolean}
inUpdate
During the update process this is set to false to prevent an endless loop.
- Default Value:
- false
{Boolean}
isSuspendedRedraw
If true updates are skipped.
{Number}
mode
The board mode the board is currently in. Possible values are
- JXG.Board.BOARD_MODE_NONE
- JXG.Board.BOARD_MODE_DRAG
- JXG.Board.BOARD_MODE_MOVE_ORIGIN
{.}
mouse
References to the object that is dragged with the mouse on the board.
- See:
{Boolean}
needsFullUpdate
Full updates are needed after zoom and axis translates. This saves some time during an update.
- Default Value:
- false
{Number}
numObjects
Number of objects ever created on this board. This includes every object, even invisible and deleted ones.
{Object}
objects
An associative array containing all geometric objects belonging to the board. Key is the id of the object and value is a reference to the object.
objectsList
An array containing all geometric objects on the board in the order of construction.
{JXG.Options}
options
Some standard options
{Object}
origin
Coordinates of the boards origin. This a object with the two properties
usrCoords and scrCoords. usrCoords always equals [1, 0, 0] and scrCoords
stores the boards origin in homogeneous screen coordinates.
{Boolean}
reducedUpdate
If reducedUpdate is set to true then only the dragged element and few (e.g. 2) following
elements are updated during mouse move. On mouse up the whole construction is
updated. This enables us to be fast even on very slow devices.
- Default Value:
- false
removeEvent
Alias of JXG.Board#off.
{JXG.AbstractRenderer}
renderer
A reference to this boards renderer.
{Array}
touches
Keeps track on touched elements, like JXG.Board#mouse does for mouse events.
- See:
{Number}
touchMoveLast
Contains the last time (epoch, msec) since the last touchMove event which was not thrown away or since
touchStart because Android's Webkit browser fires too much of them.
{Number}
unitX
The number of pixels which represent one unit in user-coordinates in x direction.
{Number}
unitY
The number of pixels which represent one unit in user-coordinates in y direction.
{Number}
updateQuality
The update quality of the board. In most cases this is set to JXG.Board#BOARD_QUALITY_HIGH.
If JXG.Board#mode equals JXG.Board#BOARD_MODE_DRAG this is set to
JXG.Board#BOARD_QUALITY_LOW to speed up the update process by e.g. reducing the number of
evaluation points when plotting functions. Possible values are
- BOARD_QUALITY_LOW
- BOARD_QUALITY_HIGH
- See:
- JXG.Board#mode
{String}
xmlString
A string containing the XML text of the construction. This is set in JXG.FileReader#parseString.
Only useful if a construction is read from a GEONExT-, Intergeo-, Geogebra-, or Cinderella-File.
{Number}
zoomX
Zoom factor in X direction. It only stores the zoom factor to be able
to get back to 100% in zoom100().
{Number}
zoomY
Zoom factor in Y direction. It only stores the zoom factor to be able
to get back to 100% in zoom100().
Method Detail
{JXG.Board}
addAnimation(element)
Adds an animation. Animations are controlled by the boards, so the boards need to be aware of the
animated elements. This function tells the board about new elements to animate.
- Parameters:
- {JXG.GeometryElement} element
- The element which is to be animated.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
addChild(board)
Adds a dependent board to this board.
- Parameters:
- {JXG.Board} board
- A reference to board which will be updated after an update of this board occured.
- Returns:
- {JXG.Board} Reference to the board
addConditions(str)
Add conditional updates to the elements.
- Parameters:
- {String} str
- String containing coniditional update in geonext syntax
addEventHandlers()
Add all possible event handlers to the board object
{JXG.Board}
addGrid()
Adds a grid to the board according to the settings given in board.options.
- Returns:
- {JXG.Board} Reference to the board.
{Number}
addHook(hook, m, context)
Please use JXG.Board#on instead.
- Parameters:
- {Function} hook
- A function to be called by the board after an update occured.
- {String} m Optional, Default: 'update'
- When the hook is to be called. Possible values are mouseup, mousedown and update.
- {Object} context Optional, Default: board
- Determines the execution context the hook is called. This parameter is optional, default is the board object the hook is attached to.
- Returns:
- {Number} Id of the hook, required to remove the hook from the board.
addMouseEventHandlers()
Registers mouse move, down and wheel event handlers.
addPointerEventHandlers()
Registers the MSPointer* event handlers.
addTouchEventHandlers(appleGestures)
Register touch start and move and gesture start and change event handlers.
- Parameters:
- {Boolean} appleGestures
- If set to false the gesturestart and gesturechange event handlers will not be registered.
{JXG.Board}
animate()
General purpose animation function. This currently only supports moving points from one place to another. This
is faster than managing the animation per point, especially if there is more than one animated point at the same time.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
applyZoom()
Apply update on all objects with the new zoom-factors. Clears all traces.
- Returns:
- {JXG.Board} Reference to the board.
{JXG.Board}
calculateSnapSizes()
Calculates adequate snap sizes.
- Returns:
- {JXG.Board} Reference to the board.
{JXG.Board}
clearTraces()
Delete the elements drawn as part of a trace of an element.
- Returns:
- {JXG.Board} Reference to the board
clickDownArrow()
Handler for click on down arrow in the navigation bar
clickLeftArrow()
Handler for click on left arrow in the navigation bar
clickRightArrow()
Handler for click on right arrow in the navigation bar
clickUpArrow()
Handler for click on up arrow in the navigation bar
{Object}
create(elementType, parents, attributes)
Creates a new geometric element of type elementType.
- Parameters:
- {String} elementType
- Type of the element to be constructed given as a string e.g. 'point' or 'circle'.
- {Array} parents
- Array of parent elements needed to construct the element e.g. coordinates for a point or two points to construct a line. This highly depends on the elementType that is constructed. See the corresponding JXG.create* methods for a list of possible parameters.
- {Object} attributes Optional
- An object containing the attributes to be set. This also depends on the elementType. Common attributes are name, visible, strokeColor.
- Returns:
- {Object} Reference to the created element. This is usually a GeometryElement, but can be an array containing two or more elements.
createRoulette(c1, c2, start_c1, stepsize, direction, time, pointlist)
Function to animate a curve rolling on another curve.
- Parameters:
- {Curve} c1
- JSXGraph curve building the floor where c2 rolls
- {Curve} c2
- JSXGraph curve which rolls on c1.
- {number} start_c1
- The parameter t such that c1(t) touches c2. This is the start position of the rolling process
- {Number} stepsize
- Increase in t in each step for the curve c1
- {Number} direction
- {Number} time
- Delay time for setInterval()
- {Array} pointlist
- Array of points which are rolled in each step. This list should contain all points which define c2 and gliders on c2.
- Examples:
// Line which will be the floor to roll upon. var line = brd.create('curve', [function (t) { return t;}, function (t){ return 1;}], {strokeWidth:6}); // Center of the rolling circle var C = brd.create('point',[0,2],{name:'C'}); // Starting point of the rolling circle var P = brd.create('point',[0,1],{name:'P', trace:true}); // Circle defined as a curve. The circle "starts" at P, i.e. circle(0) = P var circle = brd.create('curve',[ function (t){var d = P.Dist(C), beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P); t += beta; return C.X()+d*Math.cos(t); }, function (t){var d = P.Dist(C), beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P); t += beta; return C.Y()+d*Math.sin(t); }, 0,2*Math.PI], {strokeWidth:6, strokeColor:'green'}); // Point on circle var B = brd.create('glider',[0,2,circle],{name:'B', color:'blue',trace:false}); var roll = brd.createRoulette(line, circle, 0, Math.PI/20, 1, 100, [C,P,B]); roll.start() // Start the rolling, to be stopped by roll.stop()
{JXG.Board}
dehighlightAll()
Remove highlighting of all elements.
- Returns:
- {JXG.Board} Reference to the board.
{JXG.Board}
emulateColorblindness(deficiency)
Initializes color blindness simulation.
- Parameters:
- {String} deficiency
- Describes the color blindness deficiency which is simulated. Accepted values are 'protanopia', 'deuteranopia', and 'tritanopia'.
- Returns:
- {JXG.Board} Reference to the board
finalizeAdding(obj)
After construction of the object the visibility is set
and the label is constructed if necessary.
- Parameters:
- {Object} obj
- The object to add.
{JXG.Board}
fullUpdate()
Runs through all elements and calls their update() method and update the conditions.
This is necessary after zooming and changing the bounding box.
- Returns:
- {JXG.Board} Reference to the board
{String}
generateId()
Generates unique id for a board. The result is randomly generated and prefixed with 'jxgBoard'.
- Returns:
- {String} Unique id for a board.
{String}
generateName(object)
Generates an unique name for the given object. The result depends on the objects type, if the
object is a JXG.Point, capital characters are used, if it is of type JXG.Line
only lower case characters are used. If object is of type JXG.Polygon, a bunch of lower
case characters prefixed with P_ are used. If object is of type JXG.Circle the name is
generated using lower case characters. prefixed with k_ is used. In any other case, lower case
chars prefixed with s_ is used.
- Parameters:
- {Object} object
- Reference of an JXG.GeometryElement that is to be named.
- Returns:
- {String} Unique name for the object.
{Boolean}
gestureChangeListener(evt)
Triggered on iOS/Safari while the user inputs a gesture (e.g. pinch) and is used to zoom into the board. Only works on iOS/Safari.
- Parameters:
- {Event} evt
- Browser event object
- Returns:
- {Boolean}
{Boolean}
gestureStartListener(evt)
Called by iOS/Safari as soon as the user starts a gesture (only works on iOS/Safari).
- Parameters:
- {Event} evt
- Returns:
- {Boolean}
{Array}
getAllObjectsUnderMouse(evt)
Collects all elements under current mouse position.
- Parameters:
- {Event} evt
- Event object containing the mouse coordinates.
- Returns:
- {Array} Array of elements at the current mouse position.
{Array}
getAllUnderMouse(evt)
Collects all elements under current mouse position plus current user coordinates of mouse cursor.
- Parameters:
- {Event} evt
- Event object containing the mouse coordinates.
- Returns:
- {Array} Array of elements at the current mouse position plus current user coordinates of mouse.
{Array}
getBoundingBox()
Get the bounding box of the board.
- Returns:
- {Array} bounding box [x1,y1,x2,y2] upper left corner, lower right corner
{Array}
getCoordsTopLeftCorner()
Calculates mouse coordinates relative to the boards container.
- Returns:
- {Array} Array of coordinates relative the boards container top left corner.
{Array}
getMousePosition(e, i)
Get the position of the mouse in screen coordinates, relative to the upper left corner
of the host tag.
- Parameters:
- {Event} e
- Event object given by the browser.
- {Number} i Optional
- Only use in case of touch events. This determines which finger to use and should not be set for mouseevents.
- Returns:
- {Array} Contains the mouse coordinates in user coordinates, ready for JXG.Coords
{Array}
getScrCoordsOfMouse(x, y)
Returns the input parameters in an array. This method looks pointless and it really is, but it had a purpose
once.
- Parameters:
- {Number} x
- X coordinate in screen coordinates
- {Number} y
- Y coordinate in screen coordinates
- Returns:
- {Array} Coordinates of the mouse in screen coordinates.
{Array}
getUsrCoordsOfMouse(evt)
This method calculates the user coords of the current mouse coordinates.
- Parameters:
- {Event} evt
- Event object containing the mouse coordinates.
- Returns:
- {Array} Coordinates of the mouse in screen coordinates.
{Boolean}
hasPoint(x, y)
Checks if the given point is inside the boundingbox.
- Parameters:
- {Number|JXG.Coords} x
- User coordinate or JXG.Coords object.
- {Number} y Optional
- User coordinate. May be omitted in case x is a JXG.Coords object.
- Returns:
- {Boolean}
{JXG.Board}
highlightCustomInfobox(text, el)
Changes the text of the info box to what is provided via text.
- Parameters:
- {String} text
- {JXG.GeometryElement} el Optional
- Returns:
- {JXG.Board} Reference to the board.
{JXG.Board}
highlightInfobox(x, y, el)
Changes the text of the info box to show the given coordinates.
- Parameters:
- {Number} x
- {Number} y
- {JXG.GeometryElement} el Optional
- The element the mouse is pointing at
- Returns:
- {JXG.Board} Reference to the board.
{JXG.Board}
initGeonextBoard()
Initialize some objects which are contained in every GEONExT construction by default,
but are not contained in the gxt files.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
initInfobox()
Initialize the info box object which is used to display
the coordinates of points near the mouse pointer,
- Returns:
- {JXG.Board} Reference to the board
{Array}
initMoveObject(x, y, evt, type)
Collects all elements below the current mouse pointer and fulfilling the following constraints:
- isDraggable
- visible
- not fixed
- not frozen
- Parameters:
- {Number} x
- Current mouse/touch coordinates
- {Number} y
- current mouse/touch coordinates
- {Object} evt
- An event object
- {String} type
- What type of event? 'touch' or 'mouse'.
- Returns:
- {Array} A list of geometric elements.
initMoveOrigin(x, y)
Initiate moving the origin. This is used in mouseDown and touchStart listeners.
- Parameters:
- {Number} x
- Current mouse/touch coordinates
- {Number} y
- Current mouse/touch coordinates
{JXG.Board}
migratePoint(src, dest, copyName)
Migrate the dependency properties of the point src
to the point dest and delete the point src.
For example, a circle around the point src
receives the new center dest. The old center src
will be deleted.
- Parameters:
- {JXG.Point} src
- Original point which will be deleted
- {JXG.Point} dest
- New point with the dependencies of src.
- {Boolean} copyName
- Flag which decides if the name of the src element is copied to the dest element.
- Returns:
- {JXG.Board} Reference to the board
{Boolean}
mouseDownListener(evt, object)
This method is called by the browser when the mouse button is clicked.
- Parameters:
- {Event} evt
- The browsers event object.
- {JXG.GeometryElement} object
- If the object to be dragged is already known, it can be submitted via this parameter
- Returns:
- {Boolean} True if no element is found under the current mouse pointer, false otherwise.
mouseMoveListener(evt)
This method is called by the browser when the mouse is moved.
- Parameters:
- {Event} evt
- The browsers event object.
mouseUpListener(evt)
This method is called by the browser when the mouse button is released.
- Parameters:
- {Event} evt
{Boolean}
mouseWheelListener(evt)
Handler for mouse wheel events. Used to zoom in and out of the board.
- Parameters:
- {Event} evt
- Returns:
- {Boolean}
moveObject(x, y, o, evt, type)
Moves an object.
- Parameters:
- {Number} x
- Coordinate
- {Number} y
- Coordinate
- {Object} o
- The touch object that is dragged: {JXG.Board#mouse} or {JXG.Board#touches}.
- {Object} evt
- The event object.
- {String} type
- Mouse or touch event?
{JXG.Board}
moveOrigin(x, y, diff)
Moves the origin and initializes an update of all elements.
- Parameters:
- {Number} x
- {Number} y
- {Boolean} diff Optional, Default: false
- Returns:
- {JXG.Board} Reference to this board.
off(event, handler)
Unregister an event handler.
Defined in: event.js.
Defined in: event.js.
- Parameters:
- {String} event
- {Function} handler Optional
- Returns:
- Reference to the object.
on(event, handler, context)
Register a new event handler. For a list of possible events see documentation of the elements and objects implementing
the EventEmitter interface.
Defined in: event.js.
Defined in: event.js.
- Parameters:
- {String} event
- {Function} handler
- {Object} context Optional
- The context the handler will be called in, default is the element itself.
- Returns:
- Reference to the object.
{Boolean}
pointerDownListener(evt, object)
This method is called by the browser when a pointing device is pressed on the screen.
- Parameters:
- {Event} evt
- The browsers event object.
- {Object} object
- If the object to be dragged is already known, it can be submitted via this parameter
- Returns:
- {Boolean} ...
{Boolean}
pointerMoveListener(evt)
Called periodically by the browser while the user moves a pointing device across the screen.
- Parameters:
- {Event} evt
- Returns:
- {Boolean}
{Boolean}
pointerUpListener(evt)
Triggered as soon as the user stops touching the device with at least one finger.
- Parameters:
- {Event} evt
- Returns:
- {Boolean}
{JXG.Board}
prepareUpdate()
Sets for all objects the needsUpdate flag to "true".
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
removeAncestors(object)
Removes the ancestors of an object an the object itself from board and renderer.
- Parameters:
- {JXG.GeometryElement} object
- The object to remove.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
removeChild(board)
Deletes a board from the list of dependent boards.
- Parameters:
- {JXG.Board} board
- Reference to the board which will be removed.
- Returns:
- {JXG.Board} Reference to the board
removeEventHandlers()
Remove all event handlers from the board object
{JXG.Board}
removeGrids()
Removes all grids assigned to this board. Warning: This method also removes all objects depending on one or
more of the grids.
- Returns:
- {JXG.Board} Reference to the board object.
{JXG.Board}
removeHook(id)
Please use JXG.Board#off instead.
- Parameters:
- {Number|function} id
- The number you got when you added the hook or a reference to the event handler.
- Returns:
- {JXG.Board} Reference to the board
removeMouseEventHandlers()
De-register mouse event handlers.
{JXG.Board}
removeObject(object)
Removes object from board and renderer.
- Parameters:
- {JXG.GeometryElement} object
- The object to remove.
- Returns:
- {JXG.Board} Reference to the board
removePointerEventHandlers()
Remove MSPointer* Event handlers.
removeTouchEventHandlers()
Remove all registered touch event handlers.
{JXG.Board}
resizeContainer(canvasWidth, canvasHeight, dontset)
Change the height and width of the board's container.
- Parameters:
- {Number} canvasWidth
- New width of the container.
- {Number} canvasHeight
- New height of the container.
- {Boolean} dontset Optional, Default: false
- Do not set the height of the DOM element.
- Returns:
- {JXG.Board} Reference to the board
<private>
saveStartPos(obj, targets)
Helper function which returns a reasonable starting point for the object being dragged.
Formerly known as initXYstart().
- Parameters:
- {JXG.GeometryElement} obj
- The object to be dragged
- {Array} targets
- Array of targets. It is changed by this function.
{JXG.GeometryElement|JXG.Composition}
select(str)
Select a single or multiple elements at once.
- Parameters:
- {String|Object|function} str
- The name, id or a reference to a JSXGraph element on this board. An object will be used as a filter to return multiple elements at once filtered by the properties of the object.
- Returns:
- {JXG.GeometryElement|JXG.Composition}
- Examples:
// select the element with name A board.select('A'); // select all elements with strokecolor set to 'red' (but not '#ff0000') board.select({ strokeColor: 'red' }); // select all points on or below the x axis and make them black. board.select({ elementClass: JXG.OBJECT_CLASS_POINT, Y: function (v) { return v <= 0; } }).setAttribute({color: 'black'}); // select all elements board.select(function (el) { return true; });
{JXG.Board}
setBoundingBox(bbox, keepaspectratio)
Set the bounding box of the board.
- Parameters:
- {Array} bbox
- New bounding box [x1,y1,x2,y2]
- {Boolean} keepaspectratio Optional, Default: false
- If set to true, the aspect ratio will be 1:1, but the resulting viewport may be larger.
- Returns:
- {JXG.Board} Reference to the board
{String}
setId(obj, type)
Composes an id for an element. If the ID is empty ('' or null) a new ID is generated, depending on the
object type. Additionally, the id of the label is set. As a side effect JXG.Board#numObjects
is updated.
- Parameters:
- {Object} obj
- Reference of an geometry object that needs an id.
- {Number} type
- Type of the object.
- Returns:
- {String} Unique id for an element.
{JXG.Board}
setZoom(fX, fY)
Sets the zoom level to fX resp fY.
- Parameters:
- {Number} fX
- {Number} fY
- Returns:
- {JXG.Board}
{JXG.Board}
showDependencies()
Lists the dependencies graph in a new HTML-window.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
showXML()
Lists the XML code of the construction in a new HTML-window.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
stopAllAnimation()
Cancels all running animations.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
suspendUpdate()
Stop updates of the board.
- Returns:
- {JXG.Board} Reference to the board
{Boolean}
touchEndListener(evt)
Triggered as soon as the user stops touching the device with at least one finger.
- Parameters:
- {Event} evt
- Returns:
- {Boolean}
{Boolean}
touchMoveListener(evt)
Called periodically by the browser while the user moves his fingers across the device.
- Parameters:
- {Event} evt
- Returns:
- {Boolean}
{Boolean}
touchStartListener(evt, object)
This method is called by the browser when a finger touches the surface of the touch-device.
- Parameters:
- {Event} evt
- The browsers event object.
- {Object} object
- If the object to be dragged is already known, it can be submitted via this parameter
- Returns:
- {Boolean} ...
triggerEventHandlers(event, args)
Triggers all event handlers of this element for a given event.
Defined in: event.js.
Defined in: event.js.
- Parameters:
- {Array} event
- {Array} args
- The arguments passed onto the event handler
- Returns:
- Reference to the object.
twoFingerMove(p1, p2, o, evt)
Moves elements in multitouch mode.
- Parameters:
- {Array} p1
- x,y coordinates of first touch
- {Array} p2
- x,y coordinates of second touch
- {Object} o
- The touch object that is dragged: {JXG.Board#touches}.
- {Object} evt
- The event object that lead to this movement.
twoFingerTouchObject(np1c, np2c, o, drag)
Moves a line or polygon with two fingers
- Parameters:
- {JXG.Coords} np1c
- x,y coordinates of first touch
- {JXG.Coords} np2c
- x,y coordinates of second touch
- {object} o
- The touch object that is dragged: {JXG.Board#touches}.
- {object} drag
- The object that is dragged:
{JXG.Board}
unsuspendUpdate()
Enable updates of the board.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
update(drag)
Runs through most elements and calls their update() method and update the conditions.
- Parameters:
- {JXG.GeometryElement} drag Optional
- Element that caused the update.
- Returns:
- {JXG.Board} Reference to the board
updateConditions()
{JXG.Board}
updateCoords()
Update the coords object of all elements which possess this
property. This is necessary after changing the viewport.
- Returns:
- {JXG.Board} Reference to this board.
updateCSSTransforms()
Update CSS transformations of sclaing type. It is used to correct the mouse position
in JXG.Board#getMousePosition.
The inverse transformation matrix is updated on each mouseDown and touchStart event.
It is up to the user to call this method after an update of the CSS transformation
in the DOM.
{JXG.Board}
updateElements(drag)
Runs through all elements and calls their update() method.
- Parameters:
- {JXG.GeometryElement} drag
- Element that caused the update.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
updateHooks(m)
Runs through all hooked functions and calls them.
- Parameters:
- m
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
updateInfobox(el)
Updates and displays a little info box to show coordinates of current selected points.
- Parameters:
- {JXG.GeometryElement} el
- A GeometryElement
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
updateRenderer()
Runs through all elements and calls their update() method.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
updateRendererCanvas()
Runs through all elements and calls their update() method.
This is a special version for the CanvasRenderer.
Here, we have to do our own layer handling.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
zoom100()
Resets zoom factor to 100%.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
zoomAllPoints()
Zooms the board so every visible point is shown. Keeps aspect ratio.
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
zoomElements(elements)
Reset the bounding box and the zoom level to 100% such that a given set of elements is within the board's viewport.
- Parameters:
- {Array} elements
- A set of elements given by id, reference, or name.
- Returns:
- {JXG.Board} Reference to the board.
{JXG.Board}
zoomIn(x, y)
Zooms into the board by the factors board.attr.zoom.factorX and board.attr.zoom.factorY and applies the zoom.
- Parameters:
- {Number} x Optional
- {Number} y Optional
- Returns:
- {JXG.Board} Reference to the board
{JXG.Board}
zoomOut(x, y)
Zooms out of the board by the factors board.attr.zoom.factorX and board.attr.zoom.factorY and applies the zoom.
- Parameters:
- {Number} x Optional
- {Number} y Optional
- Returns:
- {JXG.Board} Reference to the board
Event Detail
boundingbox()
The bounding box of the board has changed.
down(e)
Whenever the user starts to touch or click the board.
- Parameters:
- {Event} e
- The browser's event object.
hit(e, el, target)
Whenever an element is highlighted this event is fired.
- Parameters:
- {Event} e
- The browser's event object.
- {JXG.GeometryElement} el
- The hit element.
- target
mousedown(e)
Whenever the user starts to click on the board.
- Parameters:
- {Event} e
- The browser's event object.
mousehit(e, el, target)
Whenever an element is highlighted this event is fired.
- Parameters:
- {Event} e
- The browser's event object.
- {JXG.GeometryElement} el
- The hit element.
- target
mousemove(e, mode)
This event is fired whenever the user is moving the mouse over the board.
- Parameters:
- {Event} e
- The browser's event object.
- {Number} mode
- The mode the board currently is in
- See:
mouseup(e)
Whenever the user releases the mousebutton over the board.
- Parameters:
- {Event} e
- The browser's event object.
move(e, mode)
This event is fired whenever the user is moving the finger or mouse pointer over the board.
- Parameters:
- {Event} e
- The browser's event object.
- {Number} mode
- The mode the board currently is in
- See:
touchend(e)
Whenever the user stops touching the board.
- Parameters:
- {Event} e
- The browser's event object.
touchmove(e, mode)
This event is fired whenever the user is moving the finger over the board.
- Parameters:
- {Event} e
- The browser's event object.
- {Number} mode
- The mode the board currently is in
- See:
touchstart(e)
Whenever the user starts to touch the board.
- Parameters:
- {Event} e
- The browser's event object.
up(e)
Whenever the user stops to touch or click the board.
- Parameters:
- {Event} e
- The browser's event object.
update()
This board is updated.