1 package prefuse.util.force; 2 3 9 public class ForceItem implements Cloneable { 10 11 14 public ForceItem() { 15 mass = 1.0f; 16 force = new float[] { 0.f, 0.f }; 17 velocity = new float[] { 0.f, 0.f }; 18 location = new float[] { 0.f, 0.f }; 19 plocation = new float[] { 0.f, 0.f }; 20 k = new float[4][2]; 21 l = new float[4][2]; 22 } 23 24 28 public Object clone() { 29 ForceItem item = new ForceItem(); 30 item.mass = this.mass; 31 System.arraycopy(force,0,item.force,0,2); 32 System.arraycopy(velocity,0,item.velocity,0,2); 33 System.arraycopy(location,0,item.location,0,2); 34 System.arraycopy(plocation,0,item.plocation,0,2); 35 for ( int i=0; i<k.length; ++i ) { 36 System.arraycopy(k[i],0,item.k[i],0,2); 37 System.arraycopy(l[i],0,item.l[i],0,2); 38 } 39 return item; 40 } 41 42 43 public float mass; 44 45 public float[] force; 46 47 public float[] velocity; 48 49 public float[] location; 50 51 public float[] plocation; 52 53 public float[][] k; 54 55 public float[][] l; 56 57 63 public static final boolean isValid(ForceItem item) { 64 return 65 !( Float.isNaN(item.location[0]) || Float.isNaN(item.location[1]) || 66 Float.isNaN(item.plocation[0]) || Float.isNaN(item.plocation[1]) || 67 Float.isNaN(item.velocity[0]) || Float.isNaN(item.velocity[1]) || 68 Float.isNaN(item.force[0]) || Float.isNaN(item.force[1]) ); 69 } 70 71 } | Popular Tags |