pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1865303 - /pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
Date Fri, 16 Aug 2019 15:01:18 GMT
Author: tilman
Date: Fri Aug 16 15:01:17 2019
New Revision: 1865303

URL: http://svn.apache.org/viewvc?rev=1865303&view=rev
Log:
PDFBOX-4071: use constants; improve logging; fix typo

Modified:
    pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java

Modified: pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java?rev=1865303&r1=1865302&r2=1865303&view=diff
==============================================================================
--- pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
(original)
+++ pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
Fri Aug 16 15:01:17 2019
@@ -22,6 +22,9 @@ import java.util.List;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.JTextComponent;
 import javax.swing.text.Utilities;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.contentstream.operator.OperatorName;
 import org.apache.pdfbox.pdmodel.PDResources;
 
 interface ToolTip
@@ -31,21 +34,11 @@ interface ToolTip
 
 /**
  * @author Khyrul Bashar
- * A class that provieds the tooltip for an operator.
+ * A class that provides the tooltip for an operator.
  */
 public class ToolTipController
 {
-    private static final  String FONT_OPERATOR = "Tf";
-    private static final String STROKING_COLOR = "SCN";
-    private static final String STROKING_COLOR_SPACE = "CS";
-    private static final String NON_STROKING_COLOR_SPACE = "cs";
-    private static final String NON_STROKING_COLOR = "scn";
-    private static final String RGB_STROKING_COLOR = "RG";
-    private static final String RGB_NON_STROKING_COLOR = "rg";
-    private static final String CMYK_STROKING_COLOR = "K";
-    private static final String CMYK_NON_STROKING_COLOR = "k";
-    private static final String GRAY_STROKING_COLOR = "G";
-    private static final String GRAY_NON_STROKING_COLOR = "g";
+    private static final Log LOG = LogFactory.getLog(ToolTipController.class);
 
     private final PDResources resources;
     private JTextComponent textComponent;
@@ -89,40 +82,40 @@ public class ToolTipController
         if (word != null)
         {
             ToolTip toolTip;
-            if (word.equals(FONT_OPERATOR))
+            if (word.equals(OperatorName.SET_FONT_AND_SIZE))
             {
                 toolTip = new FontToolTip(resources, rowText);
                 return toolTip.getToolTipText();
             }
-            else if (word.equals(STROKING_COLOR))
+            else if (word.equals(OperatorName.STROKING_COLOR_N))
             {
-                String colorSpaceName = findColorSpace(offset, STROKING_COLOR_SPACE);
+                String colorSpaceName = findColorSpace(offset, OperatorName.STROKING_COLORSPACE);
                 if (colorSpaceName != null)
                 {
                     toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
                     return toolTip.getToolTipText();
                 }
             }
-            else if (word.equals(NON_STROKING_COLOR))
+            else if (word.equals(OperatorName.NON_STROKING_COLOR_N))
             {
-                String colorSpaceName = findColorSpace(offset, NON_STROKING_COLOR_SPACE);
+                String colorSpaceName = findColorSpace(offset, OperatorName.NON_STROKING_COLORSPACE);
                 if (colorSpaceName != null)
                 {
                     toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
                     return toolTip.getToolTipText();
                 }
             }
-            else if (word.equals(RGB_STROKING_COLOR) || word.equals(RGB_NON_STROKING_COLOR))
+            else if (word.equals(OperatorName.STROKING_COLOR_RGB) || word.equals(OperatorName.NON_STROKING_RGB))
             {
                 toolTip = new RGToolTip(rowText);
                 return toolTip.getToolTipText();
             }
-            else if (word.equals(CMYK_STROKING_COLOR) || word.equals(CMYK_NON_STROKING_COLOR))
+            else if (word.equals(OperatorName.STROKING_COLOR_CMYK) || word.equals(OperatorName.NON_STROKING_CMYK))
             {
                 toolTip = new KToolTip(rowText);
                 return toolTip.getToolTipText();
             }
-            else if (word.equals(GRAY_STROKING_COLOR) || word.equals(GRAY_NON_STROKING_COLOR))
+            else if (word.equals(OperatorName.STROKING_COLOR_GRAY) || word.equals(OperatorName.NON_STROKING_GRAY))
             {
                 toolTip = new GToolTip(rowText);
                 return toolTip.getToolTipText();
@@ -152,8 +145,7 @@ public class ToolTipController
         }
         catch (BadLocationException e)
         {
-            e.printStackTrace();
-            return null;
+            LOG.error(e, e);
         }
         return null;
     }
@@ -174,7 +166,7 @@ public class ToolTipController
         }
         catch (BadLocationException e)
         {
-            e.printStackTrace();
+            LOG.error(e, e);
         }
         return null;
     }
@@ -189,7 +181,7 @@ public class ToolTipController
         }
         catch (BadLocationException e)
         {
-            e.printStackTrace();
+            LOG.error(e, e);
         }
         return null;
     }



Mime
View raw message