pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1697510 - in /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer: ASCIIPane.java AddressPane.java HexEditor.java HexPane.java HexView.java UpperPane.java
Date Mon, 24 Aug 2015 22:25:22 GMT
Author: jahewson
Date: Mon Aug 24 22:25:21 2015
New Revision: 1697510

URL: http://svn.apache.org/r1697510
Log:
PDFBOX-2941: High quality rendering of hex view, use system fonts/colors

Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/ASCIIPane.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/AddressPane.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexEditor.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexPane.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexView.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/UpperPane.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/ASCIIPane.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/ASCIIPane.java?rev=1697510&r1=1697509&r2=1697510&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/ASCIIPane.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/ASCIIPane.java
Mon Aug 24 22:25:21 2015
@@ -20,7 +20,9 @@ package org.apache.pdfbox.tools.pdfdebug
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
 import java.awt.Rectangle;
+import java.awt.RenderingHints;
 import javax.swing.JComponent;
 
 /**
@@ -52,6 +54,13 @@ class ASCIIPane extends JComponent imple
     protected void paintComponent(Graphics g)
     {
         super.paintComponent(g);
+
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        
         Rectangle bound = getVisibleRect();
 
         int x = HexView.LINE_INSET;

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/AddressPane.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/AddressPane.java?rev=1697510&r1=1697509&r2=1697510&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/AddressPane.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/AddressPane.java
Mon Aug 24 22:25:21 2015
@@ -20,7 +20,9 @@ package org.apache.pdfbox.tools.pdfdebug
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
 import java.awt.Rectangle;
+import java.awt.RenderingHints;
 import javax.swing.JComponent;
 
 /**
@@ -49,6 +51,13 @@ class AddressPane extends JComponent
     protected void paintComponent(Graphics g)
     {
         super.paintComponent(g);
+
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        
         Rectangle bound = getVisibleRect();
 
         int x = HexView.LINE_INSET;

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexEditor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexEditor.java?rev=1697510&r1=1697509&r2=1697510&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexEditor.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexEditor.java
Mon Aug 24 22:25:21 2015
@@ -17,6 +17,7 @@
 
 package org.apache.pdfbox.tools.pdfdebugger.hexviewer;
 
+import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.GridBagConstraints;
@@ -37,6 +38,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextField;
 import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
+import javax.swing.border.LineBorder;
 
 /**
  * @author Khyrul Bashar
@@ -97,6 +99,7 @@ class HexEditor extends JPanel implement
         panel.add(asciiPane);
 
         JScrollPane scrollPane = new JScrollPane();
+        scrollPane.setBorder(new LineBorder(Color.LIGHT_GRAY));
         scrollPane.setViewportView(panel);
 
         Action blankAction = new AbstractAction()

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexPane.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexPane.java?rev=1697510&r1=1697509&r2=1697510&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexPane.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexPane.java
Mon Aug 24 22:25:21 2015
@@ -20,8 +20,10 @@ package org.apache.pdfbox.tools.pdfdebug
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
 import java.awt.Point;
 import java.awt.Rectangle;
+import java.awt.RenderingHints;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseEvent;
@@ -73,6 +75,13 @@ class HexPane extends JPanel implements
     protected void paintComponent(Graphics g)
     {
         super.paintComponent(g);
+        
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        
         Rectangle bound = getVisibleRect();
         g.clearRect(bound.x, bound.y, bound.width, bound.height);
         g.setColor(Color.WHITE);
@@ -127,7 +136,7 @@ class HexPane extends JPanel implements
 
         if (selectedChar == 0)
         {
-            g.setColor(new Color(98, 134, 198));
+            g.setColor(HexView.SELECTED_COLOR);
             g.drawChars(chars, 0, 1, x, y);
 
             g.setColor(Color.black);
@@ -138,7 +147,7 @@ class HexPane extends JPanel implements
             g.setColor(Color.black);
             g.drawChars(chars, 0, 1, x, y);
 
-            g.setColor(new Color(98, 134, 198));
+            g.setColor(HexView.SELECTED_COLOR);
             g.drawChars(chars, 1, 1,x + g.getFontMetrics().charWidth(chars[0]), y);
         }
         setDefault(g);
@@ -148,7 +157,7 @@ class HexPane extends JPanel implements
     {
         AttributedString string = new AttributedString(str);
         string.addAttribute(TextAttribute.FONT, HexView.BOLD_FONT);
-        string.addAttribute(TextAttribute.FOREGROUND, new Color(98, 134, 198));
+        string.addAttribute(TextAttribute.FOREGROUND, HexView.SELECTED_COLOR);
         return string;
     }
 

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexView.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexView.java?rev=1697510&r1=1697509&r2=1697510&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexView.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/HexView.java
Mon Aug 24 22:25:21 2015
@@ -30,6 +30,7 @@ import javax.swing.BoxLayout;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JPanel;
+import javax.swing.UIManager;
 import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.tools.pdfdebugger.streampane.Stream;
 
@@ -43,12 +44,12 @@ public class HexView implements ActionLi
     private JComponent mainPane;
     private Stream stream;
 
-    static final Font FONT = new Font("monospaced", Font.PLAIN, 15);
+    static final Font FONT = new Font("monospaced", Font.PLAIN, 13);
     static final int CHAR_HEIGHT = 20;
     static final int CHAR_WIDTH = 35;
     static final int LINE_INSET = 20;
-    static final Color SELECTED_COLOR = new Color(98, 134, 198);
-    static final Font BOLD_FONT = new Font(Font.MONOSPACED, Font.BOLD, 15);
+    static final Color SELECTED_COLOR = UIManager.getColor("textHighlight");
+    static final Font BOLD_FONT = new Font("monospaced", Font.BOLD, 13);
     static final int HEX_PANE_WIDTH = 600;
     static final int ADDRESS_PANE_WIDTH = 120;
     static final int ASCII_PANE_WIDTH = 270;

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/UpperPane.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/UpperPane.java?rev=1697510&r1=1697509&r2=1697510&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/UpperPane.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/hexviewer/UpperPane.java
Mon Aug 24 22:25:21 2015
@@ -17,10 +17,13 @@
 
 package org.apache.pdfbox.tools.pdfdebugger.hexviewer;
 
+import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import javax.swing.BorderFactory;
 import javax.swing.JPanel;
-import javax.swing.border.BevelBorder;
 
 /**
  * @author Khyrul Bashar
@@ -31,15 +34,22 @@ class UpperPane extends JPanel
 {
     UpperPane()
     {
-        setFont(HexView.BOLD_FONT);
+        setFont(HexView.FONT);
         setPreferredSize(new Dimension(HexView.TOTAL_WIDTH, 20));
-        setBorder(new BevelBorder(BevelBorder.RAISED));
+        setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY));
     }
 
     @Override
     protected void paintComponent(Graphics g)
     {
         super.paintComponent(g);
+
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        
         int x = HexView.LINE_INSET-2;
         int y = 16;
 



Mime
View raw message