diff options
author | Glen Stampoultzis <glens@apache.org> | 2004-04-09 12:19:08 +0000 |
---|---|---|
committer | Glen Stampoultzis <glens@apache.org> | 2004-04-09 12:19:08 +0000 |
commit | 6473d8f7883f0d30da86a935e52cc66a9ed6aae1 (patch) | |
tree | 4f9727b3a352220596c1b82602faf6a80f9854c3 /src/java/org/apache/poi/hssf/usermodel | |
parent | b6ea214cc1e42332b7198954c63a783935b4bdf4 (diff) | |
download | poi-6473d8f7883f0d30da86a935e52cc66a9ed6aae1.tar.gz poi-6473d8f7883f0d30da86a935e52cc66a9ed6aae1.zip |
Some of the later tweaks ported to the head.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353543 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/usermodel')
3 files changed, 13 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java index fa8065a44c..d2ee6f6530 100644 --- a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java +++ b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java @@ -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 ); diff --git a/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics.java b/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics.java index 336b961f42..71e02add67 100644 --- a/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics.java +++ b/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics.java @@ -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()); diff --git a/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java b/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java index 22f0e28c45..3f77c8b955 100644 --- a/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java +++ b/src/java/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java @@ -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()); } } |