diff options
author | Glen Stampoultzis <glens@apache.org> | 2006-04-29 00:18:16 +0000 |
---|---|---|
committer | Glen Stampoultzis <glens@apache.org> | 2006-04-29 00:18:16 +0000 |
commit | 6f20feaadcd83c45c98d2800222bb03e67f6420f (patch) | |
tree | b3037eb9acd7b3348db1df99b6ae380a4c1228c0 /src/java/org/apache | |
parent | c1aa12327700be329d3279e3c1de702c48967433 (diff) | |
download | poi-6f20feaadcd83c45c98d2800222bb03e67f6420f.tar.gz poi-6f20feaadcd83c45c98d2800222bb03e67f6420f.zip |
Support for line thicknes through escher graphics 2d interface.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@398044 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java | 14 | ||||
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java | 24 |
2 files changed, 32 insertions, 6 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java index 0bf84d885c..6b898ce96d 100644 --- a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java +++ b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java @@ -16,9 +16,9 @@ package org.apache.poi.hssf.usermodel; +import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; -import org.apache.poi.hssf.util.HSSFColor; import java.awt.*; import java.awt.image.ImageObserver; @@ -204,9 +204,14 @@ public class EscherGraphics public void drawLine(int x1, int y1, int x2, int y2) { + drawLine(x1,y1,x2,y2,0); + } + + public void drawLine(int x1, int y1, int x2, int y2, int width) + { HSSFSimpleShape shape = escherGroup.createShape(new HSSFChildAnchor(x1, y1, x2, y2) ); shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); - shape.setLineWidth(0); + shape.setLineWidth(width); shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue()); } @@ -475,6 +480,9 @@ public class EscherGraphics this.background = background; } - + HSSFShapeGroup getEscherGraphics() + { + return escherGroup; + } } diff --git a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java index 0d2cd16aa2..e9bd19aa30 100644 --- a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java +++ b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java @@ -23,7 +23,10 @@ import java.awt.*; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; import java.awt.font.TextLayout; -import java.awt.geom.*; +import java.awt.geom.AffineTransform; +import java.awt.geom.Area; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; import java.awt.image.BufferedImage; import java.awt.image.BufferedImageOp; import java.awt.image.ImageObserver; @@ -142,7 +145,13 @@ public class EscherGraphics2d extends Graphics2D if (shape instanceof Line2D) { Line2D shape2d = (Line2D) shape; - drawLine((int)shape2d.getX1(), (int)shape2d.getY1(), (int)shape2d.getX2(), (int)shape2d.getY2()); + + int width = 0; + if (stroke != null && stroke instanceof BasicStroke) { + width = (int) ((BasicStroke)stroke).getLineWidth() * 12700; + } + + drawLine((int)shape2d.getX1(), (int)shape2d.getY1(), (int)shape2d.getX2(), (int)shape2d.getY2(), width); } else { @@ -216,9 +225,18 @@ public class EscherGraphics2d extends Graphics2D drawImage(((Image) (img)), new AffineTransform(1.0F, 0.0F, 0.0F, 1.0F, x, y), null); } + public void drawLine(int x1, int y1, int x2, int y2, int width) + { + getEscherGraphics().drawLine(x1,y1,x2,y2, width); + } + public void drawLine(int x1, int y1, int x2, int y2) { - getEscherGraphics().drawLine(x1,y1,x2,y2); + int width = 0; + if (stroke != null && stroke instanceof BasicStroke) { + width = (int) ((BasicStroke)stroke).getLineWidth() * 12700; + } + getEscherGraphics().drawLine(x1,y1,x2,y2, width); // draw(new GeneralPath(new java.awt.geom.Line2D.Float(x1, y1, x2, y2))); } |