@ -8,19 +8,25 @@ var StraightEdge = require('./edges/StraightEdge').default;
/ * *
* A edge connects two nodes
* @ param { Object } properties Object with options . Must contain
* At least options from and to .
* Available options : from ( number ) ,
* to ( number ) , label ( string , color ( string ) ,
* width ( number ) , style ( string ) ,
* length ( number ) , title ( string )
* @ param { Network } network A Network object , used to find and edge to
* nodes .
* @ param { Object } constants An object with default values for
* example for the color
* @ class Edge
* /
class Edge {
/ * *
*
* @ param { Object } options Object with options . Must contain
* At least options from and to .
* Available options : from ( number ) ,
* to ( number ) , label ( string , color ( string ) ,
* width ( number ) , style ( string ) ,
* length ( number ) , title ( string )
* @ param { Object } body A Network object , used to find and edge to
* nodes .
* @ param { Object } globalOptions An object with default values for
* example for the color
* @ param { Object } defaultOptions
* @ param { Object } edgeOptions
* @ constructor Edge
* /
constructor ( options , body , globalOptions , defaultOptions , edgeOptions ) {
if ( body === undefined ) {
throw "No body provided" ;
@ -103,6 +109,13 @@ class Edge {
return dataChanged ;
}
/ * *
*
* @ param { Object } parentOptions
* @ param { Object } newOptions
* @ param { boolean } [ allowDeletion = false ]
* @ param { Object } [ globalOptions = { } ]
* /
static parseOptions ( parentOptions , newOptions , allowDeletion = false , globalOptions = { } ) {
var fields = [
'arrowStrikethrough' ,
@ -205,6 +218,10 @@ class Edge {
}
}
/ * *
*
* @ param { Object } options
* /
choosify ( options ) {
this . chooser = true ;
@ -221,6 +238,10 @@ class Edge {
}
}
/ * *
*
* @ returns { { toArrow : boolean , toArrowScale : ( allOptions . edges . arrows . to . scaleFactor | { number } | allOptions . edges . arrows . middle . scaleFactor | allOptions . edges . arrows . from . scaleFactor | Array | number ) , toArrowType : * , middleArrow : boolean , middleArrowScale : ( number | allOptions . edges . arrows . middle . scaleFactor | { number } | Array ) , middleArrowType : ( allOptions . edges . arrows . middle . type | { string } | string | * ) , fromArrow : boolean , fromArrowScale : ( allOptions . edges . arrows . to . scaleFactor | { number } | allOptions . edges . arrows . middle . scaleFactor | allOptions . edges . arrows . from . scaleFactor | Array | number ) , fromArrowType : * , arrowStrikethrough : ( * | boolean | allOptions . edges . arrowStrikethrough | { boolean } ) , color : undefined , inheritsColor : ( string | string | string | allOptions . edges . color . inherit | { string , boolean } | Array | * ) , opacity : * , hidden : * , length : * , shadow : * , shadowColor : * , shadowSize : * , shadowX : * , shadowY : * , dashes : ( * | boolean | Array | allOptions . edges . dashes | { boolean , array } ) , width : * } }
* /
getFormattingValues ( ) {
let toArrow = ( this . options . arrows . to === true ) || ( this . options . arrows . to . enabled === true )
let fromArrow = ( this . options . arrows . from === true ) || ( this . options . arrows . from . enabled === true )
@ -417,7 +438,6 @@ class Edge {
}
/ * *
* Retrieve the value of the edge . Can be undefined
* @ return { Number } value
@ -453,6 +473,10 @@ class Edge {
this . updateLabelModule ( ) ;
}
/ * *
*
* @ private
* /
_setInteractionWidths ( ) {
if ( typeof this . options . hoverWidth === 'function' ) {
this . edgeType . hoverWidth = this . options . hoverWidth ( this . options . width ) ;
@ -510,7 +534,12 @@ class Edge {
this . drawLabel ( ctx , viaNode ) ;
}
/ * *
*
* @ param { CanvasRenderingContext2D } ctx
* @ param { Object } arrowData
* @ param { { toArrow : boolean , toArrowScale : ( allOptions . edges . arrows . to . scaleFactor | { number } | allOptions . edges . arrows . middle . scaleFactor | allOptions . edges . arrows . from . scaleFactor | Array | number ) , toArrowType : * , middleArrow : boolean , middleArrowScale : ( number | allOptions . edges . arrows . middle . scaleFactor | { number } | Array ) , middleArrowType : ( allOptions . edges . arrows . middle . type | { string } | string | * ) , fromArrow : boolean , fromArrowScale : ( allOptions . edges . arrows . to . scaleFactor | { number } | allOptions . edges . arrows . middle . scaleFactor | allOptions . edges . arrows . from . scaleFactor | Array | number ) , fromArrowType : * , arrowStrikethrough : ( * | boolean | allOptions . edges . arrowStrikethrough | { boolean } ) , color : undefined , inheritsColor : ( string | string | string | allOptions . edges . color . inherit | { string , boolean } | Array | * ) , opacity : * , hidden : * , length : * , shadow : * , shadowColor : * , shadowSize : * , shadowX : * , shadowY : * , dashes : ( * | boolean | Array | allOptions . edges . dashes | { boolean , array } ) , width : * } } values
* /
drawArrows ( ctx , arrowData , values ) {
if ( values . fromArrow ) {
this . edgeType . drawArrowHead ( ctx , values , this . selected , this . hover , arrowData . from ) ;
@ -523,7 +552,11 @@ class Edge {
}
}
/ * *
*
* @ param { CanvasRenderingContext2D } ctx
* @ param { Node } viaNode
* /
drawLabel ( ctx , viaNode ) {
if ( this . options . label !== undefined ) {
// set style
@ -622,6 +655,7 @@ class Edge {
* @ param { Number } percentage Value between 0 ( line start ) and 1 ( line end )
* @ return { Object } point
* @ private
* @ static
* /
_pointOnCircle ( x , y , radius , percentage ) {
var angle = percentage * 2 * Math . PI ;
@ -631,12 +665,16 @@ class Edge {
}
}
/ * *
* Sets selected state to true
* /
select ( ) {
this . selected = true ;
}
/ * *
* Sets selected state to false
* /
unselect ( ) {
this . selected = false ;
}