Author: msahyoun
Date: Mon Feb 19 12:21:29 2018
New Revision: 1824744

URL: http://svn.apache.org/viewvc?rev=1824744&view=rev
Log:
PDFBOX-4071: use Float.compare for float comparison

Modified:
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDDefaultAppearanceString.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1824744&r1=1824743&r2=1824744&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
 Mon Feb 19 12:21:29 2018
@@ -306,7 +306,7 @@ class AppearanceGeneratorHelper
     
                 if (lineWidth > 0 && borderColour != null)
                 {
-                    if (lineWidth != 1)
+                    if (Float.compare(lineWidth, 1) != 0)
                     {
                         contents.setLineWidth(lineWidth);
                     }
@@ -415,7 +415,7 @@ class AppearanceGeneratorHelper
             // calculate the fontSize (because 0 = autosize)
             float fontSize = defaultAppearance.getFontSize();
             
-            if (fontSize == 0)
+            if (Float.compare(fontSize, 0) == 0)
             {
                 fontSize = calculateFontSize(font, contentRect);
             }
@@ -728,7 +728,7 @@ class AppearanceGeneratorHelper
         float fontSize = defaultAppearance.getFontSize();
         
         // zero is special, it means the text is auto-sized
-        if (fontSize == 0)
+        if (Float.compare(fontSize, 0) == 0)
         {
             if (isMultiLine())
             {

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1824744&r1=1824743&r2=1824744&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
 Mon Feb 19 12:21:29 2018
@@ -325,7 +325,8 @@ public final class PDAcroForm implements
                         PDRectangle bbox = appearanceStream.getBBox();
                         PDRectangle fieldRect = annotation.getRectangle();
                         
-                        if (bbox.getWidth() - fieldRect.getWidth() != 0 && 
bbox.getHeight() - fieldRect.getHeight() != 0)
+                        if (Float.compare(bbox.getWidth() - 
fieldRect.getWidth(), 0) != 0 && 
+                            Float.compare(bbox.getHeight() - 
fieldRect.getHeight(), 0) != 0)
                         {
                             float xScale = fieldRect.getWidth() / 
bbox.getWidth();
                             float yScale = fieldRect.getHeight() / 
bbox.getHeight();
@@ -730,7 +731,7 @@ public final class PDAcroForm implements
                         PDRectangle bbox = ((PDFormXObject)xObject).getBBox();
                         float llX = bbox.getLowerLeftX();
                         float llY = bbox.getLowerLeftY();
-                        if (llX == 0 && llY == 0)
+                        if (Float.compare(llX, 0) == 0 && Float.compare(llY, 
0) == 0)
                         {
                             needsTranslation = true;
                         }

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDDefaultAppearanceString.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDDefaultAppearanceString.java?rev=1824744&r1=1824743&r2=1824744&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDDefaultAppearanceString.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDDefaultAppearanceString.java
 Mon Feb 19 12:21:29 2018
@@ -289,7 +289,7 @@ class PDDefaultAppearanceString
     void writeTo(PDAppearanceContentStream contents, float zeroFontSize) 
throws IOException
     {
         float fontSize = getFontSize();
-        if (fontSize == 0)
+        if (Float.compare(fontSize, 0) == 0)
         {
             fontSize = zeroFontSize;
         }

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java?rev=1824744&r1=1824743&r2=1824744&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
 Mon Feb 19 12:21:29 2018
@@ -230,7 +230,7 @@ public class PDSignatureField extends PD
         {
             // check if the signature is visible
             if (widget.getRectangle() == null ||
-                widget.getRectangle().getHeight() == 0 && 
widget.getRectangle().getWidth() == 0 ||
+                Float.compare(widget.getRectangle().getHeight(), 0) == 0 && 
Float.compare(widget.getRectangle().getWidth(), 0) == 0 ||
                 widget.isNoView() ||  widget.isHidden())
             {
                 return;


Reply via email to