[hg] main-silver: #225542 - dark color theme for Metal and Nimbu...

  • From: "S. Aubrecht" < >
  • To: , ,
  • Subject: [hg] main-silver: #225542 - dark color theme for Metal and Nimbu...
  • Date: Fri, 01 Feb 2013 04:28:57 -0800

changeset 1df8daf75020 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/1df8daf75020
description:
        #225542 - dark color theme for Metal and Nimbus l&f

diffstat:

 editor/src/org/netbeans/modules/editor/NbEditorToolBar.java            |    
4 +-
 o.n.swing.plaf/apichanges.xml                                          |   
18 +
 o.n.swing.plaf/manifest.mf                                             |    
2 +-
 o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java                |   
21 +-
 o.n.swing.plaf/src/org/netbeans/swing/plaf/metal/DarkMetalTheme.java   |  
115 +++++++++
 o.n.swing.plaf/src/org/netbeans/swing/plaf/nimbus/DarkNimbusTheme.java |   
72 +++++
 o.n.swing.plaf/src/org/netbeans/swing/plaf/util/DarkIconFilter.java    |   
88 +++++++
 o.n.swing.plaf/src/org/netbeans/swing/plaf/util/NbTheme.java           |    
5 +-
 openide.awt/src/org/openide/awt/CloseButtonFactory.java                |  
122 +++++-----
 openide.awt/src/org/openide/awt/HtmlLabelUI.java                       |    
6 +-
 openide.util/src/org/openide/util/ImageUtilities.java                  |   
23 +-
 11 files changed, 405 insertions(+), 71 deletions(-)

diffs (759 lines):

diff --git a/editor/src/org/netbeans/modules/editor/NbEditorToolBar.java 
b/editor/src/org/netbeans/modules/editor/NbEditorToolBar.java
--- a/editor/src/org/netbeans/modules/editor/NbEditorToolBar.java
+++ b/editor/src/org/netbeans/modules/editor/NbEditorToolBar.java
@@ -562,9 +562,9 @@
         if (icon == null) {
             String resourceId = 
(String)a.getValue(BaseAction.ICON_RESOURCE_PROPERTY);
             if (resourceId != null) {
-                Image img = ImageUtilities.loadImage(resourceId);
+                ImageIcon img = ImageUtilities.loadImageIcon(resourceId, 
true);
                 if (img != null) {
-                    a.putValue(Action.SMALL_ICON, new ImageIcon(img));
+                    a.putValue(Action.SMALL_ICON, img);
                 }
             }
         }
diff --git a/o.n.swing.plaf/apichanges.xml b/o.n.swing.plaf/apichanges.xml
--- a/o.n.swing.plaf/apichanges.xml
+++ b/o.n.swing.plaf/apichanges.xml
@@ -49,6 +49,24 @@
     <apidef name="plaf">Look And Feel Customization</apidef>
 </apidefs>
 <changes>
+    <change id="dark-theme">
+        <api name="plaf"/>
+        <summary>Support for dark theme fro Metal and Nimbus look and 
feel.</summary>
+        <version major="1" minor="32"/>
+        <date day="31" month="1" year="2013"/>
+        <author login="saubrecht"/>
+        <compatibility
+            addition="yes"
+            binary="compatible" deletion="no" deprecation="no"
+            modification="no" semantic="compatible" source="compatible"
+        />
+        <description>
+            <p>When using Nimbus or Metal look and feel then system property
+                netbeans.plaf.dark.theme=true will switch to dark color theme
+                which nicely fits to 'Norway Today' editor color schema.
+            </p>
+        </description>
+    </change>
     <change id="windows8-lfcustoms">
         <api name="plaf"/>
         <summary>New look and feel customizations for Windows 8</summary>
diff --git a/o.n.swing.plaf/manifest.mf b/o.n.swing.plaf/manifest.mf
--- a/o.n.swing.plaf/manifest.mf
+++ b/o.n.swing.plaf/manifest.mf
@@ -1,6 +1,6 @@
 Manifest-Version: 1.0
 OpenIDE-Module-Localizing-Bundle: org/netbeans/swing/plaf/Bundle.properties
 OpenIDE-Module: org.netbeans.swing.plaf
-OpenIDE-Module-Specification-Version: 1.31
+OpenIDE-Module-Specification-Version: 1.32
 AutoUpdate-Show-In-Client: false
 
diff --git a/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java 
b/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java
--- a/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java
+++ b/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java
@@ -44,6 +44,7 @@
 
 package org.netbeans.swing.plaf;
 
+import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
 import java.awt.Toolkit;
 import java.util.logging.Logger;
 import org.netbeans.swing.plaf.aqua.AquaLFCustoms;
@@ -63,6 +64,8 @@
 import java.util.HashSet;
 import java.util.ResourceBundle;
 import java.util.Set;
+import org.netbeans.swing.plaf.metal.DarkMetalTheme;
+import org.netbeans.swing.plaf.nimbus.DarkNimbusTheme;
 import org.netbeans.swing.plaf.nimbus.NimbusLFCustoms;
 import org.netbeans.swing.plaf.winclassic.WindowsLFCustoms;
 import org.netbeans.swing.plaf.windows8.Windows8LFCustoms;
@@ -88,6 +91,8 @@
      */
     private static final boolean NO_CUSTOMIZATIONS = 
Boolean.getBoolean("netbeans.plaf.disable.ui.customizations"); //NOI18N
 
+    private static final boolean USE_DARK_THEME = 
Boolean.getBoolean("netbeans.plaf.dark.theme"); //NOI18N
+
     /** Constant for Nimbus L&F name */
     private static final String NIMBUS="Nimbus";
 
@@ -114,15 +119,19 @@
      */
     private void initialize() {
         LookAndFeel lf = getLookAndFeel();
+        boolean forceLaf = false;
         if (lf instanceof MetalLookAndFeel) {
             //Metal theme must be assigned before using the look and feel
-            installTheme(lf);
+            forceLaf = installTheme(lf);
+        } else if(lf instanceof NimbusLookAndFeel && USE_DARK_THEME) {
+            DarkNimbusTheme.install( lf );
+            forceLaf = true;
         }
         // overall defaults for all LFs
         // defaults for supported LFs
 
         try {
-            if (lf != UIManager.getLookAndFeel()) {
+            if (lf != UIManager.getLookAndFeel() || forceLaf) {
                 UIManager.setLookAndFeel (lf);
             }
         } catch (Exception e) {
@@ -217,12 +226,18 @@
         return uiClassName;
     }
 
-    private void installTheme(LookAndFeel lf) {
+    private boolean installTheme(LookAndFeel lf) {
+        boolean themeInstalled = false;
         //Load the theme
         if (themeURL != null) {
+            themeInstalled = true;
           NbTheme nbTheme = new NbTheme(themeURL, lf);
           MetalLookAndFeel.setCurrentTheme(nbTheme);
+        } else if( USE_DARK_THEME ) {
+            MetalLookAndFeel.setCurrentTheme( new DarkMetalTheme() );
+            themeInstalled = true;
         }
+        return themeInstalled;
     }
 
     /** Enables, installs LF customization.  */
diff --git 
a/o.n.swing.plaf/src/org/netbeans/swing/plaf/metal/DarkMetalTheme.java 
b/o.n.swing.plaf/src/org/netbeans/swing/plaf/metal/DarkMetalTheme.java
new file mode 100644
--- /dev/null
+++ b/o.n.swing.plaf/src/org/netbeans/swing/plaf/metal/DarkMetalTheme.java
@@ -0,0 +1,115 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.swing.plaf.metal;
+
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+import org.netbeans.swing.plaf.util.DarkIconFilter;
+
+/**
+ *
+ * @author S. Aubrecht, P. Somol
+ */
+public class DarkMetalTheme extends DefaultMetalTheme {
+
+    private final ColorUIResource primary1 = new ColorUIResource( 121, 121, 
125 );
+    private final ColorUIResource primary2 = new ColorUIResource( 71, 71, 75 
);
+    private final ColorUIResource primary3 = new ColorUIResource( 99, 99, 99 
);
+    private final ColorUIResource secondary1 = new ColorUIResource( 113, 
113, 113 );
+    private final ColorUIResource secondary2 = new ColorUIResource( 91, 91, 
95 );
+    private final ColorUIResource secondary3 = new ColorUIResource( 51, 51, 
55 );
+    private final ColorUIResource black = new ColorUIResource( 222, 222, 222 
);
+    private final ColorUIResource white = new ColorUIResource( 18, 30, 49 );
+
+    @Override
+    public String getName() {
+        return "NetBeans Dark Theme";
+    }
+
+    @Override
+    public void addCustomEntriesToTable( UIDefaults table ) {
+        super.addCustomEntriesToTable( table );
+        table.put( "nb.imageicon.filter", new DarkIconFilter() ); //NOI18N
+    }
+
+    @Override
+    protected ColorUIResource getPrimary1() {
+        return primary1;
+    }
+
+    @Override
+    protected ColorUIResource getPrimary2() {
+        return primary2;
+    }
+
+    @Override
+    protected ColorUIResource getPrimary3() {
+        return primary3;
+    }
+
+    @Override
+    protected ColorUIResource getSecondary1() {
+        return secondary1;
+    }
+
+    @Override
+    protected ColorUIResource getSecondary2() {
+        return secondary2;
+    }
+
+    @Override
+    protected ColorUIResource getSecondary3() {
+        return secondary3;
+    }
+
+    @Override
+    protected ColorUIResource getWhite() {
+        return white;
+    }
+
+    @Override
+    protected ColorUIResource getBlack() {
+        return black;
+    }
+}
diff --git 
a/o.n.swing.plaf/src/org/netbeans/swing/plaf/nimbus/DarkNimbusTheme.java 
b/o.n.swing.plaf/src/org/netbeans/swing/plaf/nimbus/DarkNimbusTheme.java
new file mode 100644
--- /dev/null
+++ b/o.n.swing.plaf/src/org/netbeans/swing/plaf/nimbus/DarkNimbusTheme.java
@@ -0,0 +1,72 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.swing.plaf.nimbus;
+
+import java.awt.Color;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import org.netbeans.swing.plaf.util.DarkIconFilter;
+
+/**
+ *
+ * @author S. Aubrecht
+ */
+public class DarkNimbusTheme {
+
+    public static void install( LookAndFeel laf ) {
+        UIManager.put( "control", new Color( 128, 128, 128) );
+        UIManager.put( "info", new Color(128,128,128) );
+        UIManager.put( "nimbusBase", new Color( 18, 30, 49) );
+        UIManager.put( "nimbusAlertYellow", new Color( 248, 187, 0) );
+        UIManager.put( "nimbusDisabledText", new Color( 128, 128, 128) );
+        UIManager.put( "nimbusFocus", new Color(115,164,209) );
+        UIManager.put( "nimbusGreen", new Color(176,179,50) );
+        UIManager.put( "nimbusInfoBlue", new Color( 66, 139, 221) );
+        UIManager.put( "nimbusLightBackground", new Color( 18, 30, 49) );
+        UIManager.put( "nimbusOrange", new Color(191,98,4) );
+        UIManager.put( "nimbusRed", new Color(169,46,34) );
+        UIManager.put( "nimbusSelectedText", new Color( 255, 255, 255) );
+        UIManager.put( "nimbusSelectionBackground", new Color( 104, 93, 156) 
);
+        UIManager.put( "text", new Color( 230, 230, 230) );
+        UIManager.put( "nb.imageicon.filter", new DarkIconFilter() );
+    }
+}
diff --git 
a/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/DarkIconFilter.java 
b/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/DarkIconFilter.java
new file mode 100644
--- /dev/null
+++ b/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/DarkIconFilter.java
@@ -0,0 +1,88 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.swing.plaf.util;
+
+import java.awt.Color;
+import java.awt.image.RGBImageFilter;
+
+/**
+ * For dark LaFs it inverts icon brightness (=inverts icon image to obtain 
dark icon,
+ * then inverts its hue to restore original colors).
+ * 
+ * @author P. Somol
+ */
+public class DarkIconFilter extends RGBImageFilter {
+
+    /** in dark LaFs brighten all icons; 0.0f = no change, 1.0f = maximum 
brightening */
+    private static final float DARK_ICON_BRIGHTEN = 0.1f;
+
+    @Override
+    public int filterRGB(int x, int y, int color) {
+        int a = color & 0xff000000;
+        int rgb[] = decode(color);
+        int inverted[] = invert(rgb);
+        int result[] = invertHueBrighten(inverted, DARK_ICON_BRIGHTEN);
+        return a | encode(result);
+   }
+
+    private int[] invert(int[] rgb) {
+        return new int[]{255-rgb[0], 255-rgb[1], 255-rgb[2]};
+    }
+
+    private int[] invertHueBrighten(int[] rgb, float brighten) {
+        float hsb[] = new float[3];
+        Color.RGBtoHSB(rgb[0], rgb[1], rgb[2], hsb);
+        return decode(Color.HSBtoRGB(hsb[0] > 0.5f ? hsb[0]-0.5f : 
hsb[0]+0.5f, hsb[1], hsb[2]+(1.0f-hsb[2])*brighten));
+    }
+
+    private int[] decode(int rgb) {
+        return new int[]{(rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, 
rgb & 0x000000ff};
+    }
+    private int encode(int[] rgb) {
+        return (toBoundaries(rgb[0]) << 16) | (toBoundaries(rgb[1]) << 8) | 
toBoundaries(rgb[2]);
+    }
+
+    private int toBoundaries(int color) {
+        return Math.max(0,Math.min(255,color));
+    }
+
+}
diff --git a/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/NbTheme.java 
b/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/NbTheme.java
--- a/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/NbTheme.java
+++ b/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/NbTheme.java
@@ -61,6 +61,7 @@
 import java.net.URL;
 import java.util.HashSet;
 import java.util.StringTokenizer;
+import javax.swing.plaf.metal.DefaultMetalTheme;
 
 /** An extension of javax.swing.plaf.metal.DefaultMetalTheme which can read 
a an xml
  * file named <code>themes.xml</code> and apply the theme defined in XML.  
NbTheme
@@ -79,7 +80,7 @@
  * @author Jiri Mzourek, Tim Boudreau
  * @see http://ui.netbeans.org/docs/ui/themes/themes.html
  */
-public class NbTheme extends MetalTheme implements 
org.xml.sax.DocumentHandler {
+public class NbTheme extends DefaultMetalTheme implements 
org.xml.sax.DocumentHandler {
     
     /** The unqualified name for the theme file to use. */    
     public static final  String THEMEFILE_NAME = "themes.xml"; // NOI18N
@@ -150,7 +151,7 @@
     public NbTheme(URL themeURL, LookAndFeel lf) {
         this.themeURL = themeURL;
         defaults = lf.getDefaults();
-        initThemeDefaults();
+//        initThemeDefaults();
         parseTheme();
         UIManager.getDefaults().putAll (defaults);
     }
diff --git a/openide.awt/src/org/openide/awt/CloseButtonFactory.java 
b/openide.awt/src/org/openide/awt/CloseButtonFactory.java
--- a/openide.awt/src/org/openide/awt/CloseButtonFactory.java
+++ b/openide.awt/src/org/openide/awt/CloseButtonFactory.java
@@ -45,9 +45,9 @@
 package org.openide.awt;
 
 import java.awt.Dimension;
-import java.awt.Image;
 import java.awt.Toolkit;
 import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.UIManager;
 import org.openide.util.ImageUtilities;
@@ -60,12 +60,12 @@
  */
 public final class CloseButtonFactory{
 
-    private static Image closeTabImage;
-    private static Image closeTabPressedImage;
-    private static Image closeTabMouseOverImage;
-    private static Image bigCloseTabImage;
-    private static Image bigCloseTabPressedImage;
-    private static Image bigCloseTabMouseOverImage;
+    private static ImageIcon closeTabImage;
+    private static ImageIcon closeTabPressedImage;
+    private static ImageIcon closeTabMouseOverImage;
+    private static ImageIcon bigCloseTabImage;
+    private static ImageIcon bigCloseTabPressedImage;
+    private static ImageIcon bigCloseTabMouseOverImage;
 
     private CloseButtonFactory() {
     }
@@ -84,9 +84,9 @@
         closeButton.setBorder(BorderFactory.createEmptyBorder());
         closeButton.setBorderPainted(false);
         closeButton.setRolloverEnabled(true);
-        closeButton.setIcon(ImageUtilities.image2Icon(getCloseTabImage()));
-        
closeButton.setRolloverIcon(ImageUtilities.image2Icon(getCloseTabRolloverImage()));
-        
closeButton.setPressedIcon(ImageUtilities.image2Icon(getCloseTabPressedImage()));
+        closeButton.setIcon(getCloseTabImage());
+        closeButton.setRolloverIcon(getCloseTabRolloverImage());
+        closeButton.setPressedIcon(getCloseTabPressedImage());
         return closeButton;
     }
 
@@ -104,9 +104,9 @@
         closeButton.setBorder(BorderFactory.createEmptyBorder());
         closeButton.setBorderPainted(false);
         closeButton.setRolloverEnabled(true);
-        
closeButton.setIcon(ImageUtilities.image2Icon(getBigCloseTabImage()));
-        
closeButton.setRolloverIcon(ImageUtilities.image2Icon(getBigCloseTabRolloverImage()));
-        
closeButton.setPressedIcon(ImageUtilities.image2Icon(getBigCloseTabPressedImage()));
+        closeButton.setIcon(getBigCloseTabImage());
+        closeButton.setRolloverIcon(getBigCloseTabRolloverImage());
+        closeButton.setPressedIcon(getBigCloseTabPressedImage());
         return closeButton;
     }
 
@@ -155,128 +155,128 @@
         return "GTK".equals( UIManager.getLookAndFeel().getID() ); //NOI18N
     }
 
-    private static Image getCloseTabImage() {
+    private static ImageIcon getCloseTabImage() {
         if( null == closeTabImage ) {
             if( isWindows8LaF() ) {
-                closeTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win8_bigclose_enabled.png");
 // NOI18N
+                closeTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_enabled.png",
 true); // NOI18N
             } else if( isWindowsVistaLaF() ) {
-                closeTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/vista_close_enabled.png");
 // NOI18N
+                closeTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_close_enabled.png",
 true); // NOI18N
             } else if( isWindowsXPLaF() ) {
-                closeTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/xp_close_enabled.png"); 
// NOI18N
+                closeTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_close_enabled.png",
 true); // NOI18N
             } else if( isWindowsLaF() ) {
-                closeTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win_close_enabled.png"); 
// NOI18N
+                closeTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win_close_enabled.png",
 true); // NOI18N
             } else if( isAquaLaF() ) {
-                closeTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/mac_close_enabled.png"); 
// NOI18N
+                closeTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_close_enabled.png",
 true); // NOI18N
             } else if( isGTKLaF() ) {
-                closeTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/gtk_close_enabled.png"); 
// NOI18N
+                closeTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_close_enabled.png",
 true); // NOI18N
             } else {
-                closeTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/metal_close_enabled.png");
 // NOI18N
+                closeTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_close_enabled.png",
 true); // NOI18N
             }
         }
         return closeTabImage;
     }
 
-    private static Image getCloseTabPressedImage() {
+    private static ImageIcon getCloseTabPressedImage() {
         if( null == closeTabPressedImage ) {
             if( isWindows8LaF() ) {
-                closeTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win8_bigclose_pressed.png");
 // NOI18N
+                closeTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_pressed.png",
 true); // NOI18N
             } else if( isWindowsVistaLaF() ) {
-                closeTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/vista_close_pressed.png");
 // NOI18N
+                closeTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_close_pressed.png",
 true); // NOI18N
             } else if( isWindowsXPLaF() ) {
-                closeTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/xp_close_pressed.png"); 
// NOI18N
+                closeTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_close_pressed.png",
 true); // NOI18N
             } else if( isWindowsLaF() ) {
-                closeTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win_close_pressed.png"); 
// NOI18N
+                closeTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win_close_pressed.png",
 true); // NOI18N
             } else if( isAquaLaF() ) {
-                closeTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/mac_close_pressed.png"); 
// NOI18N
+                closeTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_close_pressed.png",
 true); // NOI18N
             } else if( isGTKLaF() ) {
-                closeTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/gtk_close_pressed.png"); 
// NOI18N
+                closeTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_close_pressed.png",
 true); // NOI18N
             } else {
-                closeTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/metal_close_pressed.png");
 // NOI18N
+                closeTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_close_pressed.png",
 true); // NOI18N
             }
         }
         return closeTabPressedImage;
     }
 
-    private static Image getCloseTabRolloverImage() {
+    private static ImageIcon getCloseTabRolloverImage() {
         if( null == closeTabMouseOverImage ) {
             if( isWindows8LaF() ) {
-                closeTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win8_bigclose_rollover.png");
 // NOI18N
+                closeTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_rollover.png",
 true); // NOI18N
             } else if( isWindowsVistaLaF() ) {
-                closeTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/vista_close_rollover.png");
 // NOI18N
+                closeTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_close_rollover.png",
 true); // NOI18N
             } else if( isWindowsXPLaF() ) {
-                closeTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/xp_close_rollover.png"); 
// NOI18N
+                closeTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_close_rollover.png",
 true); // NOI18N
             } else if( isWindowsLaF() ) {
-                closeTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win_close_rollover.png"); 
// NOI18N
+                closeTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win_close_rollover.png",
 true); // NOI18N
             } else if( isAquaLaF() ) {
-                closeTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/mac_close_rollover.png"); 
// NOI18N
+                closeTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_close_rollover.png",
 true); // NOI18N
             } else if( isGTKLaF() ) {
-                closeTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/gtk_close_rollover.png"); 
// NOI18N
+                closeTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_close_rollover.png",
 true); // NOI18N
             } else {
-                closeTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/metal_close_rollover.png");
 // NOI18N
+                closeTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_close_rollover.png",
 true); // NOI18N
             }
         }
         return closeTabMouseOverImage;
     }
 
 
-    private static Image getBigCloseTabImage() {
+    private static ImageIcon getBigCloseTabImage() {
         if( null == bigCloseTabImage ) {
             if( isWindows8LaF() ) {
-                bigCloseTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win8_bigclose_enabled.png");
 // NOI18N
+                bigCloseTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_enabled.png",
 true); // NOI18N
             } else if( isWindowsVistaLaF() ) {
-                bigCloseTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/vista_bigclose_enabled.png");
 // NOI18N
+                bigCloseTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_bigclose_enabled.png",
 true); // NOI18N
             } else if( isWindowsXPLaF() ) {
-                bigCloseTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/xp_bigclose_enabled.png");
 // NOI18N
+                bigCloseTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_bigclose_enabled.png",
 true); // NOI18N
             } else if( isWindowsLaF() ) {
-                bigCloseTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win_bigclose_enabled.png");
 // NOI18N
+                bigCloseTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win_bigclose_enabled.png",
 true); // NOI18N
             } else if( isAquaLaF() ) {
-                bigCloseTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/mac_bigclose_enabled.png");
 // NOI18N
+                bigCloseTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_bigclose_enabled.png",
 true); // NOI18N
             } else if( isGTKLaF() ) {
-                bigCloseTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/gtk_bigclose_enabled.png");
 // NOI18N
+                bigCloseTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_bigclose_enabled.png",
 true); // NOI18N
             } else {
-                bigCloseTabImage = 
ImageUtilities.loadImage("org/openide/awt/resources/metal_bigclose_enabled.png");
 // NOI18N
+                bigCloseTabImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_bigclose_enabled.png",
 true); // NOI18N
             }
         }
         return bigCloseTabImage;
     }
 
-    private static  Image getBigCloseTabPressedImage() {
+    private static  ImageIcon getBigCloseTabPressedImage() {
         if( null == bigCloseTabPressedImage ) {
             if( isWindows8LaF() ) {
-                bigCloseTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win8_bigclose_pressed.png");
 // NOI18N
+                bigCloseTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_pressed.png",
 true); // NOI18N
             } else if( isWindowsVistaLaF() ) {
-                bigCloseTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/vista_bigclose_pressed.png");
 // NOI18N
+                bigCloseTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_bigclose_pressed.png",
 true); // NOI18N
             } else if( isWindowsXPLaF() ) {
-                bigCloseTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/xp_bigclose_pressed.png");
 // NOI18N
+                bigCloseTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_bigclose_pressed.png",
 true); // NOI18N
             } else if( isWindowsLaF() ) {
-                bigCloseTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win_bigclose_pressed.png");
 // NOI18N
+                bigCloseTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win_bigclose_pressed.png",
 true); // NOI18N
             } else if( isAquaLaF() ) {
-                bigCloseTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/mac_bigclose_pressed.png");
 // NOI18N
+                bigCloseTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_bigclose_pressed.png",
 true); // NOI18N
             } else if( isGTKLaF() ) {
-                bigCloseTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/gtk_bigclose_pressed.png");
 // NOI18N
+                bigCloseTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_bigclose_pressed.png",
 true); // NOI18N
             } else {
-                bigCloseTabPressedImage = 
ImageUtilities.loadImage("org/openide/awt/resources/metal_bigclose_pressed.png");
 // NOI18N
+                bigCloseTabPressedImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_bigclose_pressed.png",
 true); // NOI18N
             }
         }
         return bigCloseTabPressedImage;
     }
 
-    private static Image getBigCloseTabRolloverImage() {
+    private static ImageIcon getBigCloseTabRolloverImage() {
         if( null == bigCloseTabMouseOverImage ) {
             if( isWindows8LaF() ) {
-                bigCloseTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win8_bigclose_rollover.png");
 // NOI18N
+                bigCloseTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_rollover.png",
 true); // NOI18N
             } else if( isWindowsVistaLaF() ) {
-                bigCloseTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/vista_bigclose_rollover.png");
 // NOI18N
+                bigCloseTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_bigclose_rollover.png",
 true); // NOI18N
             } else if( isWindowsXPLaF() ) {
-                bigCloseTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/xp_bigclose_rollover.png");
 // NOI18N
+                bigCloseTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_bigclose_rollover.png",
 true); // NOI18N
             } else if( isWindowsLaF() ) {
-                bigCloseTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/win_bigclose_rollover.png");
 // NOI18N
+                bigCloseTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/win_bigclose_rollover.png",
 true); // NOI18N
             } else if( isAquaLaF() ) {
-                bigCloseTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/mac_bigclose_rollover.png");
 // NOI18N
+                bigCloseTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_bigclose_rollover.png",
 true); // NOI18N
             } else if( isGTKLaF() ) {
-                bigCloseTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/gtk_bigclose_rollover.png");
 // NOI18N
+                bigCloseTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_bigclose_rollover.png",
 true); // NOI18N
             } else {
-                bigCloseTabMouseOverImage = 
ImageUtilities.loadImage("org/openide/awt/resources/metal_bigclose_rollover.png");
 // NOI18N
+                bigCloseTabMouseOverImage = 
ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_bigclose_rollover.png",
 true); // NOI18N
             }
         }
         return bigCloseTabMouseOverImage;
diff --git a/openide.awt/src/org/openide/awt/HtmlLabelUI.java 
b/openide.awt/src/org/openide/awt/HtmlLabelUI.java
--- a/openide.awt/src/org/openide/awt/HtmlLabelUI.java
+++ b/openide.awt/src/org/openide/awt/HtmlLabelUI.java
@@ -400,6 +400,8 @@
     static Color ensureContrastingColor(Color fg, Color bg) {
         if (bg == null) {
             if (isNimbus()) {
+                bg = UIManager.getColor( "textBackground" ); //NOI18N
+                if( null == bg )
                 bg = Color.WHITE;
             } else {
                 bg = UIManager.getColor("text"); //NOI18N
@@ -411,9 +413,11 @@
         }
         if (fg == null) {
             if (isNimbus()) {
+                fg = UIManager.getColor( "textForeground" ); //NOI18N
+                if( null == fg )
                 fg = Color.BLACK;
             } else {
-                fg = UIManager.getColor("textText");
+                fg = UIManager.getColor("textText"); //NOI18N
                 if (fg == null) {
                     fg = Color.BLACK;
                 }
diff --git a/openide.util/src/org/openide/util/ImageUtilities.java 
b/openide.util/src/org/openide/util/ImageUtilities.java
--- a/openide.util/src/org/openide/util/ImageUtilities.java
+++ b/openide.util/src/org/openide/util/ImageUtilities.java
@@ -44,6 +44,7 @@
 
 package org.openide.util;
 
+import java.awt.Color;
 import java.awt.Component;
 import java.awt.Graphics;
 import java.awt.HeadlessException;
@@ -77,6 +78,7 @@
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
 import javax.swing.JLabel;
+import javax.swing.UIManager;
 
 /** 
  * Useful static methods for manipulation with images/icons, results are 
cached.
@@ -95,6 +97,8 @@
     private static final Map<CompositeImageKey,ActiveRef<CompositeImageKey>> 
compositeCache = new 
HashMap<CompositeImageKey,ActiveRef<CompositeImageKey>>(128);
     private static final Map<ToolTipImageKey, ActiveRef<ToolTipImageKey>> 
imageToolTipCache = new HashMap<ToolTipImageKey, 
ActiveRef<ToolTipImageKey>>(128);
 
+    private static RGBImageFilter imageIconFilter = null;
+
     /** Resource paths for which we have had to strip initial slash.
      * @see "#20072"
      */
@@ -162,7 +166,24 @@
      */
     public static final ImageIcon loadImageIcon(String resource, boolean 
localized) {
         Image image = getIcon(resource, localized);
-        return image == null ? null : (ImageIcon) image2Icon(image);
+        if( image == null ) {
+            return null;
+        }
+        RGBImageFilter imageFilter = getImageIconFilter();
+        if( null != imageFilter ) {
+            image = Toolkit.getDefaultToolkit().createImage( new 
FilteredImageSource( image.getSource(), imageFilter ) );
+        }
+        return ( ImageIcon ) image2Icon( image );
+    }
+
+    private static RGBImageFilter getImageIconFilter() {
+        if( null == imageIconFilter ) {
+            Object obj = UIManager.get( "nb.imageicon.filter"); //NOI18N
+            if( obj instanceof RGBImageFilter ) {
+                imageIconFilter = ( RGBImageFilter ) obj;
+            }
+        }
+        return imageIconFilter;
     }
 
     /** This method merges two images into the new one. The second image is 
drawn

[hg] main-silver: #225542 - dark color theme for Metal and Nimbu...

S. Aubrecht 02/01/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close