KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > graphics > color > PDGamma


1 /**
2  * Copyright (c) 2004, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdmodel.graphics.color;
32
33 import org.pdfbox.cos.COSArray;
34 import org.pdfbox.cos.COSBase;
35 import org.pdfbox.cos.COSFloat;
36 import org.pdfbox.cos.COSNumber;
37
38 import org.pdfbox.pdmodel.common.COSObjectable;
39
40 /**
41  * A gamma array, or collection of three floating point parameters used for
42  * color operations.
43  *
44  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
45  * @version $Revision: 1.2 $
46  */

47 public class PDGamma implements COSObjectable
48 {
49     private COSArray values = null;
50
51     /**
52      * Constructor. Defaults all values to 0, 0, 0.
53      */

54     public PDGamma()
55     {
56         values = new COSArray();
57         values.add( new COSFloat( 0.0f ) );
58         values.add( new COSFloat( 0.0f ) );
59         values.add( new COSFloat( 0.0f ) );
60     }
61
62     /**
63      * Constructor from COS object.
64      *
65      * @param array The array containing the XYZ values.
66      */

67     public PDGamma( COSArray array )
68     {
69         values = array;
70     }
71
72     /**
73      * Convert this standard java object to a COS object.
74      *
75      * @return The cos object that matches this Java object.
76      */

77     public COSBase getCOSObject()
78     {
79         return values;
80     }
81
82     /**
83      * Convert this standard java object to a COS object.
84      *
85      * @return The cos object that matches this Java object.
86      */

87     public COSArray getCOSArray()
88     {
89         return values;
90     }
91
92     /**
93      * This will get the r value of the tristimulus.
94      *
95      * @return The R value.
96      */

97     public float getR()
98     {
99         return ((COSNumber)values.get( 0 )).floatValue();
100     }
101
102     /**
103      * This will set the r value of the tristimulus.
104      *
105      * @param r The r value for the tristimulus.
106      */

107     public void setR( float r )
108     {
109         values.set( 0, new COSFloat( r ) );
110     }
111
112     /**
113      * This will get the g value of the tristimulus.
114      *
115      * @return The g value.
116      */

117     public float getG()
118     {
119         return ((COSNumber)values.get( 1 )).floatValue();
120     }
121
122     /**
123      * This will set the g value of the tristimulus.
124      *
125      * @param g The g value for the tristimulus.
126      */

127     public void setG( float g )
128     {
129         values.set( 1, new COSFloat( g ) );
130     }
131
132     /**
133      * This will get the b value of the tristimulus.
134      *
135      * @return The B value.
136      */

137     public float getB()
138     {
139         return ((COSNumber)values.get( 2 )).floatValue();
140     }
141
142     /**
143      * This will set the b value of the tristimulus.
144      *
145      * @param b The b value for the tristimulus.
146      */

147     public void setB( float b )
148     {
149         values.set( 2, new COSFloat( b ) );
150     }
151 }
Popular Tags