You are not logged in.

#1 2006-02-06 16:56:26

aquila_deus
Member
From: Taipei
Registered: 2005-07-02
Posts: 348
Website

java swing hack!

Get src.zip from jdk, extract following files (inside parens), patch, and run:
1.zip -r /opt/java/jre/lib/rt.jar javax com -x "*.java"
2.java -Xshare:dump


JComponent.patch (javax/swing/JComponent.java) :
  Force anti-aliasing text

JPopupMenu.patch (javax/swing/JPopupMenu.java) :
  Make all popup/menu heavy-weight, so you can always see shadow behind them by compositor (if exists)

DefaultMetalTheme.patch (javax/swing/plaf/metal/DefaultMetalTheme.java) :
  Change default UI font styles to plain
  Change default UI font sizes to 13 and 12 (small)

MetalLookAndFeel.patch (javax/swing/plaf/metal/MetalLookAndFeel.java) :
  Force swing Ocean theme when -Dswing.ocean=true

MetalTheme.patch (javax/swing/plaf/metal/MetalTheme.java) :
  Change default text color to #002040, which makes blurred text to look better.

OceanTheme.patch (javax/swing/plaf/metal/OceanTheme.java) :
  Change default background color to #F5F5F5 (just to fit my gtk theme), and default text color to #002040.

SwingUtilities2.patch (com/sun/java/swing/SwingUtilities2.java) :
  force swing.aatext=true, to avoid weird problem with JComponent patch


JComponent.patch

--- javax/swing/JComponent.java.old    2005-11-11 02:20:00.000000000 +0800
+++ javax/swing/JComponent.java    2006-01-05 12:02:28.000000000 +0800
@@ -738,6 +738,16 @@
     protected void paintComponent(Graphics g) {
         if (ui != null) {
             Graphics scratchGraphics = (g == null) ? null : g.create();
+            Graphics2D g2d = (Graphics2D) g;
+            g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+            g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+            g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+            //g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+            g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+            g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+            g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+            g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
             try {
                 ui.update(scratchGraphics, this);
             }
@@ -4934,6 +4944,16 @@
                                       int clipX, int clipY, int clipW, int clipH, 
                       Image offscreen) {
         Graphics og = offscreen.getGraphics();
+        Graphics2D g2d = (Graphics2D) og;
+        g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+        g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+        //g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
         Graphics osg = (og == null) ? null : og.create();
     og.dispose();
         int bw = offscreen.getWidth(null);

JPopupMenu.patch

--- javax/swing/JPopupMenu.java.old    2005-11-11 02:20:00.000000000 +0800
+++ javax/swing/JPopupMenu.java    2006-01-05 12:03:17.000000000 +0800
@@ -822,10 +822,10 @@
         PopupFactory popupFactory = PopupFactory.getSharedInstance();
 
         if (isLightWeightPopupEnabled()) {
-            popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
+            popupFactory.setPopupType(PopupFactory.HEAVY_WEIGHT_POPUP);
         }
         else {
-            popupFactory.setPopupType(PopupFactory.MEDIUM_WEIGHT_POPUP);
+            popupFactory.setPopupType(PopupFactory.HEAVY_WEIGHT_POPUP);
         }
 
         // adjust the location of the popup
@@ -836,7 +836,7 @@
         Popup newPopup = getUI().getPopup(this, desiredLocationX,
                                           desiredLocationY);
 
-        popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
+        popupFactory.setPopupType(PopupFactory.HEAVY_WEIGHT_POPUP);
         newPopup.show();
         return newPopup;
     }

DefaultMetalTheme.patch

--- javax/swing/plaf/metal/DefaultMetalTheme.java.old    2005-11-11 02:20:00.000000000 +0800
+++ javax/swing/plaf/metal/DefaultMetalTheme.java    2006-02-03 17:14:59.000000000 +0800
@@ -46,13 +46,13 @@
      * <code>swing.boldMetal</code> is false, or PLAIN_FONTS is true.
      */
     private static final int[] fontStyles = {
-        Font.BOLD, Font.PLAIN, Font.PLAIN, Font.BOLD, Font.BOLD, Font.PLAIN
+        Font.PLAIN, Font.PLAIN, Font.PLAIN, Font.PLAIN, Font.PLAIN, Font.PLAIN
     };
     /**
      * Sizes for the fonts.
      */
     private static final int[] fontSizes = {
-        12, 12, 12, 12, 12, 10
+        13, 13, 13, 13, 13, 12
     };
 
     // note the properties listed here can currently be used by people

MetalLookAndFeel.patch

--- javax/swing/plaf/metal/MetalLookAndFeel.java.old    2005-11-11 02:20:00.000000000 +0800
+++ javax/swing/plaf/metal/MetalLookAndFeel.java    2006-01-30 02:25:32.000000000 +0800
@@ -1450,6 +1450,10 @@
         if (theme == null) {
             throw new NullPointerException("Can't have null theme");
         }
+        if (System.getProperty("swing.ocean") != null
+            && System.getProperty("swing.ocean").equals("true"))
+          currentTheme = new OceanTheme();
+        else
         currentTheme = theme;
     cachedAppContext = AppContext.getAppContext();
     cachedAppContext.put( "currentMetalTheme", theme );

MetalTheme.patch

--- javax/swing/plaf/metal/MetalTheme.java.old    2005-11-11 02:20:00.000000000 +0800
+++ javax/swing/plaf/metal/MetalTheme.java    2006-02-03 16:36:13.000000000 +0800
@@ -30,7 +30,7 @@
     static final int SUB_TEXT_FONT = 5;
 
     static ColorUIResource white = new ColorUIResource( 255, 255, 255 );
-    private static ColorUIResource black = new ColorUIResource( 0, 0, 0 );
+    private static ColorUIResource black = new ColorUIResource( 0, 32, 64 );
 
     public abstract String getName();
 

OceanTheme.patch

--- javax/swing/plaf/metal/OceanTheme.java.old    2005-11-11 02:20:00.000000000 +0800
+++ javax/swing/plaf/metal/OceanTheme.java    2006-02-03 17:22:03.000000000 +0800
@@ -40,16 +40,16 @@
     private static final ColorUIResource SECONDARY2 =
                               new ColorUIResource(0xB8CFE5);
     private static final ColorUIResource SECONDARY3 =
-                              new ColorUIResource(0xEEEEEE);
+                              new ColorUIResource(0xF5F5F5);
 
     private static final ColorUIResource CONTROL_TEXT_COLOR =
-                              new PrintColorUIResource(0x333333, Color.BLACK);
+                              new ColorUIResource(0x002040);
     private static final ColorUIResource INACTIVE_CONTROL_TEXT_COLOR =
                               new ColorUIResource(0x999999);
     private static final ColorUIResource MENU_DISABLED_FOREGROUND =
                               new ColorUIResource(0x999999);
     private static final ColorUIResource OCEAN_BLACK =
-                              new PrintColorUIResource(0x333333, Color.BLACK);
+                              new ColorUIResource(0x002040);
 
     // ComponentOrientation Icon
     // Delegates to different icons based on component orientation

SwingUtilities2.patch

--- com/sun/java/swing/SwingUtilities2.java.old    2005-11-11 02:20:00.000000000 +0800
+++ com/sun/java/swing/SwingUtilities2.java    2006-01-30 02:18:23.000000000 +0800
@@ -112,8 +112,8 @@
         fontCache = new LSBCacheEntry[CACHE_SIZE];
         Object aa = java.security.AccessController.doPrivileged(
                new GetPropertyAction("swing.aatext"));
-        AA_TEXT_DEFINED = (aa != null);
-        AA_TEXT = "true".equals(aa);
+        AA_TEXT_DEFINED = true;
+        AA_TEXT = true;
         AA_FRC = new FontRenderContext(null, true, false);
 
         Object dragFix = java.security.AccessController.doPrivileged(

my source & patch is at: http://www.aqd.ath.cx/code-public/java15/


tested with:
- Aqua Data Studio 4.5.2
- ArgoUML 0.18.1 (with -Dswing.ocean=true)
- DbVisualizer 4.3.6
- Fsgrep 2.0.0
- SmartSVN 1.1.7 (with -Dswing.ocean=true)
- X-develop 1.2 build 1007


Cheers!

Offline

Board footer

Powered by FluxBB