Exemplo n.º 1
0
 /**
  * Gets a String representation of this transform
  *
  * @return the string
  */
 @Override
 @Threadsafe
 public String toString() {
   while (true) {
     int seq = lock.readLock();
     String s = getClass().getSimpleName() + "{" + position + ", " + rotation + ", " + scale + "}";
     if (lock.readUnlock(seq)) {
       return s;
     }
   }
 }
Exemplo n.º 2
0
 /**
  * Atomically gets the parent of this Transform
  *
  * @return the parent
  */
 @Threadsafe
 public Transform getParent() {
   while (true) {
     int seq = lock.readLock();
     Transform result = null;
     try {
       result = parent.get();
     } finally {
       if (lock.readUnlock(seq)) {
         return result;
       }
     }
   }
 }
Exemplo n.º 3
0
 /**
  * Creates a Transform that is a copy of this transform
  *
  * @return the snapshot
  */
 @Threadsafe
 public Transform copy() {
   Transform t = new Transform();
   while (true) {
     int seq = lock.readLock();
     t.setPosition(position);
     t.setRotation(rotation);
     t.setScale(scale);
     t.setParent(parent.get());
     if (lock.readUnlock(seq)) {
       return t;
     }
   }
 }
Exemplo n.º 4
0
 /**
  * Creates a Transform that is the sum of this transform and the given transform
  *
  * @param t the transform
  * @return the new transform
  */
 @Threadsafe
 public Transform createSum(Transform t) {
   Transform r = new Transform();
   while (true) {
     int seq = lock.readLock();
     r.setPosition(position.add(t.getPosition()));
     r.setRotation(rotation.multiply(t.getRotation()));
     r.setScale(scale.add(t.getScale()));
     r.setParent(parent.get());
     if (lock.readUnlock(seq)) {
       return r;
     }
   }
 }
Exemplo n.º 5
0
 /**
  * Creates a Transform that is a snapshot of the absolute position of this transform
  *
  * @return the snapshot
  */
 @Threadsafe
 public Transform getAbsolutePosition() {
   while (true) {
     int seq = lock.readLock();
     if (parent == null) {
       Transform r = copy();
       if (lock.readUnlock(seq)) {
         return r;
       }
     } else {
       Transform r = createSum(parent.get().getAbsolutePosition());
       if (lock.readUnlock(seq)) {
         return r;
       }
     }
   }
 }
Exemplo n.º 6
0
 /**
  * Optimistically Read locks the Transform
  *
  * @return the sequence number
  */
 public int readLock() {
   return lock.readLock();
 }