1 package prefuse.util.force; 2 3 11 public abstract class AbstractForce implements Force { 12 13 protected float[] params; 14 protected float[] minValues; 15 protected float[] maxValues; 16 17 22 public void init(ForceSimulator fsim) { 23 } 25 26 29 public int getParameterCount() { 30 return ( params == null ? 0 : params.length ); 31 } 32 33 36 public float getParameter(int i) { 37 if ( i < 0 || params == null || i >= params.length ) { 38 throw new IndexOutOfBoundsException (); 39 } else { 40 return params[i]; 41 } 42 } 43 44 47 public float getMinValue(int i) { 48 if ( i < 0 || params == null || i >= params.length ) { 49 throw new IndexOutOfBoundsException (); 50 } else { 51 return minValues[i]; 52 } 53 } 54 55 58 public float getMaxValue(int i) { 59 if ( i < 0 || params == null || i >= params.length ) { 60 throw new IndexOutOfBoundsException (); 61 } else { 62 return maxValues[i]; 63 } 64 } 65 66 69 public String getParameterName(int i) { 70 String [] pnames = getParameterNames(); 71 if ( i < 0 || pnames == null || i >= pnames.length ) { 72 throw new IndexOutOfBoundsException (); 73 } else { 74 return pnames[i]; 75 } 76 } 77 78 81 public void setParameter(int i, float val) { 82 if ( i < 0 || params == null || i >= params.length ) { 83 throw new IndexOutOfBoundsException (); 84 } else { 85 params[i] = val; 86 } 87 } 88 89 92 public void setMinValue(int i, float val) { 93 if ( i < 0 || params == null || i >= params.length ) { 94 throw new IndexOutOfBoundsException (); 95 } else { 96 minValues[i] = val; 97 } 98 } 99 100 103 public void setMaxValue(int i, float val) { 104 if ( i < 0 || params == null || i >= params.length ) { 105 throw new IndexOutOfBoundsException (); 106 } else { 107 maxValues[i] = val; 108 } 109 } 110 111 protected abstract String [] getParameterNames(); 112 113 117 public boolean isItemForce() { 118 return false; 119 } 120 121 125 public boolean isSpringForce() { 126 return false; 127 } 128 129 133 public void getForce(ForceItem item) { 134 throw new UnsupportedOperationException ( 135 "This class does not support this operation"); 136 } 137 138 142 public void getForce(Spring spring) { 143 throw new UnsupportedOperationException ( 144 "This class does not support this operation"); 145 } 146 147 } | Popular Tags |