001 /* ColorUIResource.java 002 Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 039 package javax.swing.plaf; 040 041 import java.awt.Color; 042 043 044 /** 045 * A Color that is marked as <code>UIResource</code>, which indicates that 046 * the color has been installed by a pluggable LookAndFeel. Such colors 047 * are replaced when the LookAndFeel changes. 048 * 049 * @see java.awt.Color 050 * 051 * @author Sascha Brawer (brawer@dandelis.ch) 052 */ 053 public class ColorUIResource extends Color implements UIResource 054 { 055 /** 056 * Constructs a <code>ColorUIResource</code> using the specified 057 * red, green, and blue values, which must be given as integers in 058 * the range of 0-255. The alpha channel value will default to 255, 059 * meaning that the color is fully opaque. 060 * 061 * @param r the red intensity, which must be in the range [0 .. 255]. 062 * @param g the green intensity, which must be in the range [0 .. 255]. 063 * @param b the blue intensity, which must be in the range [0 .. 255]. 064 * 065 * @throws IllegalArgumentException if any of the values is outside the 066 * specified range. 067 */ 068 public ColorUIResource(int r, int g, int b) 069 { 070 super(r, g, b); 071 } 072 073 074 /** 075 * Constructs a <code>ColorUIResource</code> using the specified 076 * RGB value. The blue value is in bits 0-7, green in bits 8-15, and 077 * red in bits 16-23. The other bits are ignored. The alpha value is set 078 * to 255, meaning that the color is fully opaque. 079 * 080 * @param rgb the rgb value, as discussed above. 081 */ 082 public ColorUIResource(int rgb) 083 { 084 super(rgb); 085 } 086 087 088 /** 089 * Constructs a <code>ColorUIResource</code> using the specified 090 * red, green, and blue intensities, which must be given as floats in 091 * the range of 0-1. The alpha channel value will default to 1.0f, 092 * meaning that the color is fully opaque. 093 * 094 * @param r the red intensity, which must be in the range [0.0 .. 1.0]. 095 * @param g the green intensity, which must be in the range [0.0 .. 1.0]. 096 * @param b the blue intensity, which must be in the range [0.0 .. 1.0]. 097 * 098 * @throws IllegalArgumentException if any of the values is outside the 099 * specified range. 100 */ 101 public ColorUIResource(float r, float g, float b) 102 { 103 super(r, g, b); 104 } 105 106 107 /** 108 * Constructs a <code>ColorUIResource</code>, using the intensities 109 * of another color. 110 * 111 * @param c the color whose intensities will be considered when 112 * constructing this <code>ColorUIResource</code> (<code>null</code> 113 * not permitted). 114 * 115 * @throws NullPointerException if <code>c</code> is <code>null</code>. 116 */ 117 public ColorUIResource(Color c) 118 { 119 super(c.getRGB()); 120 } 121 }