You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/04/04 00:38:22 UTC

svn commit: r1671191 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java

Author: tilman
Date: Fri Apr  3 22:38:22 2015
New Revision: 1671191

URL: http://svn.apache.org/r1671191
Log:
PDFBOX-2745: zoom value is a float; fix javadoc (-1 and 0 mean the same)

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java?rev=1671191&r1=1671190&r2=1671191&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java Fri Apr  3 22:38:22 2015
@@ -18,6 +18,8 @@ package org.apache.pdfbox.pdmodel.intera
 
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSFloat;
+import org.apache.pdfbox.cos.COSNumber;
 
 /**
  * This represents a destination to a page at an x,y coordinate with a zoom setting.
@@ -42,7 +44,6 @@ public class PDPageXYZDestination extend
         super();
         array.growToSize(5);
         array.setName( 1, TYPE );
-
     }
 
     /**
@@ -56,7 +57,7 @@ public class PDPageXYZDestination extend
     }
 
     /**
-     * Get the left x coordinate.  A return value of -1 implies that the current x-coordinate
+     * Get the left x coordinate.  Return values of 0 or -1 imply that the current x-coordinate
      * will be used.
      *
      * @return The left x coordinate.
@@ -67,7 +68,7 @@ public class PDPageXYZDestination extend
     }
 
     /**
-     * Set the left x-coordinate, a value of -1 implies that the current x-coordinate
+     * Set the left x-coordinate, values 0 or -1 imply that the current x-coordinate
      * will be used.
      * @param x The left x coordinate.
      */
@@ -85,7 +86,7 @@ public class PDPageXYZDestination extend
     }
 
     /**
-     * Get the top y coordinate.  A return value of -1 implies that the current y-coordinate
+     * Get the top y coordinate.  Return values of 0 or -1 imply that the current y-coordinate
      * will be used.
      *
      * @return The top y coordinate.
@@ -96,7 +97,7 @@ public class PDPageXYZDestination extend
     }
 
     /**
-     * Set the top y-coordinate, a value of -1 implies that the current y-coordinate
+     * Set the top y-coordinate, values 0 or -1 imply that the current y-coordinate
      * will be used.
      * @param y The top ycoordinate.
      */
@@ -114,22 +115,27 @@ public class PDPageXYZDestination extend
     }
 
     /**
-     * Get the zoom value.  A return value of -1 implies that the current zoom
+     * Get the zoom value.  Return values of 0 or -1 imply that the current zoom
      * will be used.
      *
      * @return The zoom value for the page.
      */
-    public int getZoom()
+    public float getZoom()
     {
-        return array.getInt( 4 );
+        COSBase obj = array.getObject(4);
+        if (obj instanceof COSNumber)
+        {
+            return ((COSNumber) obj).floatValue();
+        }
+        return -1;
     }
 
     /**
-     * Set the zoom value for the page, a value of -1 implies that the current zoom
+     * Set the zoom value for the page, values 0 or -1 imply that the current zoom
      * will be used.
      * @param zoom The zoom value.
      */
-    public void setZoom( int zoom )
+    public void setZoom( float zoom )
     {
         array.growToSize( 5 );
         if( zoom == -1 )
@@ -138,7 +144,7 @@ public class PDPageXYZDestination extend
         }
         else
         {
-            array.setInt( 4, zoom );
+            array.set( 4, new COSFloat(zoom) );
         }
     }
 }