src/solaris/classes/sun/java2d/xr/GrowableRectArray.java

Print this page




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.java2d.xr;
  27 
  28 /**
  29  * Class to efficiently store rectangles.
  30  *
  31  * @author Clemens Eisserer
  32  */
  33 public class GrowableRectArray extends GrowableIntArray {
  34 
  35     private static final int RECT_SIZE = 4;
  36 
  37     public GrowableRectArray(int initialSize) {
  38         super(RECT_SIZE, initialSize);
  39     }














  40 
  41     public final void setX(int index, int x) {
  42         array[getCellIndex(index)] = x;
  43     }
  44 
  45     public final void setY(int index, int y) {
  46         array[getCellIndex(index) + 1] = y;
  47     }
  48 
  49     public final void setWidth(int index, int width) {
  50         array[getCellIndex(index) + 2] = width;
  51     }
  52 
  53     public final void setHeight(int index, int height) {
  54         array[getCellIndex(index) + 3] = height;
  55     }
  56 
  57     public final int getX(int index) {
  58         return array[getCellIndex(index)];
  59     }


  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.java2d.xr;
  27 
  28 /**
  29  * Class to efficiently store rectangles.
  30  *
  31  * @author Clemens Eisserer
  32  */
  33 public class GrowableRectArray extends GrowableIntArray {
  34 
  35     private static final int RECT_SIZE = 4;
  36 
  37     public GrowableRectArray(int initialSize) {
  38         super(RECT_SIZE, initialSize);
  39     }
  40     
  41     public final void pushRectValues(int x, int y, int width, int height) {
  42         int currSize = size;
  43         size += RECT_SIZE;
  44 
  45         if (size >= array.length) {
  46             growArray();
  47         }
  48         
  49         array[currSize] = x;
  50         array[currSize + 1] = y;
  51         array[currSize + 2] = width;
  52         array[currSize + 3] = height;
  53     }
  54 
  55     public final void setX(int index, int x) {
  56         array[getCellIndex(index)] = x;
  57     }
  58 
  59     public final void setY(int index, int y) {
  60         array[getCellIndex(index) + 1] = y;
  61     }
  62 
  63     public final void setWidth(int index, int width) {
  64         array[getCellIndex(index) + 2] = width;
  65     }
  66 
  67     public final void setHeight(int index, int height) {
  68         array[getCellIndex(index) + 3] = height;
  69     }
  70 
  71     public final int getX(int index) {
  72         return array[getCellIndex(index)];
  73     }