001: /*
002: Copyright © 2006,2007 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004: Contributors:
005: * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006: contributed code is Copyright © 2006,2007 by Stefano Chizzolini.
007:
008: This file should be part of the source code distribution of "PDF Clown library"
009: (the Program): see the accompanying README files for more info.
010:
011: This Program is free software; you can redistribute it and/or modify it under
012: the terms of the GNU General Public License as published by the Free Software
013: Foundation; either version 2 of the License, or (at your option) any later version.
014:
015: This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016: WARRANTY, either expressed or implied; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019: You should have received a copy of the GNU General Public License along with this
020: Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022: Redistribution and use, with or without modification, are permitted provided that such
023: redistributions retain the above copyright notice, license and disclaimer, along with
024: this list of conditions.
025: */
026:
027: package it.stefanochizzolini.clown.documents.contents.colorSpaces;
028:
029: import it.stefanochizzolini.clown.objects.PdfReal;
030:
031: /**
032: Device Red-Green-Blue color value [PDF:1.6:4.5.3].
033: @version 0.0.4
034: */
035: public class DeviceRGBColor extends DeviceColor {
036: // <class>
037: // <static>
038: // <fields>
039: public static final DeviceRGBColor Black = new DeviceRGBColor(0, 0,
040: 0);
041: public static final DeviceRGBColor White = new DeviceRGBColor(1, 1,
042: 1);
043:
044: public static final DeviceRGBColor Default = Black;
045: // </fields>
046: // </static>
047:
048: // <dynamic>
049: // <fields>
050: private double blueComponent;
051: private double greenComponent;
052: private double redComponent;
053:
054: // </fields>
055:
056: // <constructors>
057: public DeviceRGBColor(double redComponent, double greenComponent,
058: double blueComponent) {
059: super (DeviceRGBColorSpace.Default);
060:
061: setRedComponent(redComponent);
062: setGreenComponent(greenComponent);
063: setBlueComponent(blueComponent);
064: }
065:
066: // </constructors>
067:
068: // <interface>
069: // <public>
070: /**
071: Gets the blue component.
072: */
073: public double getBlueComponent() {
074: return blueComponent;
075: }
076:
077: @Override
078: public double[] getComponents() {
079: return new double[] { redComponent, greenComponent,
080: blueComponent };
081: }
082:
083: /**
084: Gets the green component.
085: */
086: public double getGreenComponent() {
087: return greenComponent;
088: }
089:
090: /**
091: Gets the red component.
092: */
093: public double getRedComponent() {
094: return redComponent;
095: }
096:
097: /**
098: Sets the blue component.
099: */
100: public void setBlueComponent(double value) {
101: blueComponent = normalizeComponent(value);
102: }
103:
104: /**
105: Sets the green component.
106: */
107: public void setGreenComponent(double value) {
108: greenComponent = normalizeComponent(value);
109: }
110:
111: /**
112: Sets the red component.
113: */
114: public void setRedComponent(double value) {
115: redComponent = normalizeComponent(value);
116: }
117:
118: // </public>
119:
120: // <internal>
121: public String toPdf() {
122: return (PdfReal.toPdf(redComponent) + " "
123: + PdfReal.toPdf(greenComponent) + " " + PdfReal
124: .toPdf(blueComponent));
125: }
126: // </internal>
127: // </interface>
128: // </dynamic>
129: // </class>
130: }
|