pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r782401 - in /incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer: SetLineWidth.java StrokePath.java
Date Sun, 07 Jun 2009 15:31:41 GMT
Author: lehmi
Date: Sun Jun  7 15:31:40 2009
New Revision: 782401

URL: http://svn.apache.org/viewvc?rev=782401&view=rev
Log:
PDFBOX-481: fixed the scaling of lines

Modified:
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SetLineWidth.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SetLineWidth.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SetLineWidth.java?rev=782401&r1=782400&r2=782401&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SetLineWidth.java
(original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SetLineWidth.java
Sun Jun  7 15:31:40 2009
@@ -19,7 +19,6 @@
 import java.util.List;
 import org.apache.pdfbox.pdfviewer.PageDrawer;
 import org.apache.pdfbox.util.PDFOperator;
-import org.apache.pdfbox.util.Matrix;
 
 import java.awt.BasicStroke;
 import java.awt.Graphics2D;
@@ -44,10 +43,9 @@
     {
         super.process( operator, arguments );
         float lineWidth = (float)context.getGraphicsState().getLineWidth();
-        Matrix ctm = context.getGraphicsState().getCurrentTransformationMatrix();
-        if ( ctm != null && ctm.getXScale() > 0 ) 
+        if (lineWidth == 0) 
         {
-            lineWidth = lineWidth * ctm.getXScale();
+        	lineWidth = 1;
         }
         Graphics2D graphics = ((PageDrawer)context).getGraphics();
         BasicStroke stroke = (BasicStroke)graphics.getStroke();

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java?rev=782401&r1=782400&r2=782401&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java
(original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java
Sun Jun  7 15:31:40 2009
@@ -18,8 +18,12 @@
 
 import java.util.List;
 import org.apache.pdfbox.pdfviewer.PageDrawer;
+import org.apache.pdfbox.util.Matrix;
 import org.apache.pdfbox.util.PDFOperator;
 import org.apache.pdfbox.util.operator.*;
+
+import java.awt.BasicStroke;
+import java.awt.Graphics2D;
 import java.io.IOException;
 
 /**
@@ -43,6 +47,21 @@
         ///dwilson 3/19/07 refactor
 	try{
 		PageDrawer drawer = (PageDrawer)context;
+
+        float lineWidth = (float)context.getGraphicsState().getLineWidth();
+        Matrix ctm = context.getGraphicsState().getCurrentTransformationMatrix();
+        if ( ctm != null && ctm.getXScale() > 0) 
+        {
+            lineWidth = lineWidth * ctm.getXScale();
+        }
+        Graphics2D graphics = ((PageDrawer)context).getGraphics();
+        BasicStroke stroke = (BasicStroke)graphics.getStroke();
+        if (stroke == null)
+            graphics.setStroke( new BasicStroke( lineWidth ) );
+        else
+            graphics.setStroke( new BasicStroke(lineWidth, stroke.getEndCap(), stroke.getLineJoin(),
stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase()) );
+
+		
 		drawer.StrokePath();
 	}catch (Exception e){
 



Mime
View raw message