Attributes
Own
none
Inherited
Members
Own
(private) size : Array
- Description
Width and height of the text element in pixel.
- Type
- Array
- Source
- base/text.js, line 111
Inherited
Methods
Own
(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
| Name | Type | Description |
|---|---|---|
text |
String | function | Number |
Details
- See
- Source
- base/text.js, line 219
(private) _setText(text) → {JXG.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
| Name | Type | Description |
|---|---|---|
text |
String | function | Number |
Returns
- Type
- JXG.Text
Details
- Source
- base/text.js, line 374
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.
Attention: for labels, [0, 0, 0, 0] is returned.
Returns
Array
Details
- Overrides
- JXG.CoordsElement#bounds
- Source
- base/text.js, line 1080
calculateScore(radius, angle) → {number}
Calculates the score of a label position with a given radius and angle. The score is calculated by the following rules:
- 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
| Name | Type | Description |
|---|---|---|
radius |
number | radius in pixels |
angle |
number | angle in radians |
Returns
Position score, higher values indicate better positions
- Type
- number
Details
- Source
- base/text.js, line 1267
(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.
Details
- Source
- base/text.js, line 674
(private) convertGeonext2CSS()
Converts the GEONExT tags
Details
- See
-
- JXG.Text.poorMansTeX
- JXG.Text._setText
- Source
- base/text.js, line 955
(private) convertGeonextAndSketchometry2CSS(s, escape)
Alias for convertGeonext2CSS and convertSketchometry2CSS
Parameters
| Name | Type | Description |
|---|---|---|
s |
String | function | Number | Text |
escape |
Boolean | Flag if ticks should be escaped |
Details
- See
-
- JXG.Text.convertGeonext2CSS
- JXG.Text.convertSketchometry2CSS
- Source
- base/text.js, line 1013
(private) convertSketchometry2CSS(s, escape)
Converts the sketchometry tag
Old tag was
Parameters
| Name | Type | Description |
|---|---|---|
s |
String | function | Number | Text |
escape |
Boolean | 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. |
Details
- See
-
- JXG.Text._setText
- JXG.Text.convertGeonextAndSketchometry2CSS
- Source
- base/text.js, line 986
crudeSizeEstimate() → {Array}
A very crude estimation of the dimensions of the textbox in case nothing else is available.
Returns
- Type
- Array
Details
- Source
- base/text.js, line 515
(private) escapeTicks(s)
Replace ticks by URI escape sequences
Parameters
| Name | Type | Description |
|---|---|---|
s |
String |
Returns
String
Details
- Source
- base/text.js, line 933
(private) expandShortMath(expr) → {string}
Converts shortened math syntax into correct syntax: 3x instead of 3x or (a+b)(3+1) instead of (a+b)(3+1).
Parameters
| Name | Type | Description |
|---|---|---|
expr |
String | Math term |
Returns
expanded String
- Type
- string
Details
- Source
- base/text.js, line 711
(private) generateTerm(contentStr, expandopt, avoidGeonext2JSopt, outputTeXopt)
Converts the GEONExT syntax of the
Obsolete, replaced by JXG.Text.valueTagToJessieCode
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
contentStr |
String | String to be parsed |
|
expand |
Boolean |
<optional> |
Optional flag if shortened math syntax is allowed (e.g. 3x instead of 3*x). |
avoidGeonext2JS |
Boolean |
<optional> |
Optional flag if geonext2JS should be called. For backwards compatibility this has to be set explicitly to true. |
outputTeX |
Boolean |
<optional> |
Optional flag which has to be true if the resulting term will be sent to MathJax or KaTeX. If true, "_" and "^" are NOT replaced by HTML tags sub and sup. Default: false, i.e. the replacement is done. This flag allows the combination of <value> tag containing calculations with TeX output. |
Details
- Deprecated
- Yes
- See
-
- JXG.GeonextParser#geonext2JS
- JXG.Text#valueTagToJessieCode
- Source
- base/text.js, line 738
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
Details
- Source
- base/text.js, line 1104
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
Details
- Source
- base/text.js, line 1131
(private) getNumberOfConflicts(x, y, w, h, whiteListopt) → {Number}
Computes the number of overlaps of a box of w pixels width, h pixels height and center (x, y)
An overlap occurs when either:
- For labels/points: Their bounding boxes intersect
- For other objects: The object contains the center point of the box
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
x |
Number | x-coordinate of the center (screen coordinates) |
|
y |
Number | y-coordinate of the center (screen coordinates) |
|
w |
Number | width of the box in pixel |
|
h |
Number | width of the box in pixel |
|
whiteList |
Array |
<optional> |
array of ids which should be ignored |
Returns
Number of overlapping elements
- Type
- Number
Details
- Source
- base/text.js, line 1169
getSize() → {Array}
Return the width of the text element.
Returns
[width, height] in pixel
- Type
- Array
Details
- Source
- base/text.js, line 603
(private) hasPoint(x, y) → {Boolean}
Parameters
| Name | Type | Description |
|---|---|---|
x |
Number | |
y |
Number |
Returns
- Type
- Boolean
Details
- Overrides
- JXG.CoordsElement#hasPoint
- Source
- base/text.js, line 160
(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
| Name | Type | Description |
|---|---|---|
content |
String | String containing dependencies for the given object. |
Details
- Source
- base/text.js, line 1025
(private) poorMansTeX(s) → {String|Array}
Simple math rendering using HTML / CSS only. In case of array, handle each entry separately and return array with the rendering strings.
Parameters
| Name | Type | Description |
|---|---|---|
s |
String | Array |
Returns
- Type
- String | Array
Details
replaceSub(te) → {String}
Replace _{} by <sub>
Parameters
| Name | Type | Description |
|---|---|---|
te |
String | String containing _{}. |
Returns
Given string with _{} replaced by <sub>.
- Type
- String
Details
- Source
- base/text.js, line 536
replaceSup(te) → {String}
Replace ^{} by <sup>
Parameters
| Name | Type | Description |
|---|---|---|
te |
String | String containing ^{}. |
Returns
Given string with ^{} replaced by <sup>.
- Type
- String
Details
- Source
- base/text.js, line 570
setAutoPosition() → {JXG.Text}
Automatically positions the label by finding the optimal position. Aims to minimize conflicts while maintaining readability.
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
Reference to the text object.
- Type
- JXG.Text
Details
- Source
- base/text.js, line 1356
setCoords(x, y) → {object}
Move the text to new coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
x |
number | |
y |
number |
Returns
reference to the text object.
- Type
- object
Details
- Source
- base/text.js, line 613
setText(text) → {JXG.Text}
Defines new content.
Parameters
| Name | Type | Description |
|---|---|---|
text |
String | function |
Returns
Reference to the text object.
- Type
- JXG.Text
Details
- Source
- base/text.js, line 423
setTextJessieCode(text)
Defines new content but converts < and > to HTML entities before updating the DOM.
Parameters
| Name | Type | Description |
|---|---|---|
text |
String | function |
Details
- Source
- base/text.js, line 399
(private) unescapeTicks(s)
Replace escape sequences for ticks by ticks
Parameters
| Name | Type | Description |
|---|---|---|
s |
String |
Returns
String
Details
- Source
- base/text.js, line 944
update()
Evaluates the text. Then, the update function of the renderer is called.
Details
- Overrides
- JXG.CoordsElement#update
- Source
- base/text.js, line 642
(private) updateRenderer()
The update function of the renderer is called.
Details
- Overrides
- JXG.CoordsElement#updateRenderer
- Source
- base/text.js, line 693
updateSize() → {this}
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
[description]
- Type
- this
Details
- Source
- base/text.js, line 439
(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.
Details
- Source
- base/text.js, line 241
utf8_decode(string) → {String}
Decode unicode entities into characters.
Parameters
| Name | Type | Description |
|---|---|---|
string |
String |
Returns
- Type
- String
Details
- Source
- base/text.js, line 525
(private) valueTagToJessieCode(contentStr)
Replace value-tags in string by JessieCode functions.
Example
"The x-coordinate of A is <value>X(A)</value>"
Parameters
| Name | Type | Description |
|---|---|---|
contentStr |
String |
Returns
String
Details
- Source
- base/text.js, line 828
Inherited
Events
Own
none
Inherited
Parameters
| Name | Type | Description |
|---|---|---|
board |
string | JXG.Board | The board the new text is drawn on. |
coordinates |
Array | An array with the user coordinates of the text. |
attributes |
Object | An object containing attributes and optional a name and a id. |
content |
string | function | A string or a function returning a string. |
Details
- Source
- base/text.js, line 88