Line is a JavaScript object that allows you to adjust a line by manipulating Handles: one for each end of the line. This code is used in the 2D Geometry section of this site
Line is a sub-class of the Shape object.
constructor - new Line(svgNode);
This method creates a new Line object. All initialization is handled by the init() method. All parameters for this method are described below
init() initialized all properties for this object.
svgNode is an SVG line element node that will be managed by this object.
realize() constructs the SVG DOM nodes needed to visualize the handles of this widget. Event listeners are registered as needed to implement this object's functionality.
translate() translates the SVG element and the associated handles by the specified amount.
delta is a Point2D.
refresh() applies the handle positions to the SVG element associated with this object.
registerHandles() adds all handles used by this object to the mouser's handle list.
unregisterHandles() removes all handles used by this object from the mouser's handle list.
selectHandles() set the current select value for all handles used by this object.
showHandles() sets the current visibility value for all handles used by this object.
getIntersectionParams() : IntersectionParams;
This method returns an IntersectionParams object to specify this shape's name and the necessary parameters to find the intersection of this shape with another. The name is used by the Intersection object to determine which intersection routine to call.
p1 is a Point2D that references the first handle on the line.
p2 is a Point2D that references the second handle on the line.
This example allows you to adjust the end-points of the lines within the SVG document. Here is a brief summary of the editing procedures:
Line.js - the line object only...cannot be used in isolation
2D.js.gz - all objects needed to use this object and other 2D geometry objects