@@ -1226,6 +1226,7 @@ module.exports = function (graphContainerSelector) {
12261226
12271227 graph . fastUpdate = function ( ) {
12281228 // fast update function for editor calls;
1229+ // -- experimental ;
12291230 quick_refreshGraphData ( ) ;
12301231 updateNodeMap ( ) ;
12311232 force . start ( ) ;
@@ -1234,7 +1235,6 @@ module.exports = function (graphContainerSelector) {
12341235 refreshGraphStyle ( ) ;
12351236 updateHaloStyles ( ) ;
12361237
1237-
12381238 } ;
12391239 function updateNodeMap ( ) {
12401240 nodeMap = [ ] ;
@@ -2525,9 +2525,9 @@ module.exports = function (graphContainerSelector) {
25252525 aNode . label ( identifier ) ;
25262526 }
25272527 }
2528-
2528+ var i ;
25292529 // updates the property domain and range
2530- for ( var i = 0 ; i < unfilteredData . properties . length ; i ++ ) {
2530+ for ( i = 0 ; i < unfilteredData . properties . length ; i ++ ) {
25312531 if ( unfilteredData . properties [ i ] . domain ( ) === element ) {
25322532 // unfilteredData.properties[i].toString();
25332533 unfilteredData . properties [ i ] . domain ( aNode ) ;
@@ -2537,8 +2537,25 @@ module.exports = function (graphContainerSelector) {
25372537 // unfilteredData.properties[i].toString();
25382538 }
25392539 }
2540- unfilteredData . nodes . splice ( unfilteredData . nodes . indexOf ( element ) , 1 ) ;
25412540
2541+ // update for fastUpdate:
2542+ for ( i = 0 ; i < properties . length ; i ++ ) {
2543+ if ( properties [ i ] . domain ( ) === element ) {
2544+ // unfilteredData.properties[i].toString();
2545+ properties [ i ] . domain ( aNode ) ;
2546+ }
2547+ if ( properties [ i ] . range ( ) === element ) {
2548+ properties [ i ] . range ( aNode ) ;
2549+ // unfilteredData.properties[i].toString();
2550+ }
2551+ }
2552+
2553+ var remId = unfilteredData . nodes . indexOf ( element ) ;
2554+ if ( remId !== - 1 )
2555+ unfilteredData . nodes . splice ( remId , 1 ) ;
2556+ remId = classNodes . indexOf ( element ) ;
2557+ if ( remId !== - 1 )
2558+ classNodes . splice ( remId , 1 ) ;
25422559 // very important thing for selection!;
25432560 addNewNodeElement ( aNode ) ;
25442561 // handle focuser!
@@ -2601,10 +2618,16 @@ module.exports = function (graphContainerSelector) {
26012618
26022619 // add this to the data;
26032620 unfilteredData . properties . push ( aProp ) ;
2604- unfilteredData . properties . splice ( unfilteredData . properties . indexOf ( element ) , 1 ) ;
2605- properties . push ( aProp ) ;
2606- properties . splice ( properties . indexOf ( element ) , 1 ) ;
2607-
2621+ if ( properties . indexOf ( aProp ) === - 1 )
2622+ properties . push ( aProp ) ;
2623+ var remId = unfilteredData . properties . indexOf ( element ) ;
2624+ if ( remId !== - 1 )
2625+ unfilteredData . properties . splice ( remId , 1 ) ;
2626+ if ( properties . indexOf ( aProp ) === - 1 )
2627+ properties . push ( aProp ) ;
2628+ remId = properties . indexOf ( element ) ;
2629+ if ( remId !== - 1 )
2630+ properties . splice ( remId , 1 ) ;
26082631 graph . fastUpdate ( ) ;
26092632 aProp . domain ( ) . addProperty ( aProp ) ;
26102633 aProp . range ( ) . addProperty ( aProp ) ;
@@ -2803,7 +2826,10 @@ module.exports = function (graphContainerSelector) {
28032826
28042827
28052828 function addNewNodeElement ( element ) {
2806- classNodes . push ( element ) ;
2829+ unfilteredData . nodes . push ( element ) ;
2830+ if ( classNodes . indexOf ( element ) === - 1 )
2831+ classNodes . push ( element ) ;
2832+
28072833 generateDictionary ( unfilteredData ) ;
28082834 graph . getUpdateDictionary ( ) ;
28092835 graph . fastUpdate ( ) ;
@@ -3118,7 +3144,8 @@ module.exports = function (graphContainerSelector) {
31183144
31193145 // add this to the data;
31203146 unfilteredData . properties . push ( aProp ) ;
3121- properties . push ( aProp ) ;
3147+ if ( properties . indexOf ( aProp ) === - 1 )
3148+ properties . push ( aProp ) ;
31223149 graph . fastUpdate ( ) ;
31233150 aProp . labelObject ( ) . x = pX ;
31243151 aProp . labelObject ( ) . px = pX ;
@@ -3197,6 +3224,8 @@ module.exports = function (graphContainerSelector) {
31973224 aNode . id ( "NodeId" + eN ++ ) ;
31983225 // add this property to the nodes;
31993226 unfilteredData . nodes . push ( aNode ) ;
3227+ if ( classNodes . indexOf ( aNode ) === - 1 )
3228+ classNodes . push ( aNode ) ;
32003229
32013230
32023231 // add also the datatype Property to it
@@ -3216,8 +3245,8 @@ module.exports = function (graphContainerSelector) {
32163245 aProp . iri ( ontoIri + aProp . id ( ) ) ;
32173246 // add this to the data;
32183247 unfilteredData . properties . push ( aProp ) ;
3219- properties . push ( aProp ) ;
3220-
3248+ if ( properties . indexOf ( aProp ) === - 1 )
3249+ properties . push ( aProp ) ;
32213250 graph . fastUpdate ( ) ;
32223251 generateDictionary ( unfilteredData ) ;
32233252 graph . getUpdateDictionary ( ) ;
@@ -3236,17 +3265,28 @@ module.exports = function (graphContainerSelector) {
32363265 } ;
32373266
32383267 graph . removeNodesViaResponse = function ( nodesToRemove , propsToRemove ) {
3239- var i ;
3268+ var i , remId ;
32403269 // splice them;
32413270 for ( i = 0 ; i < propsToRemove . length ; i ++ ) {
3242- unfilteredData . properties . splice ( unfilteredData . properties . indexOf ( propsToRemove [ i ] ) , 1 ) ;
3271+ remId = unfilteredData . properties . indexOf ( propsToRemove [ i ] ) ;
3272+ if ( remId !== - 1 )
3273+ unfilteredData . properties . splice ( remId , 1 ) ;
3274+ remId = properties . indexOf ( propsToRemove [ i ] ) ;
3275+ if ( remId !== - 1 )
3276+ properties . splice ( remId , 1 ) ;
32433277 propsToRemove [ i ] = null ;
32443278 }
32453279 for ( i = 0 ; i < nodesToRemove . length ; i ++ ) {
3246- unfilteredData . nodes . splice ( unfilteredData . nodes . indexOf ( nodesToRemove [ i ] ) , 1 ) ;
3280+ remId = unfilteredData . nodes . indexOf ( nodesToRemove [ i ] ) ;
3281+ if ( remId !== - 1 ) {
3282+ unfilteredData . nodes . splice ( remId , 1 ) ;
3283+ }
3284+ remId = classNodes . indexOf ( nodesToRemove [ i ] ) ;
3285+ if ( remId !== - 1 )
3286+ classNodes . splice ( remId , 1 ) ;
32473287 nodesToRemove [ i ] = null ;
32483288 }
3249- graph . update ( ) ;
3289+ graph . fastUpdate ( ) ;
32503290 generateDictionary ( unfilteredData ) ;
32513291 graph . getUpdateDictionary ( ) ;
32523292 options . focuserModule ( ) . handle ( undefined ) ;
@@ -3259,6 +3299,9 @@ module.exports = function (graphContainerSelector) {
32593299 var propsToRemove = [ ] ;
32603300 var nodesToRemove = [ ] ;
32613301 var datatypes = 0 ;
3302+
3303+ var remId ;
3304+
32623305 nodesToRemove . push ( node ) ;
32633306 for ( var i = 0 ; i < unfilteredData . properties . length ; i ++ ) {
32643307 if ( unfilteredData . properties [ i ] . domain ( ) === node || unfilteredData . properties [ i ] . range ( ) === node ) {
@@ -3294,14 +3337,24 @@ module.exports = function (graphContainerSelector) {
32943337 } else {
32953338 // splice them;
32963339 for ( i = 0 ; i < propsToRemove . length ; i ++ ) {
3297- unfilteredData . properties . splice ( unfilteredData . properties . indexOf ( propsToRemove [ i ] ) , 1 ) ;
3340+ remId = unfilteredData . properties . indexOf ( propsToRemove [ i ] ) ;
3341+ if ( remId !== - 1 )
3342+ unfilteredData . properties . splice ( remId , 1 ) ;
3343+ remId = properties . indexOf ( propsToRemove [ i ] ) ;
3344+ if ( remId !== - 1 )
3345+ properties . splice ( remId , 1 ) ;
32983346 propsToRemove [ i ] = null ;
32993347 }
33003348 for ( i = 0 ; i < nodesToRemove . length ; i ++ ) {
3301- unfilteredData . nodes . splice ( unfilteredData . nodes . indexOf ( nodesToRemove [ i ] ) , 1 ) ;
3349+ remId = unfilteredData . nodes . indexOf ( nodesToRemove [ i ] ) ;
3350+ if ( remId !== - 1 )
3351+ unfilteredData . nodes . splice ( remId , 1 ) ;
3352+ remId = classNodes . indexOf ( nodesToRemove [ i ] ) ;
3353+ if ( remId !== - 1 )
3354+ classNodes . splice ( remId , 1 ) ;
33023355 nodesToRemove [ i ] = null ;
33033356 }
3304- graph . update ( ) ;
3357+ graph . fastUpdate ( ) ;
33053358 generateDictionary ( unfilteredData ) ;
33063359 graph . getUpdateDictionary ( ) ;
33073360 options . focuserModule ( ) . handle ( undefined ) ;
@@ -3313,13 +3366,24 @@ module.exports = function (graphContainerSelector) {
33133366 graph . removePropertyViaEditor = function ( property ) {
33143367 property . domain ( ) . removePropertyElement ( property ) ;
33153368 property . range ( ) . removePropertyElement ( property ) ;
3369+ var remId ;
33163370
33173371 if ( property . type ( ) . toLocaleLowerCase ( ) === "owl:datatypeproperty" ) {
33183372 var datatype = property . range ( ) ;
3319- unfilteredData . nodes . splice ( unfilteredData . nodes . indexOf ( property . range ( ) ) , 1 ) ;
3373+ remId = unfilteredData . nodes . indexOf ( property . range ( ) ) ;
3374+ if ( remId !== - 1 )
3375+ unfilteredData . nodes . splice ( remId , 1 ) ;
3376+ if ( remId !== - 1 )
3377+ remId = classNodes . indexOf ( property . range ( ) ) ;
3378+ classNodes . splice ( remId , 1 ) ;
33203379 datatype = null ;
33213380 }
3322- unfilteredData . properties . splice ( unfilteredData . properties . indexOf ( property ) , 1 ) ;
3381+ remId = unfilteredData . properties . indexOf ( property ) ;
3382+ if ( remId !== - 1 )
3383+ unfilteredData . properties . splice ( remId , 1 ) ;
3384+ remId = properties . indexOf ( property ) ;
3385+ if ( remId !== - 1 )
3386+ properties . splice ( remId , 1 ) ;
33233387 if ( property . inverse ( ) ) {
33243388 // so we have inverse
33253389 property . inverse ( ) . inverse ( 0 ) ;
@@ -3328,7 +3392,7 @@ module.exports = function (graphContainerSelector) {
33283392
33293393
33303394 hoveredPropertyElement = undefined ;
3331- graph . update ( ) ;
3395+ graph . fastUpdate ( ) ;
33323396 generateDictionary ( unfilteredData ) ;
33333397 graph . getUpdateDictionary ( ) ;
33343398 options . focuserModule ( ) . handle ( undefined ) ;
0 commit comments