You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2009/06/20 15:29:07 UTC
svn commit: r786814 -
/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
Author: lehmi
Date: Sat Jun 20 13:29:07 2009
New Revision: 786814
URL: http://svn.apache.org/viewvc?rev=786814&view=rev
Log:
PDFBOX-487: increase rendering precision. Thanks to Volker Bier (volker dot bier at astrium dot eads dot net) for the hint
Modified:
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java?rev=786814&r1=786813&r2=786814&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java Sat Jun 20 13:29:07 2009
@@ -84,8 +84,10 @@
pageSize = pageDimension;
graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
+ graphics.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON );
// Only if there is some content, we have to process it. Otherwise we are done here and we will produce an empty page
- if ( page.getContents() != null) {
+ if ( page.getContents() != null)
+ {
PDResources resources = page.findResources();
processStream( page, resources, page.getContents().getStream() );
}
@@ -250,9 +252,12 @@
*/
public void setLinePath(GeneralPath newLinePath)
{
- if (linePath == null || linePath.getCurrentPoint() == null){
+ if (linePath == null || linePath.getCurrentPoint() == null)
+ {
linePath = newLinePath;
- }else{
+ }
+ else
+ {
linePath.append (newLinePath, false);
}
}
@@ -295,22 +300,24 @@
for( int i=0; i<subPaths.size(); i++ )
{
GeneralPath subPath = (GeneralPath)subPaths.get( i );
- if (subPath.getCurrentPoint() != null){ //Sector9's suggestion in bug 1672556
+ if (subPath.getCurrentPoint() != null)
+ { //Sector9's suggestion in bug 1672556
subPath.closePath();
}
graphics.fill( subPath );
}
-
graphics.fill( getLinePath() );
getLinePath().reset();
}
- public void setStroke(BasicStroke newStroke){
+ public void setStroke(BasicStroke newStroke)
+ {
getGraphics().setStroke( newStroke );
}
- public void StrokePath() throws IOException{
+ public void StrokePath() throws IOException
+ {
graphics.setColor( getGraphicsState().getStrokingColorSpace().createColor() ); //per Ben's 11/15 change in StrokePath.java
List subPaths = getLineSubPaths();
for( int i=0; i<subPaths.size(); i++ )
@@ -325,7 +332,8 @@
}
//If you need to do anything when a color changes, do it here ... or in an override of this function
- public void ColorChanged(boolean bStroking) throws IOException{
+ public void ColorChanged(boolean bStroking) throws IOException
+ {
//logger().info("changing " + (bStroking ? "" : "non") + "stroking color");
}
@@ -336,7 +344,8 @@
* @param x y-coordinate of the point to be transform
* @return the transformed coordinates as Point2D.Double
*/
- public java.awt.geom.Point2D.Double TransformedPoint (double x, double y){
+ public java.awt.geom.Point2D.Double TransformedPoint (double x, double y)
+ {
double[] position = {x,y};
getGraphicsState().getCurrentTransformationMatrix().createAffineTransform().transform(position, 0, position, 0, 1);
position[1] = fixY(position[1]);
@@ -349,7 +358,8 @@
/**
* @deprecated
*/
- public java.awt.geom.Point2D.Double ScaledPoint (double x, double y, double scaleX, double scaleY){
+ public java.awt.geom.Point2D.Double ScaledPoint (double x, double y, double scaleX, double scaleY)
+ {
double finalX = 0.0;
double finalY = 0.0;
@@ -369,7 +379,8 @@
/**
* @deprecated
*/
- public java.awt.geom.Point2D.Double ScaledPoint (double x, double y){
+ public java.awt.geom.Point2D.Double ScaledPoint (double x, double y)
+ {
double scaleX = 0.0;
double scaleY = 0.0;
@@ -389,10 +400,10 @@
*
* @param windingRule The winding rule this path will use.
*/
- public void SetClippingPath(int windingRule) throws IOException{
+ public void SetClippingPath(int windingRule) throws IOException
+ {
graphics.setColor( getGraphicsState().getNonStrokingColorSpace().createColor() );
-
getLinePath().setWindingRule(windingRule);
graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
@@ -400,12 +411,12 @@
for( int i=0; i<subPaths.size(); i++ )
{
GeneralPath subPath = (GeneralPath)subPaths.get( i );
- if (subPath.getCurrentPoint() != null){
+ if (subPath.getCurrentPoint() != null)
+ {
subPath.closePath();
}
}
-
- graphics.setClip( getLinePath() );
- getLinePath().reset();
+ graphics.setClip( getLinePath() );
+ getLinePath().reset();
}
}