Line
A Line is a graphic which is a vector, potentially connecting two other graphics at its head and tail ends.
Getting Lines
Here is a script for creating an array of references to all lines on the current canvas:
Get All Lines on Current Canvas | ||
01 | cnvs = document.windows[0].selection.canvas | |
02 | var lines = new Array() | |
03 | cnvs.graphics.forEach(function(graphic){ | |
04 | if(graphic instanceof Line){lines.push(graphic)} | |
05 | }) |
And here’s a script for creating an array of references to all lines in the document:
Get All Lines in Document | ||
01 | var lines = new Array() | |
02 | canvases.forEach(function(cnvs){ | |
03 | cnvs.graphics.forEach(function(graphic){ | |
04 | if(graphic instanceof Line){lines.push(graphic)} | |
05 | }) | |
06 | }) |
Adding Lines
You can use either of two methods for adding a line to a document:
addLine(startPoint, endPoint) (Line) • Create a new line between two points and place it on the first visible layer.
newLine() (Line) • Create a new zero-length line (presumably to be modified further) and place it on the first visible layer.
Line Class Properties
allLineEndingTypes (Array of Strings) • A list of the available line ending types.
Get All Line Endings | ||
01 | Line.allLineEndingTypes | |
02 | // FilledArrow, Arrow, FilledBall, Ball, FilledDoubleArrow, DoubleArrow, FilledBox, Box, FilledDiamond, Diamond, Fork, StickArrow, HalfStickArrow, DoubleStickArrow, Bar, UMLInheritance, SharpArrow, SharpBackArrow, SharpBackCross, CrowsFeet, CrowBar, CrowBall, BarBall, DoubleBar, NegativeControls, DimensionArrow, EmptyCenterBall, FilledCenterBall, UML2Socket, NonNavigable |
Using addLine() to Create a Line
Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Donec sed odio dui. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Create a Line using addLine() | ||
01 | cnvs = document.windows[0].selection.canvas | |
02 | line = cnvs.addLine(new Point(0,0),new Point(300,200)) | |
03 | line.lineType = LineType.Straight | |
04 | line.strokeThickness = 6 |
Using newLine() to Create a Line
Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Donec sed odio dui. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Create a Line using newLine() | ||
01 | cnvs = document.windows[0].selection.canvas | |
02 | line = cnvs.newLine() | |
03 | line.points = [new Point(0,0),new Point(300,200)] | |
04 | line.lineType = LineType.Straight | |
05 | line.strokeThickness = 6 |
Line Properties
In addition to inheriting the properties of the parent Graphic class, a Line has the following properties specific to its class:
head (Graphic or nil) • Graphic attached to the head of this line.
headMagnet (Number) • Index of the magnet in the head graphic which this line is connected to. Zero if not any particular magnet.
headScale (Number) • Scale of the line ending at the head end of this line.
headType (LineEndingType) • Type of line ending at the head end of this line.
hopType (HopType) • Style and behavior of line hops when this line passes over any other line on this canvas.
lineType (LineType) • Line type of this line. (Straight, Curved or Orthogonal.) LineType.Bezier, LineType.Curved, LineType.Orthogonal, LineType.Straight
points (Array of Points) • Array of control points for this line in canvas coordinates.
tail (Graphic or nil) • Graphic attached to the tail of this line.
tailMagnet (Number) • Index of the magnet in the tail graphic which this line is connected to. Zero if not any particular magnet.
tailScale (Number) • Scale of the line ending at the tail end of this line.
tailType (LineEndingType) • Type of line ending at the tail end of this line.
Line Ending Type
A text string indicating the line ending type: Head/Tail ending types: FilledArrow, Arrow, FilledBall, Ball, FilledDoubleArrow, DoubleArrow, FilledBox, Box, FilledDiamond, Diamond, Fork, StickArrow, HalfStickArrow, DoubleStickArrow, Bar, UMLInheritance, SharpArrow, SharpBackArrow, SharpBackCross, CrowsFeet, CrowBar, CrowBall, BarBall, DoubleBar, NegativeControls, DimensionArrow, EmptyCenterBall, FilledCenterBall, UML2Socket, NonNavigable
FilledArrow (String) • |
Arrow (String) • |
FilledBall (String) • |
Ball (String) • |
FilledDoubleArrow (String) • |
DoubleArrow (String) • |
FilledBox (String) • |
Box (String) • |
FilledDiamond (String) • |
Diamond (String) • |
Fork (String) • |
StickArrow (String) • |
HalfStickArrow (String) • |
DoubleStickArrow (String) • |
Bar (String) • |
UMLInheritance (String) • |
SharpArrow (String) • |
SharpBackArrow (String) • |
SharpBackCross (String) • |
CrowsFeet (String) • |
CrowBar (String) • |
CrowBall (String) • |
BarBall (String) • |
DoubleBar (String) • |
NegativeControls (String) • |
DimensionArrow (String) • |
EmptyCenterBall (String) • |
FilledCenterBall (String) • |
UML2Socket (String) • |
NonNavigable (String) • |
Hop Type
The HopType properties are the value for the hopType property (note the lowercase h) of the Line class:
Line Hop | ||
01 | line = document.windows[0].selection.lines[0] | |
02 | line.hopType = HopType.Ignore |
Bridge (HopType 102) • Bridge over the other line(s).
Gap (HopType 101) • Leave a gap while crossing the other line(s).
Ignore (HopType 100) • No hops, and ignore this line when computing hops for other lines.
None (HopType 0) • Don’t hop at all.
Round (HopType 1) • Rounded over the other line(s).
RoundUnder (HopType 103) • Rounded under the other line(s).
Square (HopType 2) • Square shape over the other line(s).
SquareUnder (HopType 104) • Square shape under the other line(s).
ThreeSide (HopType 4) • Three segments angled over the other line(s).
ThreeSideUnder (HopType 106) • Three segments angled under the other line(s).
TwoSide (HopType 3) • Vee over the other line(s).
TwoSideUnder (HopType 105) • Vee under the other line(s).
Line Type
The LineType properties are the value for the lineType property (note the lowercase l) of the Line class:
Line Type | ||
01 | cnvs = document.windows[0].selection.canvas | |
02 | line = cnvs.addLine(new Point(0,0),new Point(300,200)) | |
03 | line.lineType = LineType.Straight | |
04 | line.strokeThickness = 6 |
Bezier (LineType 3) • Bezier line.
Curved (LineType 1) • Curved line.
Orthogonal (LineType 2) • Orthogonal line.
Straight (LineType 0) • Straight line.
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.