Package java.awt.image

Examples of java.awt.image.DataBufferFloat


  }

  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("DataBufferFloat(int)");
    DataBufferFloat b1 = new DataBufferFloat(1);
    harness.check(b1.getDataType() == DataBuffer.TYPE_FLOAT);
    harness.check(b1.getSize() == 1);
    harness.check(b1.getNumBanks() == 1);
    harness.check(b1.getOffset() == 0);

    DataBufferFloat b2 = new DataBufferFloat(0);
    harness.check(b2.getSize() == 0);
    harness.check(b2.getNumBanks() == 1);
    harness.check(b2.getOffset() == 0);

    boolean pass = false;
    try
    {
      DataBufferFloat b3 = new DataBufferFloat(-1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
View Full Code Here


  private void testConstructor2(TestHarness harness)  
  {
    harness.checkPoint("DataBufferFloat(float[][], int)");
    float[][] source = new float[][] {{1.0f, 2.0f}};
    DataBufferFloat b = new DataBufferFloat(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
    float[][] banks = b.getBankData();
    harness.check(banks[0][0] == 1.0f);
    source[0][0] = 3.0f;
    harness.check(banks[0][0] == 3.0f);

    // check null source
    boolean pass = false;
    try
    {
      DataBufferFloat b1 = new DataBufferFloat((float[][]) null, 1);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // check negative size
    DataBufferFloat b1 = new DataBufferFloat(source, -1);
    harness.check(b1.getSize() == -1);
  }
View Full Code Here

  private void testConstructor3(TestHarness harness
  {
    harness.checkPoint("DataBufferFloat(float[][], int, int[])");
    float[][] source = new float[][] {{1, 2}};
    DataBufferFloat b = new DataBufferFloat(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 float[][] {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f, 7.0f}};
    b = new DataBufferFloat(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);

    // check null source
    boolean pass = false;
    try
    {
      DataBufferFloat b1 = new DataBufferFloat((float[][]) null, 1, new int[] {0});
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // check null offsets
    pass = false;
    try
    {
      DataBufferFloat b1 = new DataBufferFloat(new float[][]{{1.0f, 2.0f}}, 1, (int[]) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // check source doesn't match offsets array
    pass = false;
    try
    {
      DataBufferFloat b2 = new DataBufferFloat(new float[][]{{1.0f, 2.0f}}, 1, new int[] {0, 0});
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

  }

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

    boolean pass = false;
    try
    {
      // this constructor doesn't throw an exception until you
      // try to access the (null) data bank
      DataBufferFloat b1 = new DataBufferFloat((float[]) null, 1);
      int ignore = b1.getElem(0);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
View Full Code Here

  }

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

    boolean pass = false;
    try
    {
      // this constructor doesn't throw an exception until you
      // try to access the (null) data bank
      DataBufferFloat b1 = new DataBufferFloat((float[]) null, 1, 0);
      int ignore = b1.getElem(0);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // does negative size fail? no
    pass = true;
    try
    {
      DataBufferFloat b2 = new DataBufferFloat(new float[] {1, 2}, -1, 0);
    }
    catch (NegativeArraySizeException e)
    {
      pass = false;
    }
View Full Code Here

  }

  private void testConstructor6(TestHarness harness)   
  {
    harness.checkPoint("DataBufferFloat(int, int)");
    DataBufferFloat b = new DataBufferFloat(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
    {
      DataBufferFloat b1 = new DataBufferFloat(-1, 1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
    harness.check(pass);

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

  public void test(TestHarness h)
  {
    DataBuffer buf;
    float[] data = new float[] { 1.1f, -2.2f, 3.3f, -4.4f };
   
    buf = new DataBufferFloat(new float[][] { data, data }, 2,
                              new int[] { 2, 0 });

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

  {
    harness.checkPoint("getElem(int)")
     
    // test where supplied array is bigger than 'size'
    float[] source = new float[] {1, 2, 3};
    DataBufferFloat b = new DataBufferFloat(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 float[] {1, 2, 3, 4};
    b = new DataBufferFloat(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

  private void testGetElem2(TestHarness harness) {
    harness.checkPoint("getElem(int, int)")
   
    float[][] source = new float[][] {{1, 2}, {3, 4}};
    DataBufferFloat b = new DataBufferFloat(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 float[][] {{1, 2, 3}, {4, 5, 6}};
    b = new DataBufferFloat(source, 2);
    harness.check(b.getElem(1, 2) == 6);
     
    // test where offsets are specified
    source = new float[][] {{1, 2, 3, 4}, {5, 6, 7, 8}};
    b = new DataBufferFloat(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
    DataBufferFloat b2 = new DataBufferFloat(new float[] {1, 2, 3}, 3);
    harness.check(b2.getElem(0, 1) == 2);
  }
View Full Code Here

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

    // check simple case
    float[] source = new float[] {1, 2};
    DataBufferFloat b = new DataBufferFloat(source, 2);
    float[] 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 float[] {1, 2, 3};
    b = new DataBufferFloat(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 float[] {1, 2, 3, 4};
    b = new DataBufferFloat(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

TOP

Related Classes of java.awt.image.DataBufferFloat

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.