JavaScript must be enabled in order for you to use JSXGraph and JSXGraph reference. However, it seems JavaScript is either disabled or not supported by your browser.

Class Index | File Index

Elements
Classes

Class JXG.Text

JXG.GeometryElement,JXG.CoordsElement
      ↳ JXG.Text

Creates a new text object. Do not use this constructor to create a text. Use JXG.Board#create with type Text instead.

Defined in: text.js.
Extends JXG.CoordsElement, JXG.GeometryElement.

Class Summary
Constructor Attributes Constructor Name and Description
 
JXG.Text(board, coordinates, attributes, content)
Construct and handle texts.
Fields borrowed from class JXG.GeometryElement:
_org_type, _pos, ancestors, aria, baseElement, board, childElements, cssClass, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, element3D, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlightCssClass, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, nonnegativeOnly, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, visible, visProp, visPropCalc, withLabel
Fields borrowed from class JXG.CoordsElement:
coords, groups, isConstrained, needsUpdateFromParent, onPolygon, position, slideObject, slideObjects
Field Summary
Field Attributes Field Name and Description
<private>  
Width and height of the text element in pixel.
Fields borrowed from class JXG.GeometryElement:
_org_type, _pos, ancestors, aria, baseElement, board, childElements, cssClass, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, element3D, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlightCssClass, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, nonnegativeOnly, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, visible, visProp, visPropCalc, withLabel
Fields borrowed from class JXG.CoordsElement:
coords, groups, isConstrained, needsUpdateFromParent, onPolygon, position, slideObject, slideObjects
Method Summary
Method Attributes Method Name and Description
<private>  
This sets the updateText function of this element depending on the type of text content passed.
<private>  
_setText(text)
Defines new content.
 
Returns the bounding box of the text element in user coordinates as an array of length 4: [upper left x, upper left y, lower right x, lower right y].
<private>  
Used to save updateSize() calls.
<private>  
Converts the GEONExT tags and to HTML span tags with proper CSS formatting.
<private>  
Alias for convertGeonext2CSS and convertSketchometry2CSS
<private>  
Converts the sketchometry tag to HTML span tags with proper CSS formatting.
 
A very crude estimation of the dimensions of the textbox in case nothing else is available.
<private>  
Replace ticks by URI escape sequences
<private>  
Converts shortened math syntax into correct syntax: 3x instead of 3*x or (a+b)(3+1) instead of (a+b)*(3+1).
<private>  
generateTerm(contentStr, expand, avoidGeonext2JS)
Converts the GEONExT syntax of the terms into JavaScript.
 
Returns the value of the attribute "anchorX".
 
Returns the value of the attribute "anchorY".
<private>  
getNumberOfConflicts(x, y, w, h, whiteList)
Computes the number of overlaps of a box of w pixels width, h pixels height and center (x, y)
 
Return the width of the text element.
<private>  
hasPoint(x, y)
<private>  
notifyParents(content)
Finds dependencies in a given term and notifies the parents by adding the dependent object to the found objects child elements.
<private>  
Simple math rendering using HTML / CSS only.
 
Replace _{} by <sub>
 
Replace ^{} by <sup>
 
Sets the offset of a label element to the position with the least number of overlaps with other elements, while retaining the distance to its anchor element.
 
setCoords(x, y)
Move the text to new coordinates.
 
setText(text)
Defines new content.
 
Defines new content but converts < and > to HTML entities before updating the DOM.
<private>  
Replace escape sequences for ticks by ticks
 
update(fromParent)
Evaluates the text.
<private>  
The update function of the renderer is called.
 
Recompute the width and the height of the text box.
<private>  
Dynamically created function to update the content of a text.
 
utf8_decode(string)
Decode unicode entities into characters.
<private>  
Replace value-tags in string by JessieCode functions.
Methods borrowed from class JXG.GeometryElement:
_set, addChild, addDescendants, addParents, addParentsFromJCFunctions, addRotation, addTicks, addTransform, animate, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, eval, evalVisProp, formatNumberLocale, fullUpdate, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getProperty, getSnapSizes, getTextAnchor, getType, handleSnapToGrid, hide, hideElement, noHighlight, normalize, prepareUpdate, remove, removeAllTicks, removeChild, removeDescendants, removeTicks, resolveShortcuts, setArrow, setAttribute, setDash, setDisplayRendNode, setLabel, setLabelText, setName, setParents, setPosition, setPositionDirectly, setProperty, show, showElement, snapToPoints, updateVisibility, useLocale
Methods borrowed from class JXG.CoordsElement:
_anim, addAnchor, addConstraint, Coords, Dist, findClosestSnapValue, free, handleAttractors, handleSnapToPoints, makeGlider, moveAlong, moveTo, popSlideObject, setGliderPosition, setPositionByTransform, updateConstraint, updateCoords, updateGlider, updateGliderFromParent, updateTransform, visit, X, XEval, Y, YEval, Z, ZEval
Events borrowed from class JXG.GeometryElement:
attribute, attribute:key, down, drag, keydrag, mousedown, mousedrag, mousemove, mouseout, mouseover, mouseup, move, out, over, pendown, pendrag, penup, touchdown, touchdrag, touchup, up
Class Detail
JXG.Text(board, coordinates, attributes, content)
Construct and handle texts. The coordinates can be relative to the coordinates of an element given in JXG.Options#text.anchor. MathJax, HTML and GEONExT syntax can be handled.
Parameters:
{string|JXG.Board} board
The board the new text is drawn on.


{Array} coordinates
An array with the user coordinates of the text.


{Object} attributes
An object containing visual properties and optional a name and a id.


{string|function} content
A string or a function returning a string.


Field Detail
<private> {Array} size
Width and height of the text element in pixel.
Method Detail
<private> _createFctUpdateText(text)
This sets the updateText function of this element depending on the type of text content passed. Used by JXG.Text#_setText.
Parameters:
{String|Function|Number} text
See:
JXG.Text#_setText

<private> {JXG.Text} _setText(text)
Defines new content. This is used by JXG.Text#setTextJessieCode and JXG.Text#setText. This is required because JessieCode needs to filter all Texts inserted into the DOM and thus has to replace setText by setTextJessieCode.
Parameters:
{String|Function|Number} text
Returns:
{JXG.Text}

bounds()
Returns the bounding box of the text element in user coordinates as an array of length 4: [upper left x, upper left y, lower right x, lower right y]. The method assumes that the lower left corner is at position [el.X(), el.Y()] of the text element el, i.e. the attributes anchorX, anchorY are ignored.

or labels, [0, 0, 0, 0] is returned.

Returns:
Array

<private> checkForSizeUpdate()
Used to save updateSize() calls. Called in JXG.Text.update That means this.update() has been called. More tests are in JXG.Renderer.updateTextStyle. The latter tests are one update off. But this should pose not too many problems, since it affects fontSize and cssClass changes.

<private> convertGeonext2CSS(s)
Converts the GEONExT tags and to HTML span tags with proper CSS formatting.
Parameters:
s
See:
JXG.Text.poorMansTeX
JXG.Text._setText

<private> convertGeonextAndSketchometry2CSS(s, escape)
Alias for convertGeonext2CSS and convertSketchometry2CSS
Parameters:
{String|Function|Number} s
Text
{Boolean} escape
Flag if ticks should be escaped
See:
JXG.Text.convertGeonext2CSS
JXG.Text.convertSketchometry2CSS

<private> convertSketchometry2CSS(s, escape)
Converts the sketchometry tag to HTML span tags with proper CSS formatting.
Parameters:
{String|Function|Number} s
Text
{Boolean} escape
Flag if ticks should be escaped. Escaping is necessary if s is a text. It has to be avoided if s is a function returning text.
See:
JXG.Text._setText
JXG.Text.convertGeonextAndSketchometry2CSS

{Array} crudeSizeEstimate()
A very crude estimation of the dimensions of the textbox in case nothing else is available.
Returns:
{Array}

<private> escapeTicks(s)
Replace ticks by URI escape sequences
Parameters:
{String} s
Returns:
String

<private> {string} expandShortMath(expr)
Converts shortened math syntax into correct syntax: 3x instead of 3*x or (a+b)(3+1) instead of (a+b)*(3+1).
Parameters:
expr
Returns:
{string} expanded String

<private> generateTerm(contentStr, expand, avoidGeonext2JS)
Converts the GEONExT syntax of the terms into JavaScript. Also, all Objects whose name appears in the term are searched and the text is added as child to these objects. This method is called if the attribute parse==true is set. Obsolete, replaced by JXG.Text.valueTagToJessieCode
Parameters:
contentStr
expand
avoidGeonext2JS
See:
JXG.GeonextParser#geonext2JS
JXG.Text#valueTagToJessieCode

getAnchorX()
Returns the value of the attribute "anchorX". If this equals "auto", returns "left", "middle", or "right", depending on the value of the attribute "position".
Returns:
String

getAnchorY()
Returns the value of the attribute "anchorY". If this equals "auto", returns "bottom", "middle", or "top", depending on the value of the attribute "position".
Returns:
String

<private> {Number} getNumberOfConflicts(x, y, w, h, whiteList)
Computes the number of overlaps of a box of w pixels width, h pixels height and center (x, y)
Parameters:
{Number} x
x-coordinate of the center (screen coordinates)
{Number} y
y-coordinate of the center (screen coordinates)
{Number} w
width of the box in pixel
{Number} h
width of the box in pixel
{Array} whiteList Optional
array of ids which should be ignored
Returns:
{Number} Number of overlapping elements

{Array} getSize()
Return the width of the text element.
Returns:
{Array} [width, height] in pixel

<private> {Boolean} hasPoint(x, y)
Parameters:
{Number} x
{Number} y
Returns:
{Boolean}

<private> notifyParents(content)
Finds dependencies in a given term and notifies the parents by adding the dependent object to the found objects child elements.
Parameters:
{String} content
String containing dependencies for the given object.

<private> {String|Array} poorMansTeX(s)
Simple math rendering using HTML / CSS only. In case of array, handle each entry separately and return array with the rendering strings.
Parameters:
{String|Array} s
Returns:
{String|Array}
See:
JXG.Text#convertGeonextAndSketchometry2CSS
JXG.Text#replaceSub
JXG.Text#replaceSup
JXG.Text#convertGeonextAndSketchometry2CSS

{String} replaceSub(te)
Replace _{} by <sub>
Parameters:
{String} te
String containing _{}.
Returns:
{String} Given string with _{} replaced by <sub>.

{String} replaceSup(te)
Replace ^{} by <sup>
Parameters:
{String} te
String containing ^{}.
Returns:
{String} Given string with ^{} replaced by <sup>.

{JXG.Text} setAutoPosition()
Sets the offset of a label element to the position with the least number of overlaps with other elements, while retaining the distance to its anchor element. Twelve different angles are possible.
Returns:
{JXG.Text} Reference to the text object.

{object} setCoords(x, y)
Move the text to new coordinates.
Parameters:
{number} x
{number} y
Returns:
{object} reference to the text object.

{JXG.Text} setText(text)
Defines new content.
Parameters:
{String|function} text
Returns:
{JXG.Text} Reference to the text object.

setTextJessieCode(text)
Defines new content but converts < and > to HTML entities before updating the DOM.
Parameters:
{String|function} text

<private> unescapeTicks(s)
Replace escape sequences for ticks by ticks
Parameters:
{String} s
Returns:
String

update(fromParent)
Evaluates the text. Then, the update function of the renderer is called.
Parameters:
fromParent

<private> updateRenderer()
The update function of the renderer is called.

{this} updateSize()
Recompute the width and the height of the text box. Updates the array JXG.Text#size with pixel values. The result may differ from browser to browser by some pixels. In canvas an old IEs we use a very crude estimation of the dimensions of the textbox. JSXGraph needs JXG.Text#size for applying rotations in IE and for aligning text.
Returns:
{this} [description]

<private> updateText()
Dynamically created function to update the content of a text. Can not be overwritten.

<value> tags will not be evaluated if text is provided by a function

Sets the property plaintext of the text element.


{String} utf8_decode(string)
Decode unicode entities into characters.
Parameters:
{String} string
Returns:
{String}

<private> valueTagToJessieCode(contentStr)
Replace value-tags in string by JessieCode functions.
Parameters:
{String} contentStr
Returns:
String
Examples:
"The x-coordinate of A is <value>X(A)</value>"

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Nov 08 2024 12:13:06 GMT+0100 (Mitteleuropäische Normalzeit)