Updated to support lines for the EscherGraphics2d draw() call.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@396821 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ca716cdbe5
commit
6f7d2e3b76
@ -23,9 +23,7 @@ import java.awt.*;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.BufferedImageOp;
|
||||
import java.awt.image.ImageObserver;
|
||||
@ -141,8 +139,16 @@ public class EscherGraphics2d extends Graphics2D
|
||||
|
||||
public void draw(Shape shape)
|
||||
{
|
||||
if (logger.check( POILogger.WARN ))
|
||||
logger.log(POILogger.WARN,"copyArea not supported");
|
||||
if (shape instanceof Line2D)
|
||||
{
|
||||
Line2D shape2d = (Line2D) shape;
|
||||
drawLine((int)shape2d.getX1(), (int)shape2d.getY1(), (int)shape2d.getX2(), (int)shape2d.getY2());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.check(POILogger.WARN))
|
||||
logger.log(POILogger.WARN, "draw not fully supported");
|
||||
}
|
||||
}
|
||||
|
||||
public void drawArc(int x, int y, int width, int height,
|
||||
|
@ -19,7 +19,7 @@ package org.apache.poi.hssf.usermodel;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.FileOutputStream;
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
/**
|
||||
* Tests the Graphics2d drawing capability.
|
||||
@ -65,7 +65,7 @@ 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.
|
||||
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());
|
||||
@ -92,4 +92,16 @@ public class TestEscherGraphics2d extends TestCase
|
||||
|
||||
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
|
||||
}
|
||||
|
||||
public void testDraw() throws Exception
|
||||
{
|
||||
graphics.draw(new Line2D.Double(10,10,20,20));
|
||||
HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0);
|
||||
assertTrue(s.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_LINE);
|
||||
assertEquals(10, s.getAnchor().getDx1());
|
||||
assertEquals(10, s.getAnchor().getDy1());
|
||||
assertEquals(20, s.getAnchor().getDx2());
|
||||
assertEquals(20, s.getAnchor().getDy2());
|
||||
System.out.println("s = " + s);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user