Author: tilman
Date: Sat May  9 15:36:50 2026
New Revision: 1933995

Log:
PDFBOX-5660: split file to have one class per file, to avoid warning about 
auxiliary class

Added:
   
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTip.java
      - copied, changed from r1933042, 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
Modified:
   
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java

Copied and modified: 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTip.java
 (from r1933042, 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java)
==============================================================================
--- 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
     Tue Apr 14 05:57:06 2026        (r1933042, copy source)
+++ 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTip.java
       Sat May  9 15:36:50 2026        (r1933995)
@@ -17,172 +17,7 @@
 
 package org.apache.pdfbox.debugger.streampane.tooltip;
 
-import java.util.ArrayList;
-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
 {
     String getToolTipText();
 }
-
-/**
- * @author Khyrul Bashar
- * A class that provides the tooltip for an operator.
- */
-public class ToolTipController
-{
-    private static final Log LOG = LogFactory.getLog(ToolTipController.class);
-
-    private final PDResources resources;
-    private JTextComponent textComponent;
-
-    /**
-     * Constructor.
-     * @param resources PDResources instance.
-     */
-    public ToolTipController(PDResources resources)
-    {
-        this.resources = resources;
-    }
-
-    static List<String> getWords(String str)
-    {
-        List<String> words = new ArrayList<String>();
-        for (String string : str.trim().split(" "))
-        {
-            string = string.trim();
-            if (!string.isEmpty() && !string.equals("\n"))
-            {
-                words.add(string);
-            }
-        }
-        return words;
-    }
-
-    /**
-     * Returns the tooltip text for the operator. null if there isn't any 
tooltip.
-     * @param offset The position of the mouse in the text component.
-     * @param textComponent JTextComponent instance.
-     * @return Tooltip text, String instance.
-     */
-    public String getToolTip(int offset, JTextComponent textComponent)
-    {
-        this.textComponent = textComponent;
-
-        String word = getWord(offset);
-        String rowText = getRowText(offset);
-
-        if (word != null)
-        {
-            ToolTip toolTip;
-            if (word.equals(OperatorName.SET_FONT_AND_SIZE))
-            {
-                toolTip = new FontToolTip(resources, rowText);
-                return toolTip.getToolTipText();
-            }
-            else if (word.equals(OperatorName.STROKING_COLOR_N))
-            {
-                String colorSpaceName = findColorSpace(offset, 
OperatorName.STROKING_COLORSPACE);
-                if (colorSpaceName != null)
-                {
-                    toolTip = new SCNToolTip(resources, colorSpaceName, 
rowText);
-                    return toolTip.getToolTipText();
-                }
-            }
-            else if (word.equals(OperatorName.NON_STROKING_COLOR_N))
-            {
-                String colorSpaceName = findColorSpace(offset, 
OperatorName.NON_STROKING_COLORSPACE);
-                if (colorSpaceName != null)
-                {
-                    toolTip = new SCNToolTip(resources, colorSpaceName, 
rowText);
-                    return toolTip.getToolTipText();
-                }
-            }
-            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(OperatorName.STROKING_COLOR_CMYK) || 
word.equals(OperatorName.NON_STROKING_CMYK))
-            {
-                toolTip = new KToolTip(rowText);
-                return toolTip.getToolTipText();
-            }
-            else if (word.equals(OperatorName.STROKING_COLOR_GRAY) || 
word.equals(OperatorName.NON_STROKING_GRAY))
-            {
-                toolTip = new GToolTip(rowText);
-                return toolTip.getToolTipText();
-            }
-        }
-        return null;
-    }
-
-    private String findColorSpace(int offset, String colorSpaceType)
-    {
-        try
-        {
-            while (offset != -1)
-            {
-                offset = Utilities.getPositionAbove(textComponent, offset, 0);
-                String previousRowText = getRowText(offset);
-                if (previousRowText == null)
-                {
-                    return null;
-                }
-                previousRowText = previousRowText.trim();
-                if (isColorSpace(colorSpaceType, previousRowText))
-                {
-                    return previousRowText.split(" ")[0];
-                }
-            }
-        }
-        catch (BadLocationException e)
-        {
-            LOG.error(e, e);
-        }
-        return null;
-    }
-
-    private boolean isColorSpace(String colorSpaceType, String rowText)
-    {
-        List<String> words = getWords(rowText);
-        return words.size() == 2 && words.get(1).equals(colorSpaceType);
-    }
-
-    private String getWord(int offset)
-    {
-        try
-        {
-            int start = Utilities.getWordStart(textComponent, offset);
-            int end = Utilities.getWordEnd(textComponent, offset);
-            return textComponent.getDocument().getText(start, end - start + 
1).trim();
-        }
-        catch (BadLocationException e)
-        {
-            LOG.error(e, e);
-        }
-        return null;
-    }
-
-    private String getRowText(int offset)
-    {
-        try
-        {
-            int rowStart = Utilities.getRowStart(textComponent, offset);
-            int rowEnd = Utilities.getRowEnd(textComponent, offset);
-            return textComponent.getDocument().getText(rowStart, rowEnd - 
rowStart + 1);
-        }
-        catch (BadLocationException e)
-        {
-            LOG.error(e, e);
-        }
-        return null;
-    }
-}

Modified: 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
==============================================================================
--- 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
     Sat May  9 15:36:44 2026        (r1933994)
+++ 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/tooltip/ToolTipController.java
     Sat May  9 15:36:50 2026        (r1933995)
@@ -27,11 +27,6 @@ import org.apache.commons.logging.LogFac
 import org.apache.pdfbox.contentstream.operator.OperatorName;
 import org.apache.pdfbox.pdmodel.PDResources;
 
-interface ToolTip
-{
-    String getToolTipText();
-}
-
 /**
  * @author Khyrul Bashar
  * A class that provides the tooltip for an operator.

Reply via email to