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.
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, ignoreForLabelAutoposition, 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 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, ignoreForLabelAutoposition, 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 Attributes | Method Name and Description |
---|---|
<private> |
_createFctUpdateText(text)
This sets the updateText function of this element depending on the type of text content passed.
|
<private> |
_setText(text)
Defines new content.
|
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].
|
|
calculateScore(radius, angle)
Calculates the score of a label position with a given radius and angle.
|
|
<private> |
Used to save updateSize() calls.
|
<private> |
Converts the GEONExT tags
|
<private> |
convertGeonextAndSketchometry2CSS(s, escape)
Alias for convertGeonext2CSS and convertSketchometry2CSS
|
<private> |
convertSketchometry2CSS(s, escape)
Converts the sketchometry tag
|
A very crude estimation of the dimensions of the textbox in case nothing else is available.
|
|
<private> |
escapeTicks(s)
Replace ticks by URI escape sequences
|
<private> |
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).
|
<private> |
generateTerm(contentStr, expand, avoidGeonext2JS)
Converts the GEONExT syntax of the
|
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)
An overlap occurs when either:
|
getSize()
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> |
poorMansTeX(s)
Simple math rendering using HTML / CSS only.
|
replaceSub(te)
Replace _{} by <sub>
|
|
replaceSup(te)
Replace ^{} by <sup>
|
|
Automatically positions the label by finding the optimal position.
|
|
setCoords(x, y)
Move the text to new coordinates.
|
|
setText(text)
Defines new content.
|
|
setTextJessieCode(text)
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> |
valueTagToJessieCode(contentStr)
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, moveAlongES6, moveTo, moveToES6, popSlideObject, setGliderPosition, setPositionByTransform, updateConstraint, updateCoords, updateGlider, updateGliderFromParent, updateTransform, visit, visitES6, 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
- 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.
- Parameters:
- {String|Function|Number} text
- See:
- JXG.Text#_setText
- Parameters:
- {String|Function|Number} text
- Returns:
- {JXG.Text}
Attention: for labels, [0, 0, 0, 0] is returned.
- Returns:
- Array
- the maximum score is 0
- if the label is outside of the bounding box, the score is reduced by 1
- for each conflict, the score is reduced by 1
- the score is reduced by the displacement (angle difference between old and new position) of the label
- the score is reduced by the angle between the original label position and the new label position
- Parameters:
- {number} radius
- radius in pixels
- {number} angle
- angle in radians
- Returns:
- {number} Position score, higher values indicate better positions
- Parameters:
- s
- See:
- JXG.Text.poorMansTeX
- JXG.Text._setText
- Parameters:
- {String|Function|Number} s
- Text
- {Boolean} escape
- Flag if ticks should be escaped
- See:
- JXG.Text.convertGeonext2CSS
- JXG.Text.convertSketchometry2CSS
- 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
- Returns:
- {Array}
- Parameters:
- {String} s
- Returns:
- String
- Parameters:
- expr
- Returns:
- {string} expanded String
- Parameters:
- contentStr
- expand
- avoidGeonext2JS
- See:
- JXG.GeonextParser#geonext2JS
- JXG.Text#valueTagToJessieCode
- Returns:
- String
- Returns:
- String
- For labels/points: Their bounding boxes intersect
- For other objects: The object contains the center point of the box
- 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
- Returns:
- {Array} [width, height] in pixel
- Parameters:
- {Number} x
- {Number} y
- Returns:
- {Boolean}
- Parameters:
- {String} content
- String containing dependencies for the given object.
- Parameters:
- {String|Array} s
- Returns:
- {String|Array}
- See:
- JXG.Text#convertGeonextAndSketchometry2CSS
- JXG.Text#replaceSub
- JXG.Text#replaceSup
- JXG.Text#convertGeonextAndSketchometry2CSS
- Parameters:
- {String} te
- String containing _{}.
- Returns:
- {String} Given string with _{} replaced by <sub>.
- Parameters:
- {String} te
- String containing ^{}.
- Returns:
- {String} Given string with ^{} replaced by <sup>.
The method tests 60 different angles (0 to 2π) at 3 different distances (radii). It evaluates each position using calculateScore(radius, angle) and chooses the position with the highest score. Then the label's anchor points and offset are adjusted accordingly.
- Returns:
- {JXG.Text} Reference to the text object.
- Parameters:
- {number} x
- {number} y
- Returns:
- {object} reference to the text object.
- Parameters:
- {String|function} text
- Returns:
- {JXG.Text} Reference to the text object.
- Parameters:
- {String|function} text
- Parameters:
- {String} s
- Returns:
- String
- Parameters:
- fromParent
- Returns:
- {this} [description]
<value> tags will not be evaluated if text is provided by a function
Sets the property plaintext of the text element.
- Parameters:
- {String} string
- Returns:
- {String}
- Parameters:
- {String} contentStr
- Returns:
- String
- Examples:
"The x-coordinate of A is <value>X(A)</value>"