Package java.awt.image

Examples of java.awt.image.DataBufferShort


                DataBufferInt retDBT = (DataBufferInt)retDB;
                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
            }
            case DataBuffer.TYPE_SHORT: {
                DataBufferShort srcDBT = (DataBufferShort)srcDB;
                DataBufferShort retDBT = (DataBufferShort)retDB;
                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
            }
            case DataBuffer.TYPE_USHORT: {
                DataBufferUShort srcDBT = (DataBufferUShort)srcDB;
                DataBufferUShort retDBT = (DataBufferUShort)retDB;
                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
            }
            }
        }

        return ret;
View Full Code Here


                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
                break;
            }
            case DataBuffer.TYPE_SHORT: {
                DataBufferShort srcDBT = (DataBufferShort)srcDB;
                DataBufferShort retDBT = (DataBufferShort)retDB;
                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
                break;
            }
            case DataBuffer.TYPE_USHORT: {
                DataBufferUShort srcDBT = (DataBufferUShort)srcDB;
                DataBufferUShort retDBT = (DataBufferUShort)retDB;
                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
                break;
            }
            default:
                throw new
                    UnsupportedOperationException("unsupported data type: "
View Full Code Here

  private void testGetData2(TestHarness harness) {
    harness.checkPoint("getData(int)")
   
    short[][] source = new short[][] {{1, 2}, {3, 4}};
    DataBufferShort b = new DataBufferShort(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 DataBufferShort(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 DataBufferShort(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

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

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

    short[] source = new short[] {1, 2};
    DataBufferShort b = new DataBufferShort(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 DataBufferShort(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

  private void testSetElem2(TestHarness harness) {
    harness.checkPoint("setElem(int, int, int)")
 
    short[][] source = new short[][] {{1, 2}, {3, 4}};
    DataBufferShort b = new DataBufferShort(source, 2);
    b.setElem(1, 1, 99);
    harness.check(b.getElem(1, 1) == 99);
    // does the source array get updated?
    harness.check(source[1][1] == 99);

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

   */
  public void test(TestHarness harness)      
  {
    // check that array updates pass through
    short[][] data = new short[][] {{1, 2}};
    DataBufferShort b = new DataBufferShort(data, 2);
    short[][] banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));
    data[0][0] = 3;
    harness.check(banks[0][0] == 3);

    // test where supplied array is bigger than 'size'
    data = new short[][] {{1, 2, 3}};
    b = new DataBufferShort(data, 2);
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));

    // test where offsets are specified
    data = new short[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferShort(data, 2, new int[] {0, 1});
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));

    // check that a single bank buffer returns a valid array
    DataBufferShort b2 = new DataBufferShort(new short[] {1, 2}, 2);
    banks = b2.getBankData();
    harness.check(banks.length == 1);
    harness.check(banks[0][0] == 1);
    harness.check(banks[0][1] == 2);

    // check that a multi bank buffer returns a valid array
    DataBufferShort b3 = new DataBufferShort(new short[][] {{1}, {2}}, 1);
    banks = b3.getBankData();
    harness.check(banks.length == 2);
    harness.check(banks[0][0] == 1);
    harness.check(banks[1][0] == 2);
}
View Full Code Here

  }

  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("DataBufferShort(int)");
    DataBufferShort b1 = new DataBufferShort(1);
    harness.check(b1.getDataType() == DataBuffer.TYPE_SHORT);
    harness.check(b1.getSize() == 1);
    harness.check(b1.getNumBanks() == 1);
    harness.check(b1.getOffset() == 0);
 
    DataBufferShort b2 = new DataBufferShort(0);
    harness.check(b2.getSize() == 0);
    harness.check(b2.getNumBanks() == 1);
    harness.check(b2.getOffset() == 0);
 
    boolean pass = false;
    try
    {
        DataBufferShort b3 = new DataBufferShort(-1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
View Full Code Here

  private void testConstructor2(TestHarness harness
  {
    harness.checkPoint("DataBufferShort(short[][], int)");
    short[][] source = new short[][] {{1, 2}};
    DataBufferShort b = new DataBufferShort(source, 1);
    harness.check(b.getSize() == 1);
    harness.check(b.getNumBanks() == 1);
    harness.check(b.getOffset() == 0);
 
    // does a change to the source array affect the buffer? yes
    short[][] banks = b.getBankData();
    harness.check(banks[0][0] == 1);
    source[0][0] = 3;
    harness.check(banks[0][0] == 3);
 
    // check null source
    boolean pass = false;
    try
    {
        DataBufferShort b1 = new DataBufferShort((short[][]) null, 1);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // check negative size
    DataBufferShort b1 = new DataBufferShort(source, -1);
    harness.check(b1.getSize() == -1);
  }
View Full Code Here

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

    // test where offsets are specified
    source = new short[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferShort(source, 2, new int[] {0, 1});
    harness.check(b.getSize() == 2);
    harness.check(b.getNumBanks() == 2);
    harness.check(b.getOffsets()[1] == 1);
    harness.check(b.getElem(1, 0) == 5);

    boolean pass = false;
    try
    {
      DataBufferShort b1 = new DataBufferShort((short[][]) null, 1, new int[] {0});
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    pass = false;
    try
    {
      DataBufferShort b1 = new DataBufferShort(new short[][]{{1, 2}}, 1, (int[]) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    pass = false;
    try
    {
      DataBufferShort b2 = new DataBufferShort(new short[][]{{1, 2}}, 1, new int[] {0, 0});
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

TOP

Related Classes of java.awt.image.DataBufferShort

Copyright © 2018 www.massapicom. 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.