src/share/classes/com/sun/java/swing/plaf/gtk/XColors.java

Print this page




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.java.swing.plaf.gtk;
  27 
  28 import java.awt.Color;
  29 import java.util.Arrays;
  30 import javax.swing.plaf.ColorUIResource;
  31 
  32 /**
  33  * @author  Shannon Hickey
  34  */
  35 class XColors {
  36 
  37     private static class XColor implements Comparable {
  38         String name;
  39 
  40         int red;
  41         int green;
  42         int blue;
  43 
  44         XColor(String name, int red, int green, int blue) {
  45             this.name = name;
  46             this.red = red;
  47             this.green = green;
  48             this.blue = blue;
  49         }
  50 
  51         Color toColor() {
  52             return new ColorUIResource(red, green, blue);
  53         }
  54 
  55         public int compareTo(Object o) {
  56             XColor other = (XColor)o;
  57 
  58             return name.compareTo(other.name);
  59         }
  60     }
  61 
  62     private static XColor key = new XColor("", -1, -1, -1);
  63 
  64     static Color lookupColor(String name) {
  65         key.name = name.toLowerCase();
  66 
  67         int pos = Arrays.binarySearch(colors, key);
  68 
  69         if (pos < 0) {
  70             return null;
  71         }
  72 
  73         return colors[pos].toColor();
  74     }
  75 
  76     private static final XColor[] colors = {
  77         new XColor("alice blue", 240, 248, 255),
  78         new XColor("aliceblue", 240, 248, 255),




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.java.swing.plaf.gtk;
  27 
  28 import java.awt.Color;
  29 import java.util.Arrays;
  30 import javax.swing.plaf.ColorUIResource;
  31 
  32 /**
  33  * @author  Shannon Hickey
  34  */
  35 class XColors {
  36 
  37     private static class XColor implements Comparable<XColor> {
  38         String name;
  39 
  40         int red;
  41         int green;
  42         int blue;
  43 
  44         XColor(String name, int red, int green, int blue) {
  45             this.name = name;
  46             this.red = red;
  47             this.green = green;
  48             this.blue = blue;
  49         }
  50 
  51         Color toColor() {
  52             return new ColorUIResource(red, green, blue);
  53         }
  54 
  55         public int compareTo(XColor o) {
  56             return name.compareTo(o.name);


  57         }
  58     }
  59 
  60     private static XColor key = new XColor("", -1, -1, -1);
  61 
  62     static Color lookupColor(String name) {
  63         key.name = name.toLowerCase();
  64 
  65         int pos = Arrays.binarySearch(colors, key);
  66 
  67         if (pos < 0) {
  68             return null;
  69         }
  70 
  71         return colors[pos].toColor();
  72     }
  73 
  74     private static final XColor[] colors = {
  75         new XColor("alice blue", 240, 248, 255),
  76         new XColor("aliceblue", 240, 248, 255),