Author: glens
Date: Fri Apr 28 17:18:16 2006
New Revision: 398044

URL: http://svn.apache.org/viewcvs?rev=398044&view=rev
Log:
Support for line thicknes through escher graphics 2d interface.

Modified:
    
jakarta/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
    jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java
    
jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java

Modified: 
jakarta/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
URL: 
http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java?rev=398044&r1=398043&r2=398044&view=diff
==============================================================================
--- 
jakarta/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
 (original)
+++ 
jakarta/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
 Fri Apr 28 17:18:16 2006
@@ -91,6 +91,7 @@
             int y1 = (int) ( Math.sin(i) * 138.0 ) + 138;
             int x2 = (int) ( -Math.cos(i) * 160.0 ) + 160;
             int y2 = (int) ( -Math.sin(i) * 138.0 ) + 138;
+            g2d.setStroke(new BasicStroke(2));
             g2d.drawLine(x1,y1,x2,y2);
         }
         g2d.setFont(new Font("SansSerif",Font.BOLD | Font.ITALIC, 20));

Modified: 
jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java
URL: 
http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java?rev=398044&r1=398043&r2=398044&view=diff
==============================================================================
--- 
jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java 
(original)
+++ 
jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java 
Fri Apr 28 17:18:16 2006
@@ -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 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 @@
         this.background = background;
     }
 
-
+    HSSFShapeGroup getEscherGraphics()
+    {
+        return escherGroup;
+    }
 }
 

Modified: 
jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
URL: 
http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java?rev=398044&r1=398043&r2=398044&view=diff
==============================================================================
--- 
jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java 
(original)
+++ 
jakarta/poi/trunk/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java 
Fri Apr 28 17:18:16 2006
@@ -23,7 +23,10 @@
 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 @@
         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 @@
         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)));
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to