Class JXG.GeometryElement
↳ JXG.GeometryElement
This is the basic class for geometry elements like points, circles and lines.
Defined in: element.js.
Constructor Attributes | Constructor Name and Description |
---|---|
JXG.GeometryElement(board, attributes, type, oclass)
Constructs a new GeometryElement object.
|
Field Attributes | Field Name and Description |
---|---|
<private> <constant> |
Original type of the element at construction time.
|
<private> |
The position of this element inside the JXG.Board#objectsList.
|
Elements on which this element depends on are stored here.
|
|
<private> | |
Reference to the board associated with the element.
|
|
Stores all dependent objects to be updated when this point is moved.
|
|
Determines the elements border-style.
|
|
Elements depending on this element are stored here.
|
|
If true the element will be drawn in grey scale colors to visualize that it's only a draft.
|
|
The element is saved with an explicit entry in the file (true) or implicitly
via a composition.
|
|
<constant> |
The element's class.
|
The string used with JXG.Board#create
|
|
The fill color of this geometry element.
|
|
Opacity for fill color.
|
|
If true the element is fixed and can not be dragged around.
|
|
If true the element is fixed and can not be dragged around.
|
|
If element has a label subelement then this property will be set to true.
|
|
True, if the element is currently highlighted.
|
|
The fill color of the given geometry element when the mouse is pointed over it.
|
|
Opacity for fill color when the object is highlighted.
|
|
The stroke color of the given geometry element when the user moves the mouse over it.
|
|
Opacity for stroke color when the object is highlighted.
|
|
Width of the element's stroke when the mouse is pointed over it.
|
|
Unique identifier for the element.
|
|
Inherits contains the subelements, which may have an attribute
(in partuclar the attribute "visible") having value 'inherit'.
|
|
Controls if this element can be dragged.
|
|
If element is in two dimensional real space this is true, else false.
|
|
Time stamp containing the last time this element has been dragged.
|
|
The methodMap determines which methods can be called from within JessieCode and under which name it
can be used.
|
|
Is the mouse over this element?
|
|
Not necessarily unique name for the element.
|
|
If this is set to true, the element is updated in every update
call of the board.
|
|
Controls if updates are necessary
|
|
Stores all Intersection Objects which in this moment are not real and
so hide this element.
|
|
Counts the number of objects drawn as part of the trace of the element.
|
|
Ids of elements on which this element depends directly are stored here.
|
|
Quadratic form representation of circles (and conics)
|
|
Stores the SVG (or VML) rendering node for the element.
|
|
Determines whether two-finger manipulation of this object may change its size.
|
|
If true the element will get a shadow.
|
|
Snaps the element or its parents to the grid.
|
|
[c,b0,b1,a,k,r,q0,q1]
See
A.E.
|
|
The stroke color of the given geometry element.
|
|
Opacity for element's stroke color.
|
|
Width of the element's stroke.
|
|
Subs contains the subelements, created during the create method.
|
|
Stores variables for symbolic computations
|
|
If true the element will be traced, i.e.
|
|
Extra visual properties for traces of an element
|
|
Keeps track of all objects drawn as part of the trace of the element.
|
|
Stores the transformations which are applied during update in an array
|
|
Transition duration (in milliseconds) for color and opacity
changes.
|
|
<constant> |
Type of the element.
|
If false the element won't be visible on the board, otherwise it is shown.
|
|
An associative array containing all visual properties.
|
|
An associative array containing visual properties which are calculated from
the attribute values (i.e.
|
|
If true a label will display the element's name.
|
Method Attributes | Method Name and Description |
---|---|
<private> |
_set(property, value)
Sets the value of property property to value.
|
addChild(obj)
Add an element as a child to the current element.
|
|
<private> |
addDescendants(obj)
Adds the given object to the descendants list of this object and all its child objects.
|
<static> |
JXG.GeometryElement.addEvent()
Alias of JXG.EventEmitter.on.
|
addParents(parents)
Adds ids of elements to the array this.parents.
|
|
addRotation(angle)
Rotate texts or images by a given degree.
|
|
addTransform(transform)
Add transformations to this element.
|
|
animate(hash, time, options)
Animates properties for that object like stroke or fill color, opacity and maybe
even more later.
|
|
bounds()
Dimensions of the smallest rectangle enclosing the element.
|
|
Removes all objects generated by the trace function.
|
|
Copy the element to background.
|
|
<private> |
Counts the direct children of an object without counting labels.
|
<private> |
Creates a gradient nodes in the renderer.
|
Creates a label element for this geometry element.
|
|
<private> |
Decides whether an element can be dragged.
|
<private> |
fullUpdate(visible)
Run through the full update chain of an element.
|
Array of strings containing the polynomials defining the element.
|
|
getAttribute(key)
Get the value of the property key.
|
|
Retrieve a copy of the current visProp.
|
|
Returns the coords object where the label of the element shall be drawn.
|
|
getName()
Returns the elements name, Used in JessieCode.
|
|
List of the element ids resp.
|
|
<deprecated> |
Deprecated alias for JXG.GeometryElement#getAttribute.
|
Returns the coords object where a text that is bound to the element shall be drawn.
|
|
getType()
The type of the element as used in JXG.Board#create.
|
|
handleSnapToGrid(force, fromParent)
Move an element to its nearest grid point.
|
|
hasPoint(x, y)
Checks whether (x,y) is near the element.
|
|
<private> |
Hide the element.
|
<deprecated> |
labelColor(lColor)
Set the labelColor of an element
|
Uses the "normal" properties of the element.
|
|
<private> |
Normalize the element's standard form.
|
<private> |
Notify all child elements for updates.
|
remove()
Removes the element from the construction.
|
|
removeChild(obj)
Remove an element as a child from the current element.
|
|
<private> |
removeDescendants(obj)
Removes the given object from the descendants list of this object and all its child objects.
|
<static> |
JXG.GeometryElement.removeEvent()
Alias of JXG.EventEmitter.off.
|
resolveShortcuts(properties)
Resolves property shortcuts like color and expands them, e.g.
|
|
setArrow(firstArrow, lastArrow)
Determines whether the element has arrows at start or end of the arc.
|
|
setAttribute(attributes)
Sets an arbitrary number of attributes.
|
|
<private> |
setDash(dash)
Set the dash style of an object.
|
<private> |
setDisplayRendNode(val)
Show the element or hide it.
|
setLabel(str)
Sets a label and it's text
If label doesn't exist, it creates one
|
|
setLabelText(str)
Updates the element's label text, strips all html.
|
|
setName(str)
Updates the element's label text and the element's attribute "name", strips all html.
|
|
setParents(parents)
Sets ids of elements to the array this.parents.
|
|
setPosition(method, coords)
Translates the object by (x, y).
|
|
setPositionDirectly(method, coords, oldcoords)
Moves an by the difference of two coordinates.
|
|
<deprecated> |
Deprecated alias for JXG.GeometryElement#setAttribute.
|
<private> |
Make the element visible.
|
Snaps the element to points.
|
|
update()
General update method.
|
|
<private> |
Provide updateRenderer method.
|
<private> |
updateVisibility(parent_val)
Set the visibility of an element.
|
Event Attributes | Event Name and Description |
---|---|
attribute(o, el)
Notify every time an attribute is changed.
|
|
attribute:<attribute><attribute>(val, nval, el)
This is a generic event handler.
|
|
down(e)
Whenever the user starts to touch or click an element.
|
|
drag(e)
This event is fired whenever the user drags an element.
|
|
mousedown(e)
Whenever the user starts to click an element.
|
|
mousedrag(e)
This event is fired whenever the user drags the element with a mouse.
|
|
mousemove(e)
This event is fired whenever the user is moving the mouse over an element.
|
|
mouseout(e)
This event is fired whenever the user puts the mouse away from an element.
|
|
mouseover(e)
This event is fired whenever the user puts the mouse over an element.
|
|
mouseup(e)
Whenever the user releases the mousebutton over an element.
|
|
move(e)
This event is fired whenever the user is moving over an element.
|
|
out(e)
This event is fired whenever the user is leaving an element.
|
|
over(e)
This event is fired whenever the user is hovering over an element.
|
|
touchdown(e)
Whenever the user starts to touch an element.
|
|
touchdrag(e)
This event is fired whenever the user drags the element on a touch device.
|
|
touchup(e)
Whenever the user stops touching an element.
|
|
up(e)
Whenever the user stops to touch or click an element.
|
Class Detail
JXG.GeometryElement(board, attributes, type, oclass)
Constructs a new GeometryElement object.
- Parameters:
- {JXG.Board} board
- Reference to the board the element is constructed on.
- {Object} attributes
- Hash of attributes and their values.
- {Number} type
- Element type (a JXG.OBJECT_TYPE_ value).
- {Number} oclass
- The element's class (a JXG.OBJECT_CLASS_ value).
Field Detail
<private> <constant>
{number}
_org_type
Original type of the element at construction time. Used for removing glider property.
<private>
_pos
The position of this element inside the JXG.Board#objectsList.
- Default Value:
- -1
{Object}
ancestors
Elements on which this element depends on are stored here.
<private>
{JXG.GeometryElement}
baseElement
- Default Value:
- null
{JXG.Board}
board
Reference to the board associated with the element.
{Object}
childElements
Stores all dependent objects to be updated when this point is moved.
{Number}
dash
Determines the elements border-style.
Possible values are:
Defined in: options.js.
- 0 for a solid line
- 1 for a dotted line
- 2 for a line with small dashes
- 3 for a line with medium dashes
- 4 for a line with big dashes
- 5 for a line with alternating medium and big dashes and large gaps
- 6 for a line with alternating medium and big dashes and small gaps
Defined in: options.js.
- Default Value:
- 0
{Object}
descendants
Elements depending on this element are stored here.
{boolean}
draft
If true the element will be drawn in grey scale colors to visualize that it's only a draft.
Defined in: options.js.
Defined in: options.js.
{Boolean}
dump
The element is saved with an explicit entry in the file (true) or implicitly
via a composition.
- Default Value:
- true
<constant>
{number}
elementClass
The element's class.
{String}
elType
The string used with JXG.Board#create
{String}
fillColor
The fill color of this geometry element.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#highlightFillColor
- JXG.GeometryElement#fillOpacity
- JXG.GeometryElement#highlightFillOpacity
{number}
fillOpacity
Opacity for fill color.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#fillColor
- JXG.GeometryElement#highlightFillColor
- JXG.GeometryElement#highlightFillOpacity
{Boolean}
fixed
If true the element is fixed and can not be dragged around. The element
will be repositioned on zoom and moveOrigin events.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- false
{Boolean}
frozen
If true the element is fixed and can not be dragged around. The element
will even stay at its position on zoom and moveOrigin events.
Only free elements like points, texts, curves can be frozen.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- false
{Boolean}
hasLabel
If element has a label subelement then this property will be set to true.
- Default Value:
- false
{Boolean}
highlight
Defined in: options.js.
- Default Value:
- true
{Boolean}
highlighted
True, if the element is currently highlighted.
- Default Value:
- false
{String}
highlightFillColor
The fill color of the given geometry element when the mouse is pointed over it.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#fillColor
- JXG.GeometryElement#fillOpacity
- JXG.GeometryElement#highlightFillOpacity
{number}
highlightFillOpacity
Opacity for fill color when the object is highlighted.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#fillColor
- JXG.GeometryElement#highlightFillColor
- JXG.GeometryElement#fillOpacity
{String}
highlightStrokeColor
The stroke color of the given geometry element when the user moves the mouse over it.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#strokeColor
- JXG.GeometryElement#strokeWidth
- JXG.GeometryElement#strokeOpacity
- JXG.GeometryElement#highlightStrokeOpacity
{number}
highlightStrokeOpacity
Opacity for stroke color when the object is highlighted.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#strokeColor
- JXG.GeometryElement#highlightStrokeColor
- JXG.GeometryElement#strokeWidth
- JXG.GeometryElement#strokeOpacity
{number}
highlightStrokeWidth
Width of the element's stroke when the mouse is pointed over it.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#strokeColor
- JXG.GeometryElement#highlightStrokeColor
- JXG.GeometryElement#strokeOpacity
- JXG.GeometryElement#highlightStrokeOpacity
- JXG.GeometryElement#highlightFillColor
{String}
id
Unique identifier for the element. Equivalent to id-attribute of renderer element.
{Object}
inherits
Inherits contains the subelements, which may have an attribute
(in partuclar the attribute "visible") having value 'inherit'.
{Boolean}
isDraggable
Controls if this element can be dragged. In GEONExT only
free points and gliders can be dragged.
- Default Value:
- false
{Boolean}
isReal
If element is in two dimensional real space this is true, else false.
- Default Value:
- true
{Date}
lastDragTime
Time stamp containing the last time this element has been dragged.
- Default Value:
- creation time
{Object}
methodMap
The methodMap determines which methods can be called from within JessieCode and under which name it
can be used. The map is saved in an object, the name of a property is the name of the method used in JessieCode,
the value of a property is the name of the method in JavaScript.
{Boolean}
mouseover
Is the mouse over this element?
- Default Value:
- false
{String}
name
Not necessarily unique name for the element.
- Default Value:
- Name generated by JXG.Board#generateName.
{Boolean}
needsRegularUpdate
If this is set to true, the element is updated in every update
call of the board. If set to false, the element is updated only after
zoom events or more generally, when the bounding box has been changed.
Examples for the latter behaviour should be axes.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- true
{Boolean}
needsUpdate
Controls if updates are necessary
- Default Value:
- true
{Object}
notExistingParents
Stores all Intersection Objects which in this moment are not real and
so hide this element.
{Number}
numTraces
Counts the number of objects drawn as part of the trace of the element.
{Object}
parents
Ids of elements on which this element depends directly are stored here.
{Array}
quadraticform
Quadratic form representation of circles (and conics)
- Default Value:
- [[1,0,0],[0,1,0],[0,0,1]]
{Object}
rendNode
Stores the SVG (or VML) rendering node for the element. This enables low-level
access to SVG nodes. The properties of such an SVG node can then be changed
by calling setAttribute(). Note that there are a few elements which consist
of more than one SVG nodes:
- Elements with arrow tail or head: rendNodeTriangleStart, rendNodeTriangleEnd
- SVG (or VML) texts: rendNodeText
- Button: rendNodeForm, rendNodeButton, rendNodeTag
- Checkbox: rendNodeForm, rendNodeCheckbox, rendNodeLabel, rendNodeTag
- Input: rendNodeForm, rendNodeInput, rendNodeLabel, rendNodeTag
var p1 = board.create('point', [0, 0]); console.log(p1.rendNode); // returns the full SVG node details of the point p1, something like: // <ellipse id='box_jxgBoard1P6' stroke='#ff0000' stroke-opacity='1' stroke-width='2px' // fill='#ff0000' fill-opacity='1' cx='250' cy='250' rx='4' ry='4' // style='position: absolute;'> // </ellipse>
var s = board.create('segment', [p1, p2], {strokeWidth: 60}); s.rendNode.setAttribute('stroke-linecap', 'round');
{Boolean}
scalable
Determines whether two-finger manipulation of this object may change its size.
If set to false, the object is only rotated and translated.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- true
{boolean}
shadow
If true the element will get a shadow.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- false
{Boolean}
snapToGrid
Snaps the element or its parents to the grid. Currently only relevant for points, circles,
and lines. Points are snapped to grid directly, on circles and lines it's only the parent
points that are snapped
Defined in: options.js.
Defined in: options.js.
- Default Value:
- false
{Array}
stdform
[c,b0,b1,a,k,r,q0,q1]
See
A.E. Middleditch, T.W. Stacey, and S.B. Tor:
"Intersection Algorithms for Lines and Circles",
ACM Transactions on Graphics, Vol. 8, 1, 1989, pp 25-40.
The meaning of the parameters is:
Circle: points p=[p0,p1] on the circle fulfill
a<p,p> + <b,p> + c = 0
For convenience we also store
r: radius
k: discriminant = sqrt(<b,b>-4ac)
q=[q0,q1] center
Points have radius = 0.
Lines have radius = infinity.
b: normalized vector, representing the direction of the line.
Should be put into Coords, when all elements possess Coords.
- Default Value:
- [1, 0, 0, 0, 1, 1, 0, 0]
{String}
strokeColor
The stroke color of the given geometry element.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#highlightStrokeColor
- JXG.GeometryElement#strokeWidth
- JXG.GeometryElement#strokeOpacity
- JXG.GeometryElement#highlightStrokeOpacity
{number}
strokeOpacity
Opacity for element's stroke color.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#strokeColor
- JXG.GeometryElement#highlightStrokeColor
- JXG.GeometryElement#strokeWidth
- JXG.GeometryElement#highlightStrokeOpacity
{number}
strokeWidth
Width of the element's stroke.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#strokeColor
- JXG.GeometryElement#highlightStrokeColor
- JXG.GeometryElement#strokeOpacity
- JXG.GeometryElement#highlightStrokeOpacity
{Object}
subs
Subs contains the subelements, created during the create method.
{Object}
symbolic
Stores variables for symbolic computations
{Boolean}
trace
If true the element will be traced, i.e. on every movement the element will be copied
to the background. Use JXG.GeometryElement#clearTrace to delete the trace elements.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- false
{Object}
traceAttributes
Extra visual properties for traces of an element
Defined in: options.js.
Defined in: options.js.
{Object}
traces
Keeps track of all objects drawn as part of the trace of the element.
{Array}
transformations
Stores the transformations which are applied during update in an array
- See:
- JXG.Transformation
{Number}
transitionDuration
Transition duration (in milliseconds) for color and opacity
changes. Works in SVG renderer, only.
Defined in: options.js.
Defined in: options.js.
- See:
- JXG.GeometryElement#strokeColor
- JXG.GeometryElement#highlightStrokeColor
- JXG.GeometryElement#strokeOpacity
- JXG.GeometryElement#highlightStrokeOpacity
- JXG.GeometryElement#fillColor
- JXG.GeometryElement#highlightFillColor
- JXG.GeometryElement#fillOpacity
- JXG.GeometryElement#highlightFillOpacity
<constant>
{number}
type
Type of the element.
{boolean}
visible
If false the element won't be visible on the board, otherwise it is shown.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- true
{Object}
visProp
An associative array containing all visual properties.
- Default Value:
- empty object
{Object}
visPropCalc
An associative array containing visual properties which are calculated from
the attribute values (i.e. visProp) and from other constraints.
An example: if an intersection point does not have real coordinates,
visPropCalc.visible is set to false.
Additionally, the user can control visibility with the attribute "visible",
even by supplying a functions as value.
- Default Value:
- empty object
{Boolean}
withLabel
If true a label will display the element's name.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- false
Method Detail
<private>
_set(property, value)
Sets the value of property property to value.
- Parameters:
- {String} property
- The property's name.
- value
- The new value
addChild(obj)
Add an element as a child to the current element. Can be used to model dependencies between geometry elements.
- Parameters:
- {JXG.GeometryElement} obj
- The dependent object.
<private>
addDescendants(obj)
Adds the given object to the descendants list of this object and all its child objects.
- Parameters:
- {JXG.GeometryElement} obj
- The element that is to be added to the descendants list.
- Returns:
<static>
JXG.GeometryElement.addEvent()
Alias of JXG.EventEmitter.on.
{JXG.Object}
addParents(parents)
Adds ids of elements to the array this.parents. This method needs to be called if some dependencies
can not be detected automatically by JSXGraph. For example if a function graph is given by a function
which referes to coordinates of a point, calling addParents() is necessary.
- Parameters:
- {Array} parents
- Array of elements or ids of elements. Alternatively, one can give a list of objects as parameters.
- Returns:
- {JXG.Object} reference to the object itself.
- Examples:
// Movable function graph var A = board.create('point', [1, 0], {name:'A'}), B = board.create('point', [3, 1], {name:'B'}), f = board.create('functiongraph', function(x) { var ax = A.X(), ay = A.Y(), bx = B.X(), by = B.Y(), a = (by - ay) / ( (bx - ax) * (bx - ax) ); return a * (x - ax) * (x - ax) + ay; }, {fixed: false}); f.addParents([A, B]);
addRotation(angle)
Rotate texts or images by a given degree. Works only for texts where JXG.Text#display equal to "internal".
- Parameters:
- {number} angle
- The degree of the rotation (90 means vertical text).
- See:
- JXG.GeometryElement#rotate
{JXG.GeometryElement}
addTransform(transform)
Add transformations to this element.
- Parameters:
- {JXG.Transformation|Array} transform
- Either one JXG.Transformation or an array of JXG.Transformations.
- Returns:
- {JXG.GeometryElement} Reference to the element.
{JXG.GeometryElement}
animate(hash, time, options)
Animates properties for that object like stroke or fill color, opacity and maybe
even more later.
- Parameters:
- {Object} hash
- Object containing properties with target values for the animation.
- {number} time
- Number of milliseconds to complete the animation.
- {Object} options Optional
- Optional settings for the animation:
- callback: A function that is called as soon as the animation is finished.
- Returns:
- {JXG.GeometryElement} A reference to the object
{Array}
bounds()
Dimensions of the smallest rectangle enclosing the element.
- Returns:
- {Array} The coordinates of the enclosing rectangle in a format like the bounding box in JXG.Board#setBoundingBox.
clearTrace()
Removes all objects generated by the trace function.
{JXG.GeometryElement}
cloneToBackground()
Copy the element to background. This is used for tracing elements.
- Returns:
- {JXG.GeometryElement} A reference to the element
<private>
{number}
countChildren()
Counts the direct children of an object without counting labels.
- Returns:
- {number} Number of children
<private>
createGradient()
Creates a gradient nodes in the renderer.
- See:
- JXG.SVGRenderer#setGradient
createLabel()
Creates a label element for this geometry element.
- See:
- #addLabelToElement
<private>
{boolean}
draggable()
Decides whether an element can be dragged. This is used in
JXG.GeometryElement#setPositionDirectly methods
where all parent elements are checked if they may be dragged, too.
- Returns:
- {boolean}
<private>
{JXG.GeometryElement}
fullUpdate(visible)
Run through the full update chain of an element.
- Parameters:
- {Boolean} visible
- Set visibility in case the elements attribute value is 'inherit'. null is allowed.
- Returns:
- {JXG.GeometryElement} Reference to the element
{Array}
generatePolynomial()
Array of strings containing the polynomials defining the element.
Used for determining geometric loci the groebner way.
- Returns:
- {Array} An array containing polynomials describing the locus of the current object.
getAttribute(key)
Get the value of the property key.
- Parameters:
- {String} key
- The name of the property you are looking for
- Returns:
- The value of the property
{Object}
getAttributes()
Retrieve a copy of the current visProp.
- Returns:
- {Object}
{JXG.Coords}
getLabelAnchor()
Returns the coords object where the label of the element shall be drawn.
Differs in some cases from the values that getTextAnchor returns.
- Returns:
- {JXG.Coords} JXG.Coords Place where the text shall be drawn.
{String}
getName()
Returns the elements name, Used in JessieCode.
- Returns:
- {String}
{Array}
getParents()
List of the element ids resp. values used as parents in JXG.Board#create.
- Returns:
- {Array}
getProperty()
Deprecated alias for JXG.GeometryElement#getAttribute.
- Deprecated:
- Use JXG.GeometryElement#getAttribute.
{JXG.Coords}
getTextAnchor()
Returns the coords object where a text that is bound to the element shall be drawn.
Differs in some cases from the values that getLabelAnchor returns.
- Returns:
- {JXG.Coords} JXG.Coords Place where the text shall be drawn.
{String}
getType()
The type of the element as used in JXG.Board#create.
- Returns:
- {String}
{JXG.GeometryElement}
handleSnapToGrid(force, fromParent)
Move an element to its nearest grid point.
The function uses the coords object of the element as
its actual position. If there is no coords object, nothing is done.
- Parameters:
- {Boolean} force
- force snapping independent from what the snaptogrid attribute says
- {Boolean} fromParent
- True if the drag comes from a child element. This is the case if a line through two points is dragged. In this case we do not try to force the points to stay inside of the visible board, but the distance between the two points stays constant.
- Returns:
- {JXG.GeometryElement} Reference to this element
{Boolean}
hasPoint(x, y)
Checks whether (x,y) is near the element.
- Parameters:
- {Number} x
- Coordinate in x direction, screen coordinates.
- {Number} y
- Coordinate in y direction, screen coordinates.
- Returns:
- {Boolean} True if (x,y) is near the element, False otherwise.
<private>
{JXG.GeometryElement}
hideElement()
Hide the element. It will still exist but not visible on the board.
- Returns:
- {JXG.GeometryElement} Reference to the element
labelColor(lColor)
Set the labelColor of an element
- Parameters:
- {String} lColor
- String which determines the text color of an object's label.
- Deprecated:
- Use JXG.GeometryElement#setAttribute
{JXG.Board}
noHighlight()
Uses the "normal" properties of the element.
- Returns:
- {JXG.Board}
<private>
normalize()
Normalize the element's standard form.
<private>
prepareUpdate()
Notify all child elements for updates.
remove()
Removes the element from the construction. This only removes the SVG or VML node of the element and its label (if available) from
the renderer, to remove the element completely you should use JXG.Board#removeObject.
removeChild(obj)
Remove an element as a child from the current element.
- Parameters:
- {JXG.GeometryElement} obj
- The dependent object.
<private>
removeDescendants(obj)
Removes the given object from the descendants list of this object and all its child objects.
- Parameters:
- {JXG.GeometryElement} obj
- The element that is to be removed from the descendants list.
- Returns:
<static>
JXG.GeometryElement.removeEvent()
Alias of JXG.EventEmitter.off.
{Object}
resolveShortcuts(properties)
Resolves property shortcuts like color and expands them, e.g. strokeColor and fillColor.
Writes the expanded properties back to the given properties.
- Parameters:
- {Object} properties
- Returns:
- {Object} The given parameter with shortcuts expanded.
setArrow(firstArrow, lastArrow)
Determines whether the element has arrows at start or end of the arc.
If it is set to be a "typical" vector, ie lastArrow == true,
then the element.type is set to VECTOR.
- Parameters:
- {Boolean} firstArrow
- True if there is an arrow at the start of the arc, false otherwise.
- {Boolean} lastArrow
- True if there is an arrow at the end of the arc, false otherwise.
setAttribute(attributes)
Sets an arbitrary number of attributes.
- Parameters:
- {Object} attributes
- An object with attributes.
- Examples:
// Set property directly on creation of an element using the attributes object parameter var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 5, 5, 1]}; var p = board.create('point', [2, 2], {visible: false}); // Now make this point visible and fixed: p.setAttribute({ fixed: true, visible: true });
<private>
setDash(dash)
Set the dash style of an object. See JXG.GeometryElement#dash
for a list of available dash styles.
You should use JXG.GeometryElement#setAttribute instead of this method.
- Parameters:
- {number} dash
- Indicates the new dash style
<private>
{JXG.GeometryElement}
setDisplayRendNode(val)
Show the element or hide it. If hidden, it will still exist but not be
visible on the board.
- Parameters:
- {Boolean} val
- true: show the element, false: hide the element
- Returns:
- {JXG.GeometryElement} Reference to the element
setLabel(str)
Sets a label and it's text
If label doesn't exist, it creates one
- Parameters:
- {String} str
setLabelText(str)
Updates the element's label text, strips all html.
- Parameters:
- {String} str
setName(str)
Updates the element's label text and the element's attribute "name", strips all html.
- Parameters:
- {String} str
{JXG.Object}
setParents(parents)
Sets ids of elements to the array this.parents.
First, this.parents is cleared. See JXG.GeometryElement#addParents.
- Parameters:
- {Array} parents
- Array of elements or ids of elements. Alternatively, one can give a list of objects as parameters.
- Returns:
- {JXG.Object} reference to the object itself.
{JXG.GeometryElement}
setPosition(method, coords)
Translates the object by (x, y). In case the element is defined by points, the defining points are
translated, e.g. a circle constructed by a center point and a point on the circle line.
- Parameters:
- {Number} method
- The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
- {Array} coords
- array of translation vector.
- Returns:
- {JXG.GeometryElement} Reference to the element object.
{JXG.GeometryElement}
setPositionDirectly(method, coords, oldcoords)
Moves an by the difference of two coordinates.
- Parameters:
- {Number} method
- The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
- {Array} coords
- coordinates in screen/user units
- {Array} oldcoords
- previous coordinates in screen/user units
- Returns:
- {JXG.GeometryElement} this element
setProperty()
Deprecated alias for JXG.GeometryElement#setAttribute.
- Deprecated:
- Use JXG.GeometryElement#setAttribute.
<private>
{JXG.GeometryElement}
showElement()
Make the element visible.
- Returns:
- {JXG.GeometryElement} Reference to the element
{JXG.GeometryElement}
snapToPoints()
Snaps the element to points. Only works for points. Points will snap to the next point
as defined in their properties JXG.Point#attractorDistance and JXG.Point#attractorUnit.
Lines and circles
will snap their parent points to points.
- Returns:
- {JXG.GeometryElement} Reference to the element.
{JXG.GeometryElement}
update()
General update method. Should be overwritten by the element itself.
Can be used sometimes to commit changes to the object.
- Returns:
- {JXG.GeometryElement} Reference to the element
<private>
{JXG.GeometryElement}
updateRenderer()
Provide updateRenderer method.
- Returns:
- {JXG.GeometryElement} Reference to the element
<private>
{JXG.GeometryElement}
updateVisibility(parent_val)
Set the visibility of an element. The visibility is influenced by
(listed in ascending priority):
- The value of the element's attribute 'visible'
- The visibility of a parent element. (Example: label) This overrules the value of the element's attribute value only if this attribute value of the element is 'inherit'.
- being inside of the canvas
This method is called three times for most elements:
- between JXG.GeometryElement#update and JXG.GeometryElement#updateRenderer. In case the value is 'inherit', nothing is done.
- Recursively, called by itself for child elements. Here, 'inherit' is overruled by the parent's value.
- In JXG.GeometryElement#updateRenderer, if the element is outside of the canvas.
- Parameters:
- {Boolean} parent_val
- Visibility of the parent element.
- Returns:
- {JXG.GeometryElement} Reference to the element.
Event Detail
attribute(o, el)
Notify every time an attribute is changed.
- Parameters:
- {Object} o
- A list of changed attributes and their new value.
- {Object} el
- Reference to the element
attribute:<attribute>(val, nval, el)
This is a generic event handler. It exists for every possible attribute that can be set for
any element, e.g. if you want to be notified everytime an element's strokecolor is changed, is the event
attribute:strokecolor.
- Parameters:
- val
- The old value.
- nval
- The new value
- {Object} el
- Reference to the element
down(e)
Whenever the user starts to touch or click an element.
- Parameters:
- {Event} e
- The browser's event object.
drag(e)
This event is fired whenever the user drags an element.
- Parameters:
- {Event} e
- The browser's event object.
mousedown(e)
Whenever the user starts to click an element.
- Parameters:
- {Event} e
- The browser's event object.
mousedrag(e)
This event is fired whenever the user drags the element with a mouse.
- Parameters:
- {Event} e
- The browser's event object.
mousemove(e)
This event is fired whenever the user is moving the mouse over an element.
- Parameters:
- {Event} e
- The browser's event object.
mouseout(e)
This event is fired whenever the user puts the mouse away from an element.
- Parameters:
- {Event} e
- The browser's event object.
mouseover(e)
This event is fired whenever the user puts the mouse over an element.
- Parameters:
- {Event} e
- The browser's event object.
mouseup(e)
Whenever the user releases the mousebutton over an element.
- Parameters:
- {Event} e
- The browser's event object.
move(e)
This event is fired whenever the user is moving over an element.
- Parameters:
- {Event} e
- The browser's event object.
out(e)
This event is fired whenever the user is leaving an element.
- Parameters:
- {Event} e
- The browser's event object.
over(e)
This event is fired whenever the user is hovering over an element.
- Parameters:
- {Event} e
- The browser's event object.
touchdown(e)
Whenever the user starts to touch an element.
- Parameters:
- {Event} e
- The browser's event object.
touchdrag(e)
This event is fired whenever the user drags the element on a touch device.
- Parameters:
- {Event} e
- The browser's event object.
touchup(e)
Whenever the user stops touching an element.
- Parameters:
- {Event} e
- The browser's event object.
up(e)
Whenever the user stops to touch or click an element.
- Parameters:
- {Event} e
- The browser's event object.