Mouser is a JavaScript object that is used to track the mouse. This code is used in the 2D Geometry section of this site
constructor - new Mouser(parent);
This method creates a new Mouser object. All initialization is handled by the init() method. All parameters for this method are described below
init() initialized all properties for this object.
realize() creates an transparent rectangle which covers the entire SVG image. The rectangle is appended to the top-most svg element.
register() adds a new handle to the current selection. This method selects the handle.
unregister() removes a handle from the current selection. This method unselects the handle. If the handle is not in the selection, then nothing is done.
registerShape() adds a new shape to the current selection.
unregisterShape() removes a shape from the current selection. The shapes handles are deselected, hidden, and unregistered. If the shape is not in the selection, then nothing is done.
unregisterAll() removes all handles from the current selection. All removed handles will be deselected.
unregisterShapes() removes all shapes from the current selection. Each shape's handles are deselected, hidden, and unregistered.
handleIndex(handle) : integer;
handleIndex() is used internally to determine a handle's position within the handle property array. A value of -1 is returned if the handle does not exists in the array.
shapeIndex() is used internally to determine a shape;s position within the shapes property array. A value of -1 is returned if the shape does not exists in the array.
beginDrag() is called to initiate dragging. The mouser rectangle brought to the front of the drawing order and is activate and begins to recieve mousemove events.
mouseup() finalizes a the current drag. The mouser rectangle is deactivate to allow other elements to recieve events.
mousemove() moves all selected handles. All shapes effected by the move are sent update() calls.
getUserCoordinate(node, x, y); // returns an SVGPoint
getUserCoordinate() converts an x,y value to the local coordinate system used by an SVG DOM node.
node is an SVG DOM node that will be used to establish the target coordinate system.
x is a number that represents the x-coordinate in screen coordinates.
y is a number that represents the y-coordinate in screen coordinates.
getTransformToElement(node); // returns an SVGMatrix
getTransformToElement() calculates the cummulative transformation that is being applied to an SVG DOM node.
node is an SVG DOM node. All transformations that are being applied to this node will be calculated
svgNode is reference to the SVG rectangle used by this object to capture events.
handles is an array of all handles in the current selection
shapes is an array of all shapes in the current selection
lastPoint is a Point2D of the last mouse position. This is set by beginDrag and updated by mousemove.
currentNode is an SVG DOM node that initiated the current drag. This node is used to determine how to compensate for the current zoom and pan.