Project

General

Profile

« Previous | Next » 

Revision fee0865c

Added by Leszek Koltunski almost 8 years ago

Fix for adding a single DistortedObject to a DistortedNode tree multiple times.

View differences:

src/main/java/org/distorted/library/DistortedNode.java
234 234

  
235 235
  private void adjustNodeData(ArrayList<Long> oldList, ArrayList<Long> newList)
236 236
    {
237
    if( mData.numPointingNodes>1 ) mData.numPointingNodes--;
238
    else                           mMapNodeID.remove(oldList);  
237
    boolean otherNodesPoint = (mData.numPointingNodes>1);
238

  
239
    if( otherNodesPoint ) mData.numPointingNodes--;
240
    else                  mMapNodeID.remove(oldList);
239 241
   
240 242
    NodeData newData = mMapNodeID.get(newList);
241 243
    
242 244
    if( newData==null )
243 245
      {
244
      mData.ID = ++mNextNodeID;  
245
      mData.numPointingNodes = 1;
246
     
246
      if( otherNodesPoint )  mData = new NodeData(++mNextNodeID);
247
      else                   mData.ID = ++mNextNodeID;  // numPointingNodes must be 1 already
248

  
247 249
      if( newList.size()>1 && mData.mProjection==null )
248 250
        {     
249 251
        mData.mProjection = new DistortedProjection(true);
......
255 257
      mMapNodeID.put(newList, mData);
256 258
      }
257 259
    else
258
      {  
260
      {
259 261
      newData.numPointingNodes++;
260 262
      mData = newData;
261 263
      }
......
280 282
        }
281 283
      }
282 284
    }
283
  
285

  
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287
// Debug - print all the Node IDs
288

  
289
  void debug(int depth)
290
    {
291
    String tmp="";
292
    int i;
293

  
294
    for(i=0; i<depth; i++) tmp +="   ";
295
    tmp += (""+mData.ID);
296

  
297
    android.util.Log.e("node", tmp);
298

  
299
    for(i=0; i<mNumChildren[0]; i++)
300
      mChildren.get(i).debug(depth+1);
301
    }
302

  
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304
// Debug - print contents of the HashMap
305

  
306
  static void debugMap()
307
    {
308
    NodeData tmp;
309

  
310
    for(ArrayList<Long> key: mMapNodeID.keySet())
311
      {
312
      tmp = mMapNodeID.get(key);
313

  
314
      android.util.Log.e("NODE", "key="+key+" NodeID: "+tmp.ID);
315
      }
316
    }
317

  
284 318
///////////////////////////////////////////////////////////////////////////////////////////////////
285 319
// PUBLIC API
286 320
///////////////////////////////////////////////////////////////////////////////////////////////////
......
392 426
    mNumChildren[0]++;
393 427
   
394 428
    RecomputeNodeID(prev);
395
   
429

  
396 430
    return node;
397 431
    }
398 432
  
......
503 537
    {
504 538
    return mObject;
505 539
    }
506
  
507
///////////////////////////////////////////////////////////////////////////////////////////////////
508
// Debug - print all the Node IDs
509

  
510
  public void debug(int depth)
511
    {
512
    String tmp="";  
513
    int i;
514
   
515
    for(i=0; i<depth; i++) tmp +="   ";
516
    tmp += (""+mData.ID);
517
   
518
    android.util.Log.e("node", tmp);
519
   
520
    for(i=0; i<mNumChildren[0]; i++)
521
      mChildren.get(i).debug(depth+1);
522
    }
523 540

  
524 541
///////////////////////////////////////////////////////////////////////////////////////////////////
525 542
  }

Also available in: Unified diff