KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > engine > value > RGBColorValue


1 /*
2
3    Copyright 2002 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.css.engine.value;
19
20 import org.w3c.dom.DOMException JavaDoc;
21 import org.w3c.dom.css.CSSPrimitiveValue;
22
23 /**
24  * This class represents RGB colors.
25  *
26  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
27  * @version $Id: RGBColorValue.java,v 1.3 2004/08/18 07:12:53 vhardy Exp $
28  */

29 public class RGBColorValue extends AbstractValue {
30     
31     /**
32      * The red component.
33      */

34     protected Value red;
35
36     /**
37      * The green component.
38      */

39     protected Value green;
40
41     /**
42      * The blue component.
43      */

44     protected Value blue;
45
46     /**
47      * Creates a new RGBColorValue.
48      */

49     public RGBColorValue(Value r, Value g, Value b) {
50         red = r;
51         green = g;
52         blue = b;
53     }
54
55     /**
56      * The type of the value.
57      */

58     public short getPrimitiveType() {
59         return CSSPrimitiveValue.CSS_RGBCOLOR;
60     }
61
62     /**
63      * A string representation of the current value.
64      */

65     public String JavaDoc getCssText() {
66         return "rgb(" +
67             red.getCssText() + ", " +
68             green.getCssText() + ", " +
69             blue.getCssText() + ")";
70     }
71
72     /**
73      * Implements {@link Value#getRed()}.
74      */

75     public Value getRed() throws DOMException JavaDoc {
76         return red;
77     }
78
79     /**
80      * Implements {@link Value#getGreen()}.
81      */

82     public Value getGreen() throws DOMException JavaDoc {
83         return green;
84     }
85
86     /**
87      * Implements {@link Value#getBlue()}.
88      */

89     public Value getBlue() throws DOMException JavaDoc {
90         return blue;
91     }
92
93     /**
94      * Returns a printable representation of the color.
95      */

96     public String JavaDoc toString() {
97         return getCssText();
98     }
99 }
100
Popular Tags