Examples of ComponentSampleModel


Examples of java.awt.image.ComponentSampleModel

    harness.checkPoint("(int, int, int, int, int, int[], int[])");

    int[] bankIndices = new int[] {0, 1};
    int[] bandOffsets = new int[] {0, 0};
   
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
            11, 1, 25, bankIndices, new int[] {0, 0});
    harness.check(m.getDataType(), DataBuffer.TYPE_INT);
    harness.check(m.getWidth(), 22);
    harness.check(m.getHeight(), 11);
    harness.check(m.getPixelStride(), 1);
    harness.check(m.getNumBands(), 2);
    harness.check(m.getNumDataElements(), 2);
    harness.check(Arrays.equals(m.getBankIndices(), new int[] {0, 1}));
    harness.check(m.getBankIndices() != bankIndices)// not the same instance
    harness.check(Arrays.equals(m.getBandOffsets(), bandOffsets));
    harness.check(m.getBandOffsets() != bandOffsets)// not the same instance
    // check unknown data type
    boolean pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_UNDEFINED, 22,
                11, 1, 25, new int[] {0, 1}, new int[] {0, 0});
      }
    catch (IllegalArgumentException e)
      {
        pass = true
      }
    harness.check(pass);
   
    // check w = 0
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 0,
            11, 1, 25, new int[] {0, 1}, new int[] {0, 0});
      }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // check h = 0
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
            0, 1, 25, new int[] {0, 1}, new int[] {0, 0});
      }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // check w * h exceeds Integer.MAX_VALUE
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, Integer.MAX_VALUE - 1,
            2, 1, 25, new int[] {0, 1}, new int[] {0, 0});
      }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try pixelStride < 0
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
              11, -1, 25, new int[] {0, 1}, new int[] {0, 0});
      }
    catch (IllegalArgumentException e)
      {
        pass = true
      }
    harness.check(pass);
   
    // try scanlineStride = 0
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
                11, 1, -1, new int[] {0, 1}, new int[] {0, 0});
      }
    catch (IllegalArgumentException e)
      {
        pass = true
      }
    harness.check(pass);

    // try null bankIndices
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25, null,
                new int[] {0, 0});
      }
    catch (NullPointerException e)
      {
        pass = true;
      }
    harness.check(pass);
     
    // try empty bankIndices
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25,
                new int[0], new int[] {0, 0});
      }
    catch (ArrayIndexOutOfBoundsException e)
      {
        pass = true;
      }
    catch (IllegalArgumentException e)
      {
        pass = true;
      }
    harness.check(pass);
   
    // try null bandOffsets
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25,
                new int[] {0, 0}, null);
      }
    catch (NullPointerException e)
      {
        pass = true;
      }
    harness.check(pass);
   
    // try arrays of different lengths
    pass = false;
    try
      {
        m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25,
                new int[1], new int[2]);
      }
    catch (IllegalArgumentException e)
      {
        pass = true;
View Full Code Here

Examples of java.awt.image.ComponentSampleModel

public class getPixelStride implements Testlet
{
  public void test(TestHarness harness)
  {
    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
        11, 2, 44, new int[] {0, 0});
    harness.check(m1.getPixelStride(), 2);
  }
View Full Code Here

Examples of java.awt.image.ComponentSampleModel

public class getSample implements Testlet
{
  public void test(TestHarness harness)
  {
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 5,
            10, 3, 16, new int[] {0, 1, 2});
    DataBuffer db = m.createDataBuffer();
    harness.check(db.getNumBanks(), 1);
    db.setElem(0, 16, 0xAA);
    db.setElem(0, 17, 0xBB);
    db.setElem(0, 18, 0xCC);
    harness.check(m.getSample(0, 1, 0, db), 0xAA);
    harness.check(m.getSample(0, 1, 1, db), 0xBB);
    harness.check(m.getSample(0, 1, 2, db), 0xCC);
   
    // try negative x
    boolean pass = false;
    try
    {
      m.getSample(-1, 1, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try x == width
    pass = false;
    try
    {
      m.getSample(5, 0, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // try negative y
    pass = false;
    try
    {
      m.getSample(1, -1, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // try y == height
    pass = false;
    try
    {
      m.getSample(0, 10, 0, db);
    }
    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.