@ -1,4 +1,4 @@
/ * *
/ * * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* Location of all the endpoint drawing routines .
*
* Every endpoint has its own drawing routine , which contains an endpoint definition .
@ -9,9 +9,21 @@
* - The endpoints are orientated to the positive x - direction
* - The length of the endpoint is at most 1
*
* As long as the endpoint classes remain simple and not too numerous , they will be contained within this module .
* As long as the endpoint classes remain simple and not too numerous , they will
* be contained within this module .
* All classes here except ` EndPoints ` should be considered as private to this module .
* /
*
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* # # # Further Actions
*
* After adding a new endpoint here , you also need to do the following things :
*
* - Add the new endpoint name to ` network/options.js ` in array ` endPoints ` .
* - Add the new endpoint name to the documentation .
* Scan for ' arrows . to . type ` and add it to the description.
* - Add the endpoint to the examples . At the very least , add it to example
* ` edgeStyles/arrowTypes ` .
* === === === === === === === === === === === === === === === === === === === === === === === === === == * /
// NOTE: When a typedef is isolated in a separate comment block, an actual description is generated for it,
// using the rest of the commenting in the code block. Usage of typedef in other comments then
@ -145,6 +157,45 @@ class Circle {
}
/ * *
* Drawing methods for the bar endpoint .
* /
class Bar {
/ * *
* Draw this shape at the end of a line .
*
* @ param { CanvasRenderingContext2D } ctx
* @ param { ArrowData } arrowData
* @ static
* /
static draw ( ctx , arrowData ) {
/ *
var points = [
{ x : 0 , y : 0.5 } ,
{ x : 0 , y : - 0.5 }
] ;
EndPoint . transform ( points , arrowData ) ;
ctx . beginPath ( ) ;
ctx . moveTo ( points [ 0 ] . x , points [ 0 ] . y ) ;
ctx . lineTo ( points [ 1 ] . x , points [ 1 ] . y ) ;
ctx . stroke ( ) ;
* /
var points = [
{ x : 0 , y : 0.5 } ,
{ x : 0 , y : - 0.5 } ,
{ x : - 0.15 , y : - 0.5 } ,
{ x : - 0.15 , y : 0.5 } ,
] ;
EndPoint . transform ( points , arrowData ) ;
EndPoint . drawPath ( ctx , points ) ;
}
}
/ * *
* Drawing methods for the endpoints .
* /
@ -167,6 +218,9 @@ class EndPoints {
case 'circle' :
Circle . draw ( ctx , arrowData ) ;
break ;
case 'bar' :
Bar . draw ( ctx , arrowData ) ;
break ;
case 'arrow' : // fall-through
default :
Arrow . draw ( ctx , arrowData ) ;