Package java.awt.font

Examples of java.awt.font.ImageGraphicAttribute


  public void test(TestHarness harness)
  {
    try
      {
        Image image = ImageIO.read(new File("gnu/testlet/java/awt/font/ImageGraphicAttribute/image.bmp"));
        ImageGraphicAttribute iga = new ImageGraphicAttribute(image, 0);

        harness.check(iga.hashCode(), image.hashCode());
        harness.check(iga.getAscent(), 0.0);
        harness.check(iga.getDescent(), 64.0);
        harness.check(iga.getAdvance(), 127.0);
        harness.check(iga.getBounds(), new Rectangle2D.Float((float) - 0.0,
                                                             (float) - 0.0,
                                                             (float) 127.0,
                                                             (float) 64.0));
       
        ImageGraphicAttribute iga2 = new ImageGraphicAttribute(image, 0, 10, -1202);

        harness.check(iga2.hashCode(), image.hashCode());
        harness.check(iga2.getAscent(), 0.0);
        harness.check(iga2.getDescent(), 1266.0);
        harness.check(iga2.getAdvance(), 117.0);
        harness.check(iga2.getBounds(), new Rectangle2D.Float((float) - 10.0,
                                                             (float) 1202.0,
                                                             (float) 127.0,
                                                             (float) 64.0));
       
        harness.check(iga.equals(iga2), false);
View Full Code Here


    public final void testGetAdvance() {
        float xOrigin = 5;
        float yOrigin = 5;
        float xOrigin1 = 15;

        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
        assertEquals(img.getWidth(null) - xOrigin, iga.getAdvance(), 0F);

        iga = new ImageGraphicAttribute(img, alignment, xOrigin1, yOrigin);
        assertEquals(0, iga.getAdvance(), 0F);
    }
View Full Code Here

    public final void testGetAscent() {
        float yOrigin = 5;
        float xOrigin = 5;
        float yOrigin1 = -5;

        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
        assertEquals(yOrigin, iga.getAscent(), 0F);

        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin1);
        assertEquals(0, iga.getAscent(), 0F);
    }
View Full Code Here

     * Test method for 'java.awt.font.ImageGraphicAttribute.getBounds()'
     */
    public final void testGetBounds() {
        float yOrigin = 5;
        float xOrigin = 5;
        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
        assertEquals(new Rectangle2D.Float(-xOrigin, -yOrigin, img.getWidth(null), img.getHeight(null)),
                iga.getBounds());

        iga = new ImageGraphicAttribute(img, alignment);
        assertEquals(new Rectangle2D.Float(0, 0, img.getWidth(null), img.getHeight(null)),
                iga.getBounds());

    }
View Full Code Here

    public final void testGetDescent() {
        float yOrigin = 5;
        float xOrigin = 5;
        float yOrigin1 = 15;

        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
        assertEquals(img.getHeight(null) - yOrigin, iga.getDescent(), 0F);

        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin1);
        assertEquals(0, iga.getDescent(), 0F);
       
    }
View Full Code Here

    /*
     * Test method for 'java.awt.font.ImageGraphicAttribute.ImageGraphicAttribute(Image, int, float, float)'
     */
    public final void testImageGraphicAttributeImageInt() {
        ImageGraphicAttribute igAttribute = new ImageGraphicAttribute(img, alignment);
        assertNotNull(igAttribute);
        assertEquals(alignment, igAttribute.getAlignment());
        assertEquals(width, igAttribute.getAdvance(), 0F);
        assertEquals(0, igAttribute.getAscent(), 0F);
        assertEquals(height, igAttribute.getDescent(), 0F);
        assertEquals(new Rectangle2D.Float(0, 0, img.getWidth(null), img.getHeight(null)),
                igAttribute.getBounds());

        // illegal alignment value
        try {
            iga = new ImageGraphicAttribute(img, -3);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }

        try {
            iga = new ImageGraphicAttribute(img, 3);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }
    }
View Full Code Here

     * Test method for 'java.awt.font.ImageGraphicAttribute.ImageGraphicAttribute(Image, int)'
     */
    public final void testImageGraphicAttributeImageIntFloatFloat() {
        float xOrigin = 5;
        float yOrigin = 5;
        ImageGraphicAttribute igAttribute = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
        assertNotNull(igAttribute);
        assertEquals(alignment, igAttribute.getAlignment());
        assertEquals(width - xOrigin, igAttribute.getAdvance(), 0F);
        assertEquals(yOrigin, igAttribute.getAscent(), 0F);
        assertEquals(height - yOrigin, igAttribute.getDescent(), 0F);
        assertEquals(new Rectangle2D.Float(-xOrigin, -yOrigin, img.getWidth(null), img.getHeight(null)),
                igAttribute.getBounds());

        // illegal alignment value
        try {
            iga = new ImageGraphicAttribute(img, -3, xOrigin, yOrigin);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }

        try {
            iga = new ImageGraphicAttribute(img, 3, xOrigin, yOrigin);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }
    }
View Full Code Here

    /*
     * Test method for 'java.awt.font.ImageGraphicAttribute.equals(ImageGraphicAttribute)'
     */
    public final void testEqualsImageGraphicAttribute() {
        iga = new ImageGraphicAttribute(img, alignment);
        ImageGraphicAttribute iga1 = new ImageGraphicAttribute(img, alignment);
        assertEquals(iga, iga1);
    }
View Full Code Here

    /*
     * Test method for 'java.awt.font.ImageGraphicAttribute.equals(Object)'
     */
    public final void testEqualsObject() {
        iga = new ImageGraphicAttribute(img, alignment);
        ImageGraphicAttribute iga1 = new ImageGraphicAttribute(img, alignment);
        assertEquals(iga, iga1);
    }
View Full Code Here

    /*
     * Test method for 'java.awt.font.GraphicAttribute.getAlignment()'
     */
    public final void testGetAlignment() {
        iga = new ImageGraphicAttribute(img, alignment);
        assertEquals(alignment, iga.getAlignment());
    }
View Full Code Here

TOP

Related Classes of java.awt.font.ImageGraphicAttribute

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.