pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1687387 - in /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools: gui/PDFTreeCellRenderer.java pdfdebugger/ui/OverlayIcon.java
Date Wed, 24 Jun 2015 22:42:09 GMT
Author: jahewson
Date: Wed Jun 24 22:42:09 2015
New Revision: 1687387

URL: http://svn.apache.org/r1687387
Log:
PDFBOX-2530: Move OverlayIcon to appease Sonar

Removed:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/ui/OverlayIcon.java
Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java?rev=1687387&r1=1687386&r2=1687387&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java
Wed Jun 24 22:42:09 2015
@@ -17,7 +17,10 @@
 package org.apache.pdfbox.tools.gui;
 
 import java.awt.Component;
+import java.awt.Graphics;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 import javax.swing.ImageIcon;
 import javax.swing.JTree;
 import javax.swing.tree.DefaultTreeCellRenderer;
@@ -31,7 +34,6 @@ import org.apache.pdfbox.cos.COSNull;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
-import org.apache.pdfbox.tools.pdfdebugger.ui.OverlayIcon;
 
 /**
  * A class to render tree cells for the pdfviewer.
@@ -255,4 +257,35 @@ public class PDFTreeCellRenderer extends
             return null;
         }
     }
+
+    /**
+     * An ImageIcon which allows other ImageIcon overlays.
+     */
+    private class OverlayIcon extends ImageIcon
+    {
+        private final ImageIcon base;
+        private final List<ImageIcon> overlays;
+
+        public OverlayIcon(ImageIcon base)
+        {
+            super(base.getImage());
+            this.base = base;
+            this.overlays = new ArrayList<ImageIcon>();
+        }
+
+        public void add(ImageIcon overlay)
+        {
+            overlays.add(overlay);
+        }
+
+        @Override
+        public synchronized void paintIcon(Component c, Graphics g, int x, int y)
+        {
+            base.paintIcon(c, g, x, y);
+            for (ImageIcon icon: overlays)
+            {
+                icon.paintIcon(c, g, x, y);
+            }
+        }
+    }
 }



Mime
View raw message