Project

General

Profile

Download (1.67 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / DistortedObjectList.java @ 6a06a912

1
package org.distorted.library;
2

    
3
import java.util.HashMap;
4
/**
5
 * List of all DistortedObjects currently created by the application.
6
 * We need to be able to quickly retrieve an Object by its ID, thus a HashMap.
7
 */
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
final class DistortedObjectList 
11
  {
12
  private static long id =0;  
13
  private static HashMap<Long,DistortedObject> mBitmaps = new HashMap<Long,DistortedObject>();
14
  
15
///////////////////////////////////////////////////////////////////////////////////////////////////
16

    
17
  static synchronized long add(DistortedObject dBmp)
18
    {
19
    long ret = id++;  
20
    mBitmaps.put(ret,dBmp);
21
    return ret;
22
    }
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
  static synchronized void remove(DistortedObject dBmp)
27
    {
28
    mBitmaps.remove(dBmp);
29
    }
30
  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  static DistortedObject get(long id)
34
    {
35
    return mBitmaps.get(id);  
36
    }
37
  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
  
40
  static synchronized void reset()
41
    {
42
    for(long id: mBitmaps.keySet()) 
43
      {
44
      get(id).resetTexture();  
45
      }
46
    }
47

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

    
50
  static synchronized void release()
51
    {
52
    for(long id: mBitmaps.keySet()) 
53
      {
54
      get(id).releasePriv();  
55
      }
56
   
57
    mBitmaps.clear();
58
    id = 0;
59
    }
60
  
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62
  }
(6-6/28)