This is the mail archive of the mauve-patches@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java.awt.geom.AffineTransform


I've attached some tests for the java.awt.geom.AffineTransform class. 
With JamVM 1.1.4 and Classpath from CVS about 1 week ago, I get the
following results:

FAIL: gnu.testlet.java.awt.geom.AffineTransform.createTransformedShape
(number 10)
FAIL: gnu.testlet.java.awt.geom.AffineTransform.inverseTransform (number
4)
got -16.0 but expected 16.0
FAIL: gnu.testlet.java.awt.geom.AffineTransform.inverseTransform (number
6)
got -24.0 but expected 24.0
FAIL: gnu.testlet.java.awt.geom.AffineTransform.inverseTransform (number
8)
got -32.0 but expected 32.0
FAIL: gnu.testlet.java.awt.geom.AffineTransform.inverseTransform (number
12)
got -8.0 but expected 8.0
FAIL: gnu.testlet.java.awt.geom.AffineTransform.inverseTransform (number
14)
got -8.0 but expected 8.0
6 of 205 tests failed

The first error is some unusual behaviour in Sun's implementation where
the createTransformedShape(Shape) method will accept a null argument.
Classpath throws a NullPointerException.  I searched Sun's bug parade
and it is in there as report 4190350, status "will not fix".

I didn't investigate the problem with the inverseTransform() method. 

All checks pass with JDK1.3 and JDK 1.4 (on SuSE Linux 9.1):

dgilbert@linux42:~/workspace/mauve> java13 gnu.testlet.SimpleTestHarness
-file CurrentTests.txt -debug
0 of 205 tests failed
dgilbert@linux42:~/workspace/mauve> java14 gnu.testlet.SimpleTestHarness
-file CurrentTests.txt -debug
0 of 205 tests failed

Regards,

Dave Gilbert
www.jfree.org
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Checks that the clone() method works.
 */
public class clone implements Testlet 
{

    /**
     * Runs the test using the specified harness.
     * 
     * @param harness  the test harness (<code>null</code> not permitted).
     */
    public void test(TestHarness harness) 
    {
      AffineTransform t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
      AffineTransform t2 = null;
      t2 = (AffineTransform) t1.clone();
      harness.check(t2.getScaleX(), 1.0);
      harness.check(t2.getScaleY(), 4.0);
      harness.check(t2.getTranslateX(), 5.0);
      harness.check(t2.getTranslateY(), 6.0);
      harness.check(t2.getShearX(), 3.0);
      harness.check(t2.getShearY(), 2.0);
      harness.check(t2.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
    }

}
//Tags: JDK1.4

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class concatenate implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    AffineTransform t2 = new AffineTransform(7.0, 8.0, 9.0, 10.0, 11.0, 12.0);
    t1.concatenate(t2);
    harness.check(t1.getScaleX(), 31.0);
    harness.check(t1.getShearX(), 39.0);
    harness.check(t1.getTranslateX(), 52.0);
    harness.check(t1.getShearY(), 46.0);
    harness.check(t1.getScaleY(), 58.0);
    harness.check(t1.getTranslateY(), 76.0);

    boolean pass = false;
    try
    {
      t1.concatenate(null);
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
  }

}
//Tags: JDK1.4

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Verifies constant values for the {@link AffineTransform} class.
 */
public class constants implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    harness.check(AffineTransform.TYPE_FLIP == 64);
    harness.check(AffineTransform.TYPE_GENERAL_ROTATION == 16);
    harness.check(AffineTransform.TYPE_GENERAL_SCALE == 4);
    harness.check(AffineTransform.TYPE_GENERAL_TRANSFORM == 32);
    harness.check(AffineTransform.TYPE_IDENTITY == 0);
    harness.check(AffineTransform.TYPE_MASK_ROTATION == 24);
    harness.check(AffineTransform.TYPE_MASK_SCALE == 6);
    harness.check(AffineTransform.TYPE_QUADRANT_ROTATION == 8);
    harness.check(AffineTransform.TYPE_TRANSLATION == 1);
    harness.check(AffineTransform.TYPE_UNIFORM_SCALE == 2);
  }

}
//Tags: JDK1.4

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
* Some tests for the {@link AffineTransform} class.
*/
public class constructors implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    testConstructor1(harness);
    testConstructor2(harness);
    testConstructor3(harness);
    testConstructor4(harness);
    testConstructor5(harness);
    testConstructor6(harness);
  }
  
  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("AffineTransform()");
    AffineTransform t = new AffineTransform();
    harness.check(t.getScaleX(), 1.0);
    harness.check(t.getScaleY(), 1.0);
    harness.check(t.getTranslateX(), 0.0);
    harness.check(t.getTranslateY(), 0.0);
    harness.check(t.getShearX(), 0.0);
    harness.check(t.getShearY(), 0.0);
    harness.check(t.getType() == AffineTransform.TYPE_IDENTITY);
  }

  private void testConstructor2(TestHarness harness) 
  {
    harness.checkPoint("AffineTransform(AffineTransform)");
    AffineTransform t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    AffineTransform t2 = new AffineTransform(t1);
    harness.check(t2.getScaleX(), 1.0);
    harness.check(t2.getScaleY(), 4.0);
    harness.check(t2.getTranslateX(), 5.0);
    harness.check(t2.getTranslateY(), 6.0);
    harness.check(t2.getShearX(), 3.0);
    harness.check(t2.getShearY(), 2.0);
    harness.check(t2.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
  }
  
  private void testConstructor3(TestHarness harness) 
  {
    harness.checkPoint("AffineTransform(double[])");
    double[] d1 = new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
    AffineTransform t1 = new AffineTransform(d1);
    harness.check(t1.getScaleX(), 1.0);
    harness.check(t1.getScaleY(), 4.0);
    harness.check(t1.getTranslateX(), 5.0);
    harness.check(t1.getTranslateY(), 6.0);
    harness.check(t1.getShearX(), 3.0);
    harness.check(t1.getShearY(), 2.0);
    harness.check(t1.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
    
    double[] d2 = new double[] {1.0, 2.0, 3.0, 4.0};
    AffineTransform t2 = new AffineTransform(d2);
    harness.check(t2.getScaleX(), 1.0);
    harness.check(t2.getScaleY(), 4.0);
    harness.check(t2.getTranslateX(), 0.0);
    harness.check(t2.getTranslateY(), 0.0);
    harness.check(t2.getShearX(), 3.0);
    harness.check(t2.getShearY(), 2.0);
    harness.check(t2.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
  }

  private void testConstructor4(TestHarness harness) 
  {
    harness.checkPoint("AffineTransform(double, double, double, double, double, double)");
    AffineTransform t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(t1.getScaleX(), 1.0);
    harness.check(t1.getScaleY(), 4.0);
    harness.check(t1.getTranslateX(), 5.0);
    harness.check(t1.getTranslateY(), 6.0);
    harness.check(t1.getShearX(), 3.0);
    harness.check(t1.getShearY(), 2.0);
    harness.check(t1.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
  }
  
  private void testConstructor5(TestHarness harness) 
  {
    harness.checkPoint("AffineTransform(float[])");
    float[] f1 = new float[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
    AffineTransform t1 = new AffineTransform(f1);
    harness.check(t1.getScaleX(), 1.0f);
    harness.check(t1.getScaleY(), 4.0f);
    harness.check(t1.getTranslateX(), 5.0f);
    harness.check(t1.getTranslateY(), 6.0f);
    harness.check(t1.getShearX(), 3.0f);
    harness.check(t1.getShearY(), 2.0f);
    harness.check(t1.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
    
    float[] d2 = new float[] {1.0f, 2.0f, 3.0f, 4.0f};
    AffineTransform t2 = new AffineTransform(d2);
    harness.check(t2.getScaleX(), 1.0f);
    harness.check(t2.getScaleY(), 4.0f);
    harness.check(t2.getTranslateX(), 0.0);
    harness.check(t2.getTranslateY(), 0.0);
    harness.check(t2.getShearX(), 3.0f);
    harness.check(t2.getShearY(), 2.0f);
    harness.check(t2.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
  }

  private void testConstructor6(TestHarness harness) 
  {
    harness.checkPoint("AffineTransform(float, float, float, float, float, float)");
    AffineTransform t1 = new AffineTransform(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);
    harness.check(t1.getScaleX(), 1.0f);
    harness.check(t1.getScaleY(), 4.0f);
    harness.check(t1.getTranslateX(), 5.0f);
    harness.check(t1.getTranslateY(), 6.0f);
    harness.check(t1.getShearX(), 3.0f);
    harness.check(t1.getShearY(), 2.0f);
    harness.check(t1.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
  }
}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class createInverse implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    // inverse of identity is identity
    AffineTransform t1 = new AffineTransform();
    try 
    {
      AffineTransform t2 = t1.createInverse();
      harness.check(t2.getType() == AffineTransform.TYPE_IDENTITY);
    }
    catch (NoninvertibleTransformException e)
    {
      harness.check(false);
    }
    
    
    t1 = new AffineTransform(7.0, 8.0, 9.0, 10.0, 11.0, 12.0);
    try 
    {
      AffineTransform t3 = t1.createInverse();
      harness.check(t3.getScaleX(), -5.0);
      harness.check(t3.getShearX(), 4.5);
      harness.check(t3.getTranslateX(), 1.0);
      harness.check(t3.getShearY(), 4.0);
      harness.check(t3.getScaleY(), -3.5);
      harness.check(t3.getTranslateY(), -2.0);
    }
    catch (NoninvertibleTransformException e)
    {
      harness.check(false);
    }
    
    AffineTransform t4 = new AffineTransform(3.0, 3.0, 3.0, 3.0, 3.0, 3.0);
    try 
    {
      AffineTransform t5 = t4.createInverse();
      harness.check(false);
    }
    catch (NoninvertibleTransformException e)
    {
      harness.check(true);
    }
  }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.PathIterator;

/**
* Some tests for the {@link AffineTransform} class.
*/
public class createTransformedShape implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t1 = new AffineTransform();
    Line2D line1 = new Line2D.Double(1.0, 2.0, 3.0, 4.0);
    Shape shape1 = t1.createTransformedShape(line1);
    GeneralPath p1 = (GeneralPath) shape1;
    PathIterator iterator = p1.getPathIterator(null);
    double[] c = new double[6];
    
    harness.check(!iterator.isDone());                                   
    harness.check(iterator.currentSegment(c), PathIterator.SEG_MOVETO);  
    harness.check(c[0], 1.0);                                       
    harness.check(c[1], 2.0);   

    iterator.next();
    harness.check(!iterator.isDone());                                   
    harness.check(iterator.currentSegment(c), PathIterator.SEG_LINETO);  
    harness.check(c[0], 3.0);                                       
    harness.check(c[1], 4.0);  

    iterator.next();
    harness.check(iterator.isDone());
    
    // tricky case here - passing a null argument does NOT throw a 
    // NullPointerException (see bug parade report 4190350).
    boolean pass = true;
    try 
    {
      t1.createTransformedShape(null);
    }
    catch (NullPointerException e) 
    {
      pass = false;
    }
    harness.check(pass);
  } 

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;

/**
* Some tests for the {@link AffineTransform} class.
*/
public class deltaTransform implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t1 = AffineTransform.getScaleInstance(2.0, 3.0);
    double[] v = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
    double[] expected = new double[] { 1.0, 2.0, 6.0, 12.0, 10.0, 18.0, 14.0, 24.0, 9.0, 10.0 };
    t1.deltaTransform(v, 2, v, 2, 3);
    for (int i = 0; i < 10; i++) {
        harness.check(v[i], expected[i]);
    }
    
    Point2D p1 = new Point2D.Double(1.0, 2.0);
    Point2D p2 = t1.deltaTransform(p1, null);
    harness.check(p2.getX(), 2.0);
    harness.check(p2.getY(), 6.0);
    
    t1.deltaTransform(p1, p1);
    harness.check(p1.getX(), 2.0);
    harness.check(p1.getY(), 6.0);
    
    boolean pass = false;
    try
    {
      t1.deltaTransform(null, null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
  } 

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class equals implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    AffineTransform t2 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(t1.equals(t2));
    harness.check(t2.equals(t1));
    
    t1 = new AffineTransform(0.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(!t1.equals(t2));
    t2 = new AffineTransform(0.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(t1.equals(t2));

    t1 = new AffineTransform(1.0, 0.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(!t1.equals(t2));
    t2 = new AffineTransform(1.0, 0.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(t1.equals(t2));

    t1 = new AffineTransform(1.0, 2.0, 0.0, 4.0, 5.0, 6.0);
    harness.check(!t1.equals(t2));
    t2 = new AffineTransform(1.0, 2.0, 0.0, 4.0, 5.0, 6.0);
    harness.check(t1.equals(t2));

    t1 = new AffineTransform(1.0, 2.0, 3.0, 0.0, 5.0, 6.0);
    harness.check(!t1.equals(t2));
    t2 = new AffineTransform(1.0, 2.0, 3.0, 0.0, 5.0, 6.0);
    harness.check(t1.equals(t2));

    t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 0.0, 6.0);
    harness.check(!t1.equals(t2));
    t2 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 0.0, 6.0);
    harness.check(t1.equals(t2));

    t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 0.0);
    harness.check(!t1.equals(t2));
    t2 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 0.0);
    harness.check(t1.equals(t2));
  }
}
//Tags: JDK1.4

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class getDeterminant implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(t.getDeterminant(), 1.0 * 4.0 - 2.0 * 3.0);
  }

}
//Tags: JDK1.4

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class getMatrix implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    double[] m = new double[4];
    t.getMatrix(m);
    harness.check(m[0], 1.0);
    harness.check(m[1], 2.0);
    harness.check(m[2], 3.0);
    harness.check(m[3], 4.0);
    
    m = new double[6];
    t.getMatrix(m);
    harness.check(m[0], 1.0);
    harness.check(m[1], 2.0);
    harness.check(m[2], 3.0);
    harness.check(m[3], 4.0);
    harness.check(m[4], 5.0);
    harness.check(m[5], 6.0);
    
    boolean pass = false;
    m = new double[2];
    try
    {
      t.getMatrix(m);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
    
    pass = false;
    try
    {
      t.getMatrix(null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
  }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
* Some tests for the {@link AffineTransform} class.
*/
public class getRotateInstance implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t = AffineTransform.getRotateInstance(0.5);
    harness.check(t.getScaleX(), Math.cos(0.5));
    harness.check(t.getShearX(), -Math.sin(0.5));
    harness.check(t.getTranslateX(), 0.0);
    harness.check(t.getShearY(), Math.sin(0.5));
    harness.check(t.getScaleY(), Math.cos(0.5));
    harness.check(t.getTranslateY(), 0.0);
    harness.check(t.getType() == AffineTransform.TYPE_GENERAL_ROTATION);

    t = AffineTransform.getRotateInstance(0.5, 1.0, 2.0);
    harness.check(t.getScaleX(), Math.cos(0.5));
    harness.check(t.getShearX(), -Math.sin(0.5));
    harness.check(t.getTranslateX(), 1.0 - 1.0 * Math.cos(0.5) + 2.0 * Math.sin(0.5));
    harness.check(t.getShearY(), Math.sin(0.5));
    harness.check(t.getScaleY(), Math.cos(0.5));
    harness.check(t.getTranslateY(), 2.0 - 1.0 * Math.sin(0.5) - 2.0 * Math.cos(0.5));
    harness.check(t.getType() == (AffineTransform.TYPE_TRANSLATION | AffineTransform.TYPE_GENERAL_ROTATION));

  }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
* Some tests for the {@link AffineTransform} class.
*/
public class getScaleInstance implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    AffineTransform t = AffineTransform.getScaleInstance(1.0, 2.0);
    harness.check(t.getScaleX(), 1.0);
    harness.check(t.getShearX(), 0.0);
    harness.check(t.getTranslateX(), 0.0);
    harness.check(t.getShearY(), 0.0);
    harness.check(t.getScaleY(), 2.0);
    harness.check(t.getTranslateY(), 0.0);
    harness.check(t.getType() == AffineTransform.TYPE_GENERAL_SCALE);

 }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class getShearInstance implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    AffineTransform t = AffineTransform.getShearInstance(1.0, 2.0);
    harness.check(t.getScaleX(), 1.0);
    harness.check(t.getShearX(), 1.0);
    harness.check(t.getTranslateX(), 0.0);
    harness.check(t.getShearY(), 2.0);
    harness.check(t.getScaleY(), 1.0);
    harness.check(t.getTranslateY(), 0.0);
    harness.check(t.getType() == AffineTransform.TYPE_GENERAL_TRANSFORM);
  }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class getTranslateInstance implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
  */
  public void test(TestHarness harness)       
  {
    AffineTransform t = AffineTransform.getTranslateInstance(1.0, 2.0);
    harness.check(t.getScaleX(), 1.0);
    harness.check(t.getShearX(), 0.0);
    harness.check(t.getTranslateX(), 1.0);
    harness.check(t.getShearY(), 0.0);
    harness.check(t.getScaleY(), 1.0);
    harness.check(t.getTranslateY(), 2.0);
    harness.check(t.getType() == AffineTransform.TYPE_TRANSLATION);
  }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;

/**
* Some tests for the {@link AffineTransform} class.
*/
public class inverseTransform implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t1 = AffineTransform.getScaleInstance(0.5, 0.25);
    double[] v = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
    double[] expected = new double[] { 1.0, 2.0, 6.0, 16.0, 10.0, 24.0, 14.0, 32.0, 9.0, 10.0 };
    try 
    {
      t1.inverseTransform(v, 2, v, 2, 3);
      for (int i = 0; i < 10; i++) {
        harness.check(v[i], expected[i]);
      }
    }
    catch (NoninvertibleTransformException e)
    {
      harness.check(false);
    }
  
    Point2D p1 = new Point2D.Double(1.0, 2.0);
    try 
    {
      Point2D p2 = t1.inverseTransform(p1, null);
      harness.check(p2.getX(), 2.0);
      harness.check(p2.getY(), 8.0);
      t1.inverseTransform(p1, p1);
      harness.check(p1.getX(), 2.0);
      harness.check(p1.getY(), 8.0);
    }
    catch (NoninvertibleTransformException e)
    {
      harness.check(false);
    }
  
    boolean pass = false;
    try
    {
      t1.inverseTransform(null, null);
    }
    catch (NoninvertibleTransformException e1)
    {
      pass = false;
    }
    catch (NullPointerException e2)
    {
      pass = true;
    }
    harness.check(pass);
  } 

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class isIdentity implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t0 = new AffineTransform();
    harness.check(t0.isIdentity());
    AffineTransform t1 = AffineTransform.getScaleInstance(0.5, 0.25);
    harness.check(!t1.isIdentity());
  } 

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class preConcatenate implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t1 = new AffineTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    AffineTransform t2 = new AffineTransform(7.0, 8.0, 9.0, 10.0, 11.0, 12.0);
    t1.preConcatenate(t2);
    harness.check(t1.getScaleX(), 25.0);
    harness.check(t1.getShearX(), 57.0);
    harness.check(t1.getTranslateX(), 100.0);
    harness.check(t1.getShearY(), 28.0);
    harness.check(t1.getScaleY(), 64.0);
    harness.check(t1.getTranslateY(), 112.0);

    boolean pass = false;
    try
    {
      t1.preConcatenate(null);
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
  }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class setTransform implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    AffineTransform t1 = new AffineTransform();
    t1.setTransform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
    harness.check(t1.getScaleX(), 1.0);
    harness.check(t1.getShearY(), 2.0);
    harness.check(t1.getShearX(), 3.0);
    harness.check(t1.getScaleY(), 4.0);
    harness.check(t1.getTranslateX(), 5.0);
    harness.check(t1.getTranslateY(), 6.0);
    
    t1.setTransform(new AffineTransform(6.0, 5.0, 4.0, 3.0, 2.0, 1.0));
    harness.check(t1.getScaleX(), 6.0);
    harness.check(t1.getShearY(), 5.0);
    harness.check(t1.getShearX(), 4.0);
    harness.check(t1.getScaleY(), 3.0);
    harness.check(t1.getTranslateX(), 2.0);
    harness.check(t1.getTranslateY(), 1.0);
    
    boolean pass = false;
    try
    {
      t1.setTransform(null);
    }
    catch (NullPointerException e) 
    {
      pass = true;
    }
    harness.check(pass);
  }

}
//Tags: JDK1.2

//Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>

//Mauve is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2, or (at your option)
//any later version.

//Mauve is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Mauve; see the file COPYING.  If not, write to
//the Free Software Foundation, 59 Temple Place - Suite 330,
//Boston, MA 02111-1307, USA.  */

package gnu.testlet.java.awt.geom.AffineTransform;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;

/**
 * Some tests for the {@link AffineTransform} class.
 */
public class transform implements Testlet 
{

  /**
   * Runs the test using the specified harness.
   * 
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    AffineTransform t1 = AffineTransform.getScaleInstance(2.0, 3.0);
    double[] d = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
    double[] expected = new double[] { 1.0, 2.0, 6.0, 12.0, 10.0, 18.0, 14.0, 24.0, 9.0, 10.0 };
    t1.transform(d, 2, d, 2, 3);
    for (int i = 0; i < 10; i++) {
      harness.check(d[i], expected[i]);
    }
  
    float[] f = new float[10];
    float[] expectedf = new float[] { 1.0f, 2.0f, 6.0f, 12.0f, 10.0f, 18.0f, 14.0f, 24.0f, 9.0f, 10.0f };
    t1.transform(d, 2, f, 2, 3);
    for (int i = 0; i < 10; i++) {
      harness.check(f[i], expectedf[i]);
    }
    
    f = new float[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f };
    t1.transform(f, 2, d, 2, 3);
    for (int i = 0; i < 10; i++) {
      harness.check(d[i], expected[i]);
    }

    t1.transform(f, 2, f, 2, 3);
    for (int i = 0; i < 10; i++) {
      harness.check(f[i], expectedf[i]);
    }
    
    Point2D p1 = new Point2D.Double(1.0, 2.0);
    Point2D p2 = t1.transform(p1, null);
    harness.check(p2.getX(), 2.0);
    harness.check(p2.getY(), 6.0);
  
    t1.transform(p1, p1);
    harness.check(p1.getX(), 2.0);
    harness.check(p1.getY(), 6.0);
  
    boolean pass = false;
    try
    {
      t1.transform(null, null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
  } 

}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]