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 2020/04/28 17:04:02 UTC

svn commit: r1877134 - /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java

Author: tilman
Date: Tue Apr 28 17:04:02 2020
New Revision: 1877134

URL: http://svn.apache.org/viewvc?rev=1877134&view=rev
Log:
PDFBOX-2941: simplify code

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

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java?rev=1877134&r1=1877133&r2=1877134&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java Tue Apr 28 17:04:02 2020
@@ -67,61 +67,61 @@ public class ToolTipController
     }
 
     /**
-     * Returns the tooltip text for the operator. null if there isn't any tooltip.
+     * Returns the tooltip text for the operator.
+     *
      * @param offset The position of the mouse in the text component.
      * @param textComponent JTextComponent instance.
-     * @return Tooltip text, String instance.
+     * @return Tooltip text or null if there isn't any tooltip.
      */
     public String getToolTip(int offset, JTextComponent textComponent)
     {
         this.textComponent = textComponent;
 
         String word = getWord(offset);
+        if (word == null)
+        {
+            return null;
+        }
+
         String rowText = getRowText(offset);
 
-        if (word != null)
+        ToolTip toolTip;
+        String colorSpaceName;
+        switch (word)
         {
-            ToolTip toolTip;
-            switch (word)
-            {
-                case OperatorName.SET_FONT_AND_SIZE:
-                    toolTip = new FontToolTip(resources, rowText);
-                    return toolTip.getToolTipText();
-                case OperatorName.STROKING_COLOR_N:
+            case OperatorName.SET_FONT_AND_SIZE:
+                toolTip = new FontToolTip(resources, rowText);
+                return toolTip.getToolTipText();
+            case OperatorName.STROKING_COLOR_N:
+                colorSpaceName = findColorSpace(offset, OperatorName.STROKING_COLORSPACE);
+                if (colorSpaceName != null)
                 {
-                    String colorSpaceName = findColorSpace(offset, OperatorName.STROKING_COLORSPACE);
-                    if (colorSpaceName != null)
-                    {
-                        toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
-                        return toolTip.getToolTipText();
-                    }
-                    break;
+                    toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
+                    return toolTip.getToolTipText();
                 }
-                case OperatorName.NON_STROKING_COLOR_N:
+                break;
+            case OperatorName.NON_STROKING_COLOR_N:
+                colorSpaceName = findColorSpace(offset, OperatorName.NON_STROKING_COLORSPACE);
+                if (colorSpaceName != null)
                 {
-                    String colorSpaceName = findColorSpace(offset, OperatorName.NON_STROKING_COLORSPACE);
-                    if (colorSpaceName != null)
-                    {
-                        toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
-                        return toolTip.getToolTipText();
-                    }
-                    break;
-                }
-                case OperatorName.STROKING_COLOR_RGB:
-                case OperatorName.NON_STROKING_RGB:
-                    toolTip = new RGToolTip(rowText);
-                    return toolTip.getToolTipText();
-                case OperatorName.STROKING_COLOR_CMYK:
-                case OperatorName.NON_STROKING_CMYK:
-                    toolTip = new KToolTip(rowText);
+                    toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
                     return toolTip.getToolTipText();
-                case OperatorName.STROKING_COLOR_GRAY:
-                case OperatorName.NON_STROKING_GRAY:
-                    toolTip = new GToolTip(rowText);
-                    return toolTip.getToolTipText();
-                default:
-                    break;
-            }
+                }
+                break;
+            case OperatorName.STROKING_COLOR_RGB:
+            case OperatorName.NON_STROKING_RGB:
+                toolTip = new RGToolTip(rowText);
+                return toolTip.getToolTipText();
+            case OperatorName.STROKING_COLOR_CMYK:
+            case OperatorName.NON_STROKING_CMYK:
+                toolTip = new KToolTip(rowText);
+                return toolTip.getToolTipText();
+            case OperatorName.STROKING_COLOR_GRAY:
+            case OperatorName.NON_STROKING_GRAY:
+                toolTip = new GToolTip(rowText);
+                return toolTip.getToolTipText();
+            default:
+                break;
         }
         return null;
     }