Web color enum : Color « 2D Graphics GUI « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java » 2D Graphics GUI » ColorScreenshots 
Web color enum
   

/*
 * @(#)WebColor.java  1.0 Apr 27, 2008
 *
 *  The MIT License
 *
 *  Copyright (c) 2008 Malachi de AElfweald <[email protected]>
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *  THE SOFTWARE.
 */
//package org.eoti.awt;

import java.awt.*;

public enum WebColor
{
  AliceBlue(0xF00xF80xFF),
  AntiqueWhite(0xFA0xEB0xD7),
  Aqua(0x000xFF0xFF),
  AquaMarine(0x7F0xFF0xD4),
  Azure(0xF00xFF0xFF),
  Beige(0xF50xF50xDC),
  Bisque(0xFF0xE40xC4),
  Black(0x000x000x00),
  BlanchedAlmond(0xFF0xEB0xCD),
  Blue(0x000x000xFF),
  BlueViolet(0x8A0x2B0xE2),
  Brown(0xA50x2A0x2A),
  BurlyWood(0xDE0xB80x87),
  CadetBlue(0x5F0x9E0xA0),
  Chartreuse(0x7F0xFF0x00),
  Chocolate(0xD20x690x1E),
  Coral(0xFF0x7F0x50),
  CornFlowerBlue(0x640x950xED),
  CornSilk(0xFF0xF80xDC),
  Crimson  (0xDC0x140x3C),
  Cyan(0x000xFF0xFF),
  DarkBlue(0x000x000x8B),
  DarkCyan(0x000x8B0x8B),
  DarkGoldenRod(0xB80x860x0B),
  DarkGray(0xA90xA90xA9),
  DarkGreen(0x000x640x00),
  DarkKhaki(0xBD0xB70x6B),
  DarkMagenta(0x8B0x000x8B),
  DarkOliveGreen(0x550x6B0x2F),
  DarkOrange(0xFF0x8C0x00),
  DarkOrchid(0x990x320xCC),
  DarkRed(0x8B0x000x00),
  DarkSalmon(0xE90x960x7A),
  DarkSeaGreen(0x8F0xBC0x8F),
  DarkSlateBlue(0x480x3D0x8B),
  DarkSlateGray(0x2F0x4F0x4F),
  DarkTurquoise(0x000xCE0xD1),
  DarkViolet(0x940x000xD3),
  DeepPink(0xFF0x140x93),
  DeepSkyBlue(0x000xBF0xFF),
  DimGray(0x690x690x69),
  DodgerBlue(0x1E0x900xFF),
  FireBrick(0xB20x220x22),
  FloralWhite(0xFF0xFA0xF0),
  ForestGreen(0x220x8B0x22),
  Fuchsia(0xFF0x000xFF),
  Gainsboro(0xDC0xDC0xDC),
  GhostWhite(0xF80xF80xFF),
  Gold(0xFF0xD70x00),
  GoldenRod(0xDA0xA50x20),
  Gray(0x800x800x80),
  Green(0x000x800x00),
  GreenYellow(0xAD0xFF0x2F),
  HoneyDew(0xF00xFF0xF0),
  HotPink(0xFF0x690xB4),
  IndianRed(0xCD0x5C0x5C),
  Indigo(0x4B0x000x82),
  Ivory(0xFF0xFF0xF0),
  Khaki(0xF00xE60x8C),
  Lavender(0xE60xE60xFA),
  LavenderBlush(0xFF0xF00xF5),
  LawnGreen(0x7C0xFC0x00),
  LemonChiffon(0xFF0xFA0xCD),
  LightBlue(0xAD0xD80xE6),
  LightCoral(0xF00x800x80),
  LightCyan(0xE00xFF0xFF),
  LightGoldenRodYellow(0xFA0xFA0xD2),
  LightGreen(0x900xEE0x90),
  LightGray(0xD30xD30xD3),
  LightPink(0xFF0xB60xC1),
  LightSalmon(0xFF0xA00x7A),
  LightSeaGreen(0x200xB20xAA),
  LightSkyBlue(0x870xCE0xFA),
  LightSlateGray(0x770x880x99),
  LightSteelBlue(0xB00xC40xDE),
  LightYellow(0xFF0xFF0xE0),
  Lime(0x000xFF0x00),
  LimeGreen(0x320xCD0x32),
  Linen(0xFA0xF00xE6),
  Magenta(0xFF0x000xFF),
  Maroon(0x800x000x00),
  MediumAquaMarine(0x660xCD0xAA),
  MediumBlue(0x000x000xCD),
  MediumOrchid(0xBA0x550xD3),
  MediumPurple(0x930x700xDB),
  MediumSeaGreen(0x3C0xB30x71),
  MediumSlateBlue(0x7B0x680xEE),
  MediumSpringGreen(0x000xFA0x9A),
  MediumTurquoise(0x480xD10xCC),
  MediumVioletRed(0xC70x150x85),
  MidnightBlue(0x190x190x70),
  MintCream(0xF50xFF0xFA),
  MistyRose(0xFF0xE40xE1),
  Moccasin(0xFF0xE40xB5),
  NavajoWhite(0xFF0xDE0xAD),
  Navy(0x000x000x80),
  OldLace(0xFD0xF50xE6),
  Olive(0x800x800x00),
  OliveDrab(0x6B0x8E0x23),
  Orange(0xFF0xA50x00),
  OrangeRed(0xFF0x450x00),
  Orchid(0xDA0x700xD6),
  PaleGoldenRod(0xEE0xE80xAA),
  PaleGreen(0x980xFB0x98),
  PaleTurquoise(0xAF0xEE0xEE),
  PaleVioletRed(0xDB0x700x93),
  PapayaWhip(0xFF0xEF0xD5),
  PeachPuff(0xFF0xDA0xB9),
  Peru(0xCD0x850x3F),
  Pink(0xFF0xC00xCB),
  Plum(0xDD0xA00xDD),
  PowderBlue(0xB00xE00xE6),
  Purple(0x800x000x80),
  Red(0xFF0x000x00),
  RosyBrown(0xBC0x8F0x8F),
  RoyalBlue(0x410x690xE1),
  SaddleBrown(0x8B0x450x13),
  Salmon(0xFA0x800x72),
  SandyBrown(0xF40xA40x60),
  SeaGreen(0x2E0x8B0x57),
  SeaShell(0xFF0xF50xEE),
  Sienna(0xA00x520x2D),
  Silver(0xC00xC00xC0),
  SkyBlue(0x870xCE0xEB),
  SlateBlue(0x6A0x5A0xCD),
  SlateGray(0x700x800x90),
  Snow(0xFF0xFA0xFA),
  SpringGreen(0x000xFF0x7F),
  SteelBlue(0x460x820xB4),
  Tan(0xD20xB40x8C),
  Teal(0x000x800x80),
  Thistle(0xD80xBF0xD8),
  Tomato(0xFF0x630x47),
  Turquoise(0x400xE00xD0),
  Violet(0xEE0x820xEE),
  Wheat(0xF50xDE0xB3),
  White(0xFF0xFF0xFF),
  WhiteSmoke(0xF50xF50xF5),
  Yellow(0xFF0xFF0x00),
  YellowGreen(0x9A0xCD0x32);

  WebColor(int r, int g, int b){this.r=r;this.g=g;this.b=b;}
  private final int r, g, b;
  public int getRed(){return r;}
  public int getGreen(){return g;}
  public int getBlue(){return b;}
  public Color getColor(){return new Color(r,g,b);}
  public int getRGB(){return getColor().getRGB();}
  public String getRGBString()
  {
    /**
     * toHexString will return "0" instead of "00"
     * String.format will not 0-pad Strings or Hex
     * Have to do it manually...
     */
    return String.format(
      "#%s%s%s",
      (r<0x10?"0":"")+Integer.toHexString(r),
      (g<0x10?"0":"")+Integer.toHexString(g),
      (b<0x10?"0":"")+Integer.toHexString(b)
    );
  }
}

   
    
    
  
Related examples in the same category
1.Color class is used to work with colors in Java 2D
2.Color Utilities: common color operations
3.Color Difference
4.Rainbow ColorRainbow Color
5.XOR colorXOR color
6.Color Gradient
7.Common color utilities
8.Drawing with Color
9.Color fading animation
10.140 colors - defined for X Window System listed in O'Reilly html pocket reference 87pp
11.Color Util
12.Color Factory
13.An efficient color quantization algorithm
14.Utility for checking colors given either hexa or natural language string descriptions.
15.Derives a color by adding the specified offsets to the base color's hue, saturation, and brightness values
16.Map colors into names and vice versa.
17.Converts a given string into a color.
18.If the color is equal to one of the defined constant colors, that name is returned instead.
19.Converts the String representation of a color to an actual Color object.
20.Returns blue-yellow-red color scale
21.Returns green-yellow-red-black color scale
22.Returns black-red-yellow-green color scale
23.Returns color based on 0-9 scale ranging from green to yellow
24.Returns color based on 0-9 scale ranging from yellow to red
25.Returns color based on 0-9 scale ranging from black to green
26.Returns n-dimensional array of colors for given nx3 integer array of RGB values
27.Utility class for managing resources such as colors, fonts, images, etc.
28.Make a color transparent
29.Return a Color object given a string representation of it
30.Return a string representation of a color
31.Serializes a color to its HTML markup (e.g. "#ff0000" for red)
32.Parses a java.awt.Color from an HTML color string in the form '#RRGGBB' where RR, GG, and BB are the red, green, and blue bytes in hexadecimal form
33.Performs a somewhat subjective analysis of a color to determine how dark it looks to a user
34.Lightens a color by a given amount
35.Darkens a color by a given amount
36.Blend two colors
37.Utility for working with natively-ordered integer-packed RGBA-format colours.
38.HSV to RGB
39.A widget to manipulate an RGBA colour.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.