Class JXG.AbstractRenderer
↳ JXG.AbstractRenderer
JXG.AbstractRenderer
Defined in: abstract.js.
Constructor Attributes | Constructor Name and Description |
---|---|
This class defines the interface to the graphics part of JSXGraph. |
Field Attributes | Field Name and Description |
---|---|
The HTML element that stores the JSXGraph board in it.
|
|
Defines dash patterns.
|
|
If this property is set to true the visual properties of the elements are updated
on every update.
|
|
<private> |
True if the browsers' SVG engine supports foreignObject.
|
This is used to easily determine which renderer we are using
|
|
The vertical offset for Text elements.
|
Method Attributes | Method Name and Description |
---|---|
<private> |
_css2js(cssString)
Converts string containing CSS properties into
array with key-value pair objects.
|
<private> |
_getHighlighted(el)
Get information if element is highlighted.
|
<private> |
_setArrowWidth(node, width, parentNode)
Updates width of an arrow DOM node.
|
<private> |
_updateVisual(el, not, enhanced)
Update visual properties, but only if JXG.AbstractRenderer#enhancedRendering or enhanced is set to true.
|
appendChildPrim(node, level)
Appends a node to a specific layer level.
|
|
appendNodesToElement(element, type)
Stores the rendering nodes.
|
|
changePointStyle(el)
Changes the style of a JXG.Point.
|
|
createPrim(type, id)
Creates a node of a given type with a given id.
|
|
Create crosshair elements (Fadenkreuz) for presentations.
|
|
display(element, value)
Shows or hides an element on the canvas; Only a stub, requires implementation in the derived renderer.
|
|
displayCopyright(str, fontsize)
Shows a small copyright notice in the top left corner of the board.
|
|
drawCurve(el)
|
|
drawEllipse(el)
Draws a JXG.Circle
|
|
drawImage(element)
Draws an JXG.Image on a board; This is just a template that has to be implemented by special
renderers.
|
|
drawInternalText(element)
An internal text is a JXG.Text element which is drawn using only
the given renderer but no HTML.
|
|
drawLine(el)
Draws a line on the JXG.Board.
|
|
<private> |
drawNavigationBar(board, attr)
The tiny zoom bar shown on the bottom of a board (if board attribute "showNavigation" is true).
|
drawPoint(el)
Draws a point on the JXG.Board.
|
|
drawPolygon(el)
Draws a JXG.Polygon on the JXG.Board.
|
|
drawText(el)
|
|
drawTicks(el)
Creates a rendering node for ticks added to a line.
|
|
dumpToCanvas(canvasId, w, h, _ignoreTexts)
Convert SVG construction to canvas.
|
|
dumpToDataURI(_ignoreTexts)
Convert SVG construction to base64 encoded SVG data URL.
|
|
<private> |
getArrowHeadData(el, strokewidth, hl)
This method determines some data about the line endings of this element.
|
getElementById(id)
Wrapper for getElementById for maybe other renderers which elements are not directly accessible by DOM
methods like document.getElementById().
|
|
getPositionArrowHead(el, c1, c2, a)
Shorten the length of a line element such that the arrow head touches
the start or end point and such that the arrow head ends exactly
at the start / end position of the line.
|
|
handleTouchpoints(el, c1, c2, a)
Handle touchlastpoint / touchfirstpoint
|
|
hide(element)
Hides an element on the canvas; Only a stub, requires implementation in the derived renderer.
|
|
Hide a specific crosshair.
|
|
highlight(el, suppressHighlightStrokeWidth)
Highlights an object, i.e.
|
|
joinTransforms(el, transformations)
Multiplication of transformations without updating.
|
|
makeArrows(element, arrowData)
Can be used to create the nodes to display arrows.
|
|
noHighlight(el)
Uses the normal colors of an object, i.e.
|
|
remove(node)
Removes an element node.
|
|
removeDraft(el)
Puts an object from draft mode back into normal mode.
|
|
Remove an element and provide a function that inserts it into its original position.
|
|
resize(w, h)
Resizes the rendering element
|
|
screenshot(board)
Display SVG image in html img-tag which enables
easy download for the user.
|
|
setARIA(element)
Set ARIA related properties of an element.
|
|
<private> |
setArrowSize(el, arrowData)
Set the arrow head size.
|
setBuffering(node, type)
Sets the buffering as recommended by SVGWG.
|
|
setCssClass(element, cssClass)
Sets CSS classes for elements (relevant for SVG only).
|
|
setDashStyle(element)
Sets an element's dash style.
|
|
setDraft(el)
Puts an object into draft mode, i.e.
|
|
setGradient(element)
Sets up nodes for rendering a gradient fill.
|
|
<private> |
setLayer(el, value)
Move element into new layer.
|
setLineCap(element)
Update the line endings (linecap) of a straight line from its attribute
'linecap'.
|
|
setObjectFillColor(element, color, opacity)
Sets an objects fill color.
|
|
setObjectStrokeColor(element, color, opacity)
Changes an objects stroke color to the given color.
|
|
setObjectStrokeWidth(element, width)
Sets an element's stroke width.
|
|
setObjectTransition(element, duration)
Sets the transition duration (in milliseconds) for fill color and stroke
color and opacity.
|
|
setPropertyPrim(node, key, val)
Sets a node's attribute.
|
|
setShadow(element)
Sets the shadow properties to a geometry element.
|
|
show(element)
Shows a hidden element on the canvas; Only a stub, requires implementation in the derived renderer.
|
|
Show a specific crosshair.
|
|
Stop redraw.
|
|
transformImage(element, transformations)
Applies transformations on images and text elements.
|
|
Restart redraw.
|
|
updateCurve(el)
Updates visual appearance of the renderer element assigned to the given JXG.Curve.
|
|
updateEllipse(el)
Updates visual appearance of a given JXG.Circle on the JXG.Board.
|
|
updateEllipsePrim(node, x, y, rx, ry)
Updates an ellipse node primitive.
|
|
updateGradient(element)
Updates the gradient fill.
|
|
updateImage(el)
Updates the properties of an JXG.Image element.
|
|
updateImageStyle(el, doHighlight)
Updates CSS style properties of a JXG.Image node.
|
|
updateImageURL(element)
If the URL of the image is provided by a function the URL has to be updated during updateImage()
|
|
updateInternalText(element)
Updates visual properties of an already existing JXG.Text element.
|
|
<private> |
updateInternalTextStyle(el, strokeColor, strokeOpacity)
Set color and opacity of internal texts.
|
updateLine(el)
Updates visual appearance of the renderer element assigned to the given JXG.Line.
|
|
updateLinePrim(node, p1x, p1y, p2x, p2y, board)
Refreshes a line node.
|
|
<private> |
updateLineWithEndings(el, arrowData)
Corrects the line length if there are arrow heads, such that
the arrow ends exactly at the intended position.
|
<private> |
updatePath(el)
Calls the renderer method to draw a curve.
|
updatePathPrim(node, pathString, board)
Updates a path element.
|
|
updatePathStringBezierPrim(element)
Builds a path data string from a JXG.Curve element such that the curve looks like hand drawn.
|
|
updatePathStringPoint(element, size, type)
Builds a path data string to draw a point with a face other than rect and circle.
|
|
updatePathStringPrim(element)
Builds a path data string from a JXG.Curve element.
|
|
<private> |
updatePathWithArrowHeads(el, doHighlight)
Handles arrow heads of a line or curve element and calls the renderer primitive.
|
updatePoint(el)
Updates visual appearance of the renderer element assigned to the given JXG.Point.
|
|
updatePolygon(el)
Updates properties of a JXG.Polygon's rendering node.
|
|
updatePolygonPrim(node, element)
Update a polygon primitive.
|
|
updateRectPrim(node, x, y, w, h)
Update a rectangle primitive.
|
|
updateText(el)
Updates visual properties of an already existing JXG.Text element.
|
|
updateTextStyle(el, doHighlight)
Updates font-size, color and opacity propertiey and CSS style properties of a JXG.Text node.
|
|
updateTicks(element)
|
|
updateTouchpoint(i, pos)
Move a specific crosshair.
|
This class defines the interface to the graphics part of JSXGraph. This class is an abstract class, it actually does not render anything. This is up to the JXG.SVGRenderer, JXG.VMLRenderer, and JXG.CanvasRenderer classes. We strongly discourage you from using the methods in these classes directly. Only the methods which are defined in this class and are not marked as private are guaranteed to exist in any renderer instance you can access via JXG.Board#renderer. But not all methods may work as expected.
The methods of this renderer can be divided into different categories:
- Draw basic elements
- In this category we find methods to draw basic elements like JXG.Point, JXG.Line, and JXG.Curve as well as assisting methods tightly bound to these basic painters. You do not need to implement these methods in a descendant renderer but instead implement the primitive drawing methods described below. This approach is encouraged when you're using a XML based rendering engine like VML and SVG. If you want to use a bitmap based rendering technique you are supposed to override these methods instead of the primitive drawing methods.
- Draw primitives
- This category summarizes methods to handle primitive nodes. As creation and management of these nodes is different among different the rendering techniques most of these methods are purely virtual and need proper implementation if you choose to not overwrite the basic element drawing methods.
- Attribute manipulation
- In XML based renders you have to manipulate XML nodes and their attributes to change the graphics. For that purpose attribute manipulation methods are defined to set the color, opacity, and other things. Please note that some of these methods are required in bitmap based renderers, too, because some elements like JXG.Text can be HTML nodes floating over the construction.
- Renderer control
- Methods to clear the drawing board or to stop and to resume the rendering engine.
- 2 dash, 2 space
- 5 dash, 5 space
- 10 dash, 10 space
- 20 dash, 20 space
- 20 dash, 10 space, 10 dash, 10 space
- 20 dash, 5 space, 10 dash, 5 space
- 0 dash, 5 space (dotted line)
- Default Value:
- [[2, 2], [5, 5], [10, 10], [20, 20], [20, 10, 10, 10], [20, 5, 10, 5], [0, 5]]
- Default Value:
- true
if (board.renderer.type === 'vml') { // do something }
- Default Value:
- 0
- Parameters:
- {String} cssString
- String containing CSS properties
- Returns:
- {Array} Array of CSS key-value pairs
- Examples:
"color:blue; background-color:yellow" is converted to [{'color': 'blue'}, {'backgroundColor': 'yellow'}]
- Parameters:
- {JXG.GeometryElement} el
- The element which is tested for being highlighted.
- Returns:
- {String} 'highlight' if highlighted, otherwise the ampty string '' is returned.
- Parameters:
- {Node} node
- The arrow node.
- {Number} width
- {Node} parentNode
- Used in IE only
- Parameters:
- {JXG.GeometryElement} el
- The element to update
- {Object} not Optional, Default: {}
- Select properties you don't want to be updated: {fill: true, dash: true} updates everything except for fill and dash. Possible values are stroke, fill, dash, shadow, gradient.
- {Boolean} enhanced Optional, Default: false
- If true, JXG.AbstractRenderer#enhancedRendering is assumed to be true.
- Parameters:
- {Node} node
- A DOM tree node.
- {Number} level
- The layer the node is attached to. This is the index of the layer in JXG.SVGRenderer#layer or the z-index style property of the node in VMLRenderer.
- Parameters:
- {JXG.GeometryElement} element
- A JSXGraph element.
- {String} type
- The XML node name. Only used in VMLRenderer.
- Parameters:
- {String} type
- The type of the node to create.
- {String} id
- Set the id attribute to this.
- Returns:
- {Node} Reference to the created node.
- Parameters:
- {Number} n
- Number of crosshairs.
- Parameters:
- {JXG.GeometryElement} element
- Reference to the object that has to appear.
- {Boolean} value
- true to show the element, false to hide the element.
- Parameters:
- {String} str
- The copyright notice itself
- {Number} fontsize
- Size of the font the copyright notice is written in
- Parameters:
- {JXG.Curve} el
- Reference to a graph object, that has to be plotted.
- Parameters:
- {JXG.Circle} el
- Reference to a JXG.Circle object that has to be drawn.
- Parameters:
- {JXG.Image} element
- Reference to the image object that is to be drawn
- See:
- Text
- JXG.Text
- JXG.AbstractRenderer#updateInternalText
- JXG.AbstractRenderer#drawText
- JXG.AbstractRenderer#updateText
- JXG.AbstractRenderer#updateTextStyle
- Parameters:
- {JXG.Line} el
- Reference to a line object, that has to be drawn.
The buttons get the CSS class "JXG_navigation_button" and the id {board_id}_name where name is one of [top, down, left, right, out, 100, in, fullscreen, screenshot, reload, cleartraces].
The symbols for zoom, navigation and reload are hard-coded.
- Parameters:
- {JXG.Board} board
- Reference to a JSXGraph board.
- {Object} attr
- Attributes of the navigation bar
- Parameters:
- {JXG.Polygon} el
- Reference to a Polygon object, that is to be drawn.
- See:
- Text
- JXG.Text
- JXG.AbstractRenderer#drawInternalText
- JXG.AbstractRenderer#updateText
- JXG.AbstractRenderer#updateInternalText
- JXG.AbstractRenderer#updateTextStyle
- Parameters:
- {JXG.Line} el
- A arbitrary line.
- Parameters:
- canvasId
- w
- h
- _ignoreTexts
- Parameters:
- _ignoreTexts
The returned object also contains the types of the arrow heads.
- Parameters:
- {JXG.GeometryElement} el
- JSXGraph line or curve element
- {Number} strokewidth
- strokewidth of the element
- {String} hl
- Ither 'highlight' or empty string
- Returns:
- {Object} object containing the data
- Parameters:
- {String} id
- Unique identifier for element.
- Returns:
- {Object} Reference to a JavaScript object. In case of SVG/VMLRenderer it's a reference to a SVG/VML node.
The Coords objects c1 and c2 are changed in place. In object a, the Boolean properties 'showFirst' and 'showLast' are set.
- Parameters:
- {JXG.Line} el
- Reference to the line object that gets arrow heads.
- {JXG.Coords} c1
- Coords of the first point of the line (after JXG.Math.Geometry#calcStraight).
- {JXG.Coords} c2
- Coords of the second point of the line (after JXG.Math.Geometry#calcStraight).
- {Object} a
- Object { evFirst: Boolean, evLast: Boolean} containing information about arrow heads.
- Parameters:
- {JXG.GeometryElement} el
- {JXG.Coords} c1
- Coordinates of the start of the line. The coordinates are changed in place.
- {JXG.Coords} c2
- Coordinates of the end of the line. The coordinates are changed in place.
- {Object} a
- Parameters:
- {JXG.GeometryElement} element
- Reference to the geometry element that has to disappear.
- Parameters:
- {Number} i
- Number of the crosshair to show
- Parameters:
- {JXG.GeometryElement} el
- Reference of the object that will be highlighted.
- {Boolean} suppressHighlightStrokeWidth Optional, Default: undefined
- If undefined or false, highlighting also changes strokeWidth. This might not be the cases for polygon borders. Thus, if a polygon is highlighted, its polygon borders change strokeWidth only if the polygon attribute highlightByStrokeWidth == true.
- Returns:
- {JXG.AbstractRenderer} Reference to the renderer
- Parameters:
- {JXG.GeometryElement} el
- A JSXGraph element. We only need its board property.
- {Array} transformations
- An array of JXG.Transformations.
- Returns:
- {Array} A matrix represented by a two dimensional array of numbers.
- Parameters:
- {JXG.GeometryElement} element
- The element the arrows are to be attached to.
- {Object} arrowData
- Data concerning possible arrow heads
- Parameters:
- {JXG.GeometryElement} el
- Reference of the object that will get its normal colors.
- Returns:
- {JXG.AbstractRenderer} Reference to the renderer
- Parameters:
- {Node} node
- The node to remove.
- Parameters:
- {JXG.GeometryElement} el
- Reference of the object that no longer is in draft mode.
Author: KeeKim Heng, Google Web Developer.
- Parameters:
- {Element} el
- The element to be temporarily removed
- Returns:
- {Function} A function that inserts the element into its original position
- Parameters:
- {Number} w
- New width
- {Number} h
- New height
- Parameters:
- board
In JSXGraph, the available properties are used without the leading 'aria-'. For example, the value of the JSXGraph attribute 'aria.label' will be set to the HTML attribute 'aria-label'.
- Parameters:
- {JXG.GeometryElement} element
- Reference of the object that wants new ARIA attributes.
- Parameters:
- {JXG.GeometryElement} el
- Reference to a line or curve object that has to be drawn.
- {Object} arrowData
- Data concerning possible arrow heads
- Returns:
- {JXG.AbstractRenderer} Reference to the renderer
- See:
- Line
- JXG.Line
- Curve
- JXG.Curve
- JXG.AbstractRenderer#updatePathWithArrowHeads
- JXG.AbstractRenderer#getArrowHeadData
- Parameters:
- {Node} node
- The SVG DOM Node which buffering type to update.
- {String} type
- Either 'auto', 'dynamic', or 'static'. For an explanation see https://www.w3.org/TR/SVGTiny12/painting.html#BufferedRenderingProperty.
- Parameters:
- {JXG.GeometryElement} element
- Reference of the object that wants a new set of CSS classes.
- {String} cssClass
- String containing a space separated list of CSS classes.
- Parameters:
- {JXG.GeometryElement} element
- An JSXGraph element.
- Parameters:
- {JXG.GeometryElement} el
- Reference of the object that is in draft mode.
- Parameters:
- element
- Parameters:
- {JXG.GeometryElement} el
- Element which is put into different layer
- {Number} value
- Layer number
- Parameters:
- {JXG.Line} element
- A arbitrary line.
- Parameters:
- {JXG.GeometryElement} element
- Reference of the object that wants a new fill color.
- {String} color
- Color in a HTML/CSS compatible format. If you don't want any fill color at all, choose 'none'.
- {Number} opacity
- Opacity of the fill color. Must be between 0 and 1.
- Parameters:
- {JXG.GeometryElement} element
- Reference of the JXG.GeometryElement that gets a new stroke color.
- {String} color
- Color value in a HTML compatible format, e.g. #00ff00 or green for green.
- {Number} opacity
- Opacity of the fill color. Must be between 0 and 1.
- Parameters:
- {JXG.GeometryElement} element
- Reference to the geometry element.
- {Number} width
- The new stroke width to be assigned to the element.
- Parameters:
- {JXG.GeometryElement} element
- Reference of the object that wants a new transition duration.
- {Number} duration
- (Optional) duration in milliseconds. If not given, element.visProp.transitionDuration is taken. This is the default.
- Parameters:
- {Node} node
- The node that is to be updated.
- {String} key
- Name of the attribute.
- {String} val
- New value for the attribute.
- Parameters:
- {JXG.GeometryElement} element
- Reference to a geometry object, that should get a shadow
- Parameters:
- {JXG.GeometryElement} element
- Reference to the object that has to appear.
- Parameters:
- {Number} i
- Number of the crosshair to show
Only affine transformation are supported, no proper projective transformations. This means, the respective entries of the transformation matrix are simply ignored.
- Parameters:
- {JXG.Image|JXG.Text} element
- A JXG.Image or JXG.Text object.
- {Array} transformations
- An array of JXG.Transformation objects. This is usually the transformations property of the given element el.
- Parameters:
- {JXG.Circle} el
- Reference to a JXG.Circle object, that has to be updated.
- Parameters:
- {Node} node
- Reference to the node.
- {Number} x
- Centre X coordinate
- {Number} y
- Centre Y coordinate
- {Number} rx
- The x-axis radius.
- {Number} ry
- The y-axis radius.
- Parameters:
- {JXG.GeometryElement} element
- An JSXGraph element with an area that can be filled.
- Parameters:
- {JXG.Text} el
- Reference to the JXG.Image object, that has to be updated.
- {Boolean} doHighlight
- Parameters:
- {JXG.Image} element
- Reference to an image object.
- See:
- Text
- JXG.Text
- JXG.AbstractRenderer#drawInternalText
- JXG.AbstractRenderer#drawText
- JXG.AbstractRenderer#updateText
- JXG.AbstractRenderer#updateTextStyle
- Parameters:
- el
- strokeColor
- strokeOpacity
- Parameters:
- {Node} node
- The node to be refreshed.
- {Number} p1x
- The first point's x coordinate.
- {Number} p1y
- The first point's y coordinate.
- {Number} p2x
- The second point's x coordinate.
- {Number} p2y
- The second point's y coordinate.
- {JXG.Board} board
- Parameters:
- {JXG.Line} el
- Reference to a line object, that has to be drawn
- {Object} arrowData
- Data concerning possible arrow heads
- Returns:
- {JXG.AbstractRenderer} Reference to the renderer
- Parameters:
- {JXG.GeometryElement} el
- Reference to a line object, that has to be drawn.
- Returns:
- {JXG.AbstractRenderer} Reference to the renderer
- Parameters:
- {Node} node
- The path node.
- {String} pathString
- A string formatted like e.g. 'M 1,2 L 3,1 L5,5'. The format of the string depends on the rendering engine.
- {JXG.Board} board
- Reference to the element's board.
- Parameters:
- element
- Parameters:
- {JXG.Point} element
- The point element
- {Number} size
- A positive number describing the size. Usually the half of the width and height of the drawn point.
- {String} type
- A string describing the point's face. This method only accepts the shortcut version of each possible face: x, +, |, -, [], <>, <<>>,^, v, >, <
- Parameters:
- element
- Parameters:
- {JXG.GeometryElement} el
- Reference to a line or curve object that has to be drawn.
- {Boolean} doHighlight
- See:
- Line
- JXG.Line
- Curve
- JXG.Curve
- JXG.AbstractRenderer#updateLine
- JXG.AbstractRenderer#updateCurve
- JXG.AbstractRenderer#makeArrows
- JXG.AbstractRenderer#getArrowHeadData
- Parameters:
- {JXG.Polygon} el
- Reference to a JXG.Polygon object, that has to be updated.
- Parameters:
- {Node} node
- {JXG.Polygon} element
- A JSXGraph element of type JXG.Polygon
- Parameters:
- {Node} node
- The node yearning to be updated.
- {Number} x
- x coordinate of the top left vertex.
- {Number} y
- y coordinate of the top left vertex.
- {Number} w
- Width of the rectangle.
- {Number} h
- The rectangle's height.
- See:
- Text
- JXG.Text
- JXG.AbstractRenderer#drawText
- JXG.AbstractRenderer#drawInternalText
- JXG.AbstractRenderer#updateInternalText
- JXG.AbstractRenderer#updateTextStyle
- Parameters:
- {JXG.Text} el
- Reference to the JXG.Text object, that has to be updated.
- {Boolean} doHighlight
- See:
- Text
- JXG.Text
- JXG.AbstractRenderer#drawText
- JXG.AbstractRenderer#drawInternalText
- JXG.AbstractRenderer#updateText
- JXG.AbstractRenderer#updateInternalText
- JXG.AbstractRenderer#updateInternalTextStyle
- Parameters:
- {JXG.Ticks} element
- Reference of a ticks object that has to be updated.
- Parameters:
- {Number} i
- Number of the crosshair to show
- {Array} pos
- New positon in screen coordinates