]> source.dussan.org Git - poi.git/commitdiff
Some of the later tweaks ported to the head.
authorGlen Stampoultzis <glens@apache.org>
Fri, 9 Apr 2004 12:19:08 +0000 (12:19 +0000)
committerGlen Stampoultzis <glens@apache.org>
Fri, 9 Apr 2004 12:19:08 +0000 (12:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353543 13f79535-47bb-0310-9956-ffa450edef68

build.xml
src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java
src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics.java
src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java

index 9e2148fb218fa412f18d777a15f7aac79c67983a..29a7b5448997ba6ad4ead21c5f0fee4f4f072dce 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -275,6 +275,7 @@ Main targets:
             <classpath refid="test.classpath"/>
             <sysproperty key="HSSF.testdata.path" file="${main.src.test}/org/apache/poi/hssf/data"/>
             <sysproperty key="HPSF.testdata.path" file="${main.src.test}/org/apache/poi/hpsf/data"/>
+            <sysproperty key="java.awt.headless" value="true"/>
             <formatter type="plain"/>
             <formatter type="xml"/>
             <batchtest todir="${main.reports.test}">
@@ -293,6 +294,7 @@ Main targets:
             <classpath refid="test.classpath"/>
             <sysproperty key="HSSF.testdata.path" file="${main.src.test}/org/apache/poi/hssf/data"/>
             <sysproperty key="HPSF.testdata.path" file="${main.src.test}/org/apache/poi/hpsf/data"/>
+            <sysproperty key="java.awt.headless" value="true"/>
             <formatter type="plain" usefile="no"/>
             <formatter type="xml"/>
             <test name="${testcase}"/>
@@ -307,6 +309,7 @@ Main targets:
             <classpath refid="test.classpath"/>
             <sysproperty key="HSSF.testdata.path" file="${main.src.test}/org/apache/poi/hssf/data"/>
             <sysproperty key="HPSF.testdata.path" file="${main.src.test}/org/apache/poi/hpsf/data"/>
+            <sysproperty key="java.awt.headless" value="true"/>
             <formatter type="plain" usefile="no"/>
             <test name="${testcase}"/>
         </junit>
@@ -341,6 +344,7 @@ Main targets:
             <sysproperty key="HPSF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hpsf/data"/>
             <sysproperty key="HDF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hdf/data"/>
             <sysproperty key="HWPF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hwpf/data"/>
+            <sysproperty key="java.awt.headless" value="true"/>
             <formatter type="plain"/>
             <formatter type="xml"/>
             <batchtest todir="${scratchpad.reports.test}">
@@ -376,6 +380,7 @@ Main targets:
             </classpath>
             <sysproperty key="HSSF.testdata.path" file="${contrib.src.test}/org/apache/poi/hssf/data"/>
             <sysproperty key="HPSF.testdata.path" file="${contrib.src.test}/org/apache/poi/hpsf/data"/>
+            <sysproperty key="java.awt.headless" value="true"/>
             <formatter type="plain"/>
             <formatter type="xml"/>
             <batchtest todir="${contrib.reports.test}">
index fa8065a44c24603dfdc766491760de4d8a4fac2c..d2ee6f65305799573e0ec6344c4fd470136511b5 100644 (file)
@@ -253,9 +253,9 @@ public class EscherGraphics
             excelFont = new Font( font.getName(), font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ));
         }
         FontDetails d = StaticFontMetrics.getFontDetails( excelFont );
-        int width = (int) ( (d.getStringWidth( str ) * 2.5)  + 12 );
-        int height = (int) ( ( font.getSize() * 2.0 * verticalPixelsPerPoint ) + 6 );
-        y -= ( font.getSize() * verticalPixelsPerPoint );    // we want to draw the shape from the top-left
+        int width = (int) ( (d.getStringWidth( str ) * 8)  + 12 );
+        int height = (int) ( ( font.getSize() / verticalPixelsPerPoint ) + 6 ) * 2;
+        y -= ( font.getSize() / verticalPixelsPerPoint ) + 2 * verticalPixelsPerPoint;    // we want to draw the shape from the top-left
         HSSFTextbox textbox = escherGroup.createTextbox( new HSSFChildAnchor( x, y, x + width, y + height ) );
         textbox.setNoFill( true );
         textbox.setLineStyle( HSSFShape.LINESTYLE_NONE );
index 336b961f42afcf78ef19305c8dbf0920abeafc32..71e02add676f46c572fda349de70fdacc45e9a22 100644 (file)
@@ -27,11 +27,15 @@ public class TestEscherGraphics extends TestCase
     public void testGetFont() throws Exception
     {
         Font f = graphics.getFont();
-        assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
+        if (f.toString().indexOf("dialog") == -1)
+            assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
     }
 
     public void testGetFontMetrics() throws Exception
     {
+        Font f = graphics.getFont();
+        if (f.toString().indexOf("dialog") != -1)
+            return;
         FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
         assertEquals(7, fontMetrics.charWidth('X'));
         assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
index 22f0e28c4549fe00b668027fda540e52c5db79da..3f77c8b955314dcdfda37ebe687ce51a72ce5470 100644 (file)
@@ -49,6 +49,8 @@ public class TestEscherGraphics2d extends TestCase
     public void testGetFontMetrics() throws Exception
     {
         FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
+     if (graphics.getFont().toString().indexOf("dialog") != -1) // if dialog is returned we can't run the test properly.
+            return;
         assertEquals(7, fontMetrics.charWidth('X'));
         assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
     }
@@ -69,6 +71,9 @@ public class TestEscherGraphics2d extends TestCase
     public void testGetFont() throws Exception
     {
         Font f = graphics.getFont();
+        if (graphics.getFont().toString().indexOf("dialog") != -1) // if dialog is returned we can't run the test properly.
+            return;
+
         assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
     }
 }