Examples of DataBufferUShort


Examples of java.awt.image.DataBufferUShort

  }

  private void testConstructor5(TestHarness harness)
  {
    harness.checkPoint("DataBufferUShort(short[], int, int)");
    DataBufferUShort b = new DataBufferUShort(new short[] {1, 2}, 2, 0);
    harness.check(b.getSize() == 2);
    harness.check(b.getNumBanks() == 1);
    harness.check(b.getOffset() == 0);

    // this constructor, unlike all the other DataBuffer classes, rejects
    // a null bank
    boolean pass = false;
    try
    {
      DataBufferUShort b1 = new DataBufferUShort((short[]) null, 1, 0);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // does negative size fail? no
    pass = true;
    try
    {
      DataBuffer b1 = new DataBufferUShort(new short[] {1, 2}, -1, 0);
    }
    catch (NegativeArraySizeException e)
    {
      pass = false;
    }
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  }

  private void testConstructor6(TestHarness harness)
  {
    harness.checkPoint("DataBufferUShort(int, int)");
    DataBufferUShort b = new DataBufferUShort(2, 3);
    harness.check(b.getNumBanks() == 3);
    harness.check(b.getSize() == 2);
    harness.check(b.getOffset() == 0);

    // does negative size fail? yes
    boolean pass = false;
    try
    {
      DataBufferUShort b1 = new DataBufferUShort(-1, 1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
    harness.check(pass);

    // does negative banks fail? yes
    pass = false;
    try
    {
      DataBufferUShort b1 = new DataBufferUShort(1, -1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  public void test(TestHarness h)
  {
    DataBuffer buf;
    short[] data = new short[] { -11, -22, -33, -44 };
   
    buf = new DataBufferUShort(new short[][] { data, data }, 2,
                               new int[] { 2, 0 });

    h.check(buf.getElem(0), 0x10000 - 33);    // Check #1.
    h.check(buf.getElem(1), 0x10000 - 44);    // Check #2.
    h.check(buf.getElem(0, 0), 0x10000 - 33); // Check #3.
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  {
    harness.checkPoint("getElem(int)")
     
    // test where supplied array is bigger than 'size'
    short[] source = new short[] {1, 2, 3};
    DataBufferUShort b = new DataBufferUShort(source, 2);
    harness.check(b.getElem(0) == 1);
    harness.check(b.getElem(1) == 2);
    harness.check(b.getElem(2) == 3);
   
    boolean pass = false;
    try
    {
      b.getElem(-1);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      b.getElem(3);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // test where offsets are specified
    source = new short[] {1, 2, 3, 4};
    b = new DataBufferUShort(source, 2, 1);
    harness.check(b.getElem(-1) == 1);
    harness.check(b.getElem(0) == 2);
    harness.check(b.getElem(1) == 3);
    harness.check(b.getElem(2) == 4);

    pass = false;
    try
    {
      b.getElem(3);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try
    {
      b.getElem(-2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  private void testGetElem2(TestHarness harness) {
    harness.checkPoint("getElem(int, int)")
   
    short[][] source = new short[][] {{1, 2}, {3, 4}};
    DataBufferUShort b = new DataBufferUShort(source, 2);
    harness.check(b.getElem(1, 0) == 3);
    harness.check(b.getElem(1, 1) == 4);
   
    // test where supplied array is bigger than 'size'
    source = new short[][] {{1, 2, 3}, {4, 5, 6}};
    b = new DataBufferUShort(source, 2);
    harness.check(b.getElem(1, 2) == 6);
     
    // test where offsets are specified
    source = new short[][] {{1, 2, 3, 4}, {5, 6, 7, 8}};
    b = new DataBufferUShort(source, 2, new int[] {1, 2});
    harness.check(b.getElem(1, -2) == 5);
    harness.check(b.getElem(1, -1) == 6);
    harness.check(b.getElem(1, 0) == 7);
    harness.check(b.getElem(1, 1) == 8);
      
    // does a change to the source affect the DataBuffer? Yes
    source[1][2] = 99;
    harness.check(source[1][2] == 99);
    harness.check(b.getElem(1, 0) == 99);
       
    // test when the bank index is out of bounds
    boolean pass = true;
    try
    {
      b.getElem(-1, 0);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
       
    pass = false;
    try
    {
      b.getElem(2, 0);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // test when the item index is out of bounds
    pass = true;
    try
    {
      b.getElem(0, -2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
       
    pass = false;
    try
    {
      b.getElem(1, 5);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // the array of arrays should reflect the single dimension array
    DataBufferUShort b2 = new DataBufferUShort(new short[] {1, 2, 3}, 3);
    harness.check(b2.getElem(0, 1) == 2);
  }
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  private void testGetData1(TestHarness harness) {
    harness.checkPoint("getData()")

    // check simple case
    short[] source = new short[] {1, 2};
    DataBufferUShort b = new DataBufferUShort(source, 2);
    short[] data = b.getData();
    harness.check(data.length == 2);
    harness.check(data[0] == 1);
    harness.check(data[1] == 2);

    // test where supplied array is bigger than 'size'
    source = new short[] {1, 2, 3};
    b = new DataBufferUShort(source, 2);
    data = b.getData();
    harness.check(data.length == 3);
    harness.check(data[0] == 1);
    harness.check(data[1] == 2);
    harness.check(data[2] == 3);

    // test where offsets are specified
    source = new short[] {1, 2, 3, 4};
    b = new DataBufferUShort(source, 2, 1);
    data = b.getData();
    harness.check(data.length == 4);
    harness.check(data[0] == 1);
    harness.check(data[1] == 2);
    harness.check(data[2] == 3);
    harness.check(data[3] == 4);
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  private void testGetData2(TestHarness harness) {
    harness.checkPoint("getData(int)")
 
    short[][] source = new short[][] {{1, 2}, {3, 4}};
    DataBufferUShort b = new DataBufferUShort(source, 2);
    short[] data = b.getData(1);
    harness.check(data.length == 2);
    harness.check(data[0] == 3);
    harness.check(data[1] == 4);
 
    // test where supplied array is bigger than 'size'
    source = new short[][] {{1, 2, 3}, {4, 5, 6}};
    b = new DataBufferUShort(source, 2);
    data = b.getData(1);
    harness.check(data.length == 3);
    harness.check(data[0] == 4);
    harness.check(data[1] == 5);
    harness.check(data[2] == 6);

    // test where offsets are specified
    source = new short[][] {{1, 2, 3, 4}, {5, 6, 7, 8}};
    b = new DataBufferUShort(source, 2, new int[] {1, 2});
    data = b.getData(1);
    harness.check(data.length == 4);
    harness.check(data[0] == 5);
    harness.check(data[1] == 6);
    harness.check(data[2] == 7);
    harness.check(data[3] == 8);
 
    // does a change to the source affect the DataBuffer? Yes
    source[1][2] = 99;
    harness.check(data[2] == 99);
 
    // check bounds exceptions
    boolean pass = true;
    try
    {
      b.getData(-1);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    pass = false;
    try
    {
      b.getData(2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  implements Testlet
{
  public void test(TestHarness h)
  {
    // Check #1.
    h.check(new DataBufferUShort(5).getDataType(), DataBuffer.TYPE_USHORT);
  }
View Full Code Here

Examples of java.awt.image.DataBufferUShort

    harness.checkPoint("(int, int, Object, DataBuffer(UShort))");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_USHORT, 2, 2, new int[] { 224, 28, 3 }
    );
    short[] s = new short[] { (short) 11, (short) 22, (short) 33, (short) 44 };
    DataBuffer db = new DataBufferUShort(s, 4)
   
    short[] de = (short[]) m1.getDataElements(1, 1, null, db);
    harness.check(de.length, 1);
    harness.check(de[0], (byte) 44);
   
View Full Code Here

Examples of java.awt.image.DataBufferUShort

  private void testSetElem1(TestHarness harness) {
    harness.checkPoint("setElem(int, int)");  

    short[] source = new short[] {1, 2};
    DataBufferUShort b = new DataBufferUShort(source, 2);
    b.setElem(1, 99);
    harness.check(b.getElem(1) == 99);

    // does the source array get updated? Yes
    harness.check(source[1] == 99);

    // test with offsets
    source = new short[] {1, 2, 3, 4, 5};
    b = new DataBufferUShort(source, 4, 1);
    harness.check(b.getElem(1) == 3);
    b.setElem(1, 99);
    harness.check(b.getElem(1) == 99);
    harness.check(source[2] == 99);

    boolean pass = false;
    try
    {
      b.setElem(-2, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try
    {
      b.setElem(4, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.