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 Cyan-Magenta-Yellow-Key color value [PDF:1.6:4.5.3].
033: <h3>Remarks</h3>
034: <p>The 'Key' component is renamed 'Black' to avoid semantic ambiguities.</p>
035: @version 0.0.4
036: */
037: public class DeviceCMYKColor extends DeviceColor {
038: // <class>
039: // <static>
040: // <fields>
041: public static final DeviceCMYKColor Black = new DeviceCMYKColor(0,
042: 0, 0, 1);
043: public static final DeviceCMYKColor White = new DeviceCMYKColor(0,
044: 0, 0, 0);
045:
046: public static final DeviceCMYKColor Default = Black;
047: // </fields>
048: // </static>
049:
050: // <dynamic>
051: // <fields>
052: private double blackComponent;
053: private double cyanComponent;
054: private double magentaComponent;
055: private double yellowComponent;
056:
057: // </fields>
058:
059: // <constructors>
060: public DeviceCMYKColor(double cyanComponent,
061: double magentaComponent, double yellowComponent,
062: double blackComponent) {
063: super (DeviceCMYKColorSpace.Default);
064:
065: setCyanComponent(cyanComponent);
066: setMagentaComponent(magentaComponent);
067: setYellowComponent(yellowComponent);
068: setBlackComponent(blackComponent);
069: }
070:
071: // </constructors>
072:
073: // <interface>
074: // <public>
075: /**
076: Gets the black (key) component.
077: */
078: public double getBlackComponent() {
079: return blackComponent;
080: }
081:
082: @Override
083: public double[] getComponents() {
084: return new double[] { cyanComponent, magentaComponent,
085: yellowComponent, blackComponent };
086: }
087:
088: /**
089: Gets the cyan component.
090: */
091: public double getCyanComponent() {
092: return cyanComponent;
093: }
094:
095: /**
096: Gets the magenta component.
097: */
098: public double getMagentaComponent() {
099: return magentaComponent;
100: }
101:
102: /**
103: Gets the yellow component.
104: */
105: public double getYellowComponent() {
106: return yellowComponent;
107: }
108:
109: /**
110: Sets the black (key) component.
111: */
112: public void setBlackComponent(double value) {
113: blackComponent = normalizeComponent(value);
114: }
115:
116: /**
117: Sets the cyan component.
118: */
119: public void setCyanComponent(double value) {
120: cyanComponent = normalizeComponent(value);
121: }
122:
123: /**
124: Sets the magenta component.
125: */
126: public void setMagentaComponent(double value) {
127: magentaComponent = normalizeComponent(value);
128: }
129:
130: /**
131: Sets the yellow component.
132: */
133: public void setYellowComponent(double value) {
134: yellowComponent = normalizeComponent(value);
135: }
136:
137: // </public>
138:
139: // <internal>
140: public String toPdf() {
141: return (PdfReal.toPdf(cyanComponent) + " "
142: + PdfReal.toPdf(magentaComponent) + " "
143: + PdfReal.toPdf(yellowComponent) + " " + PdfReal
144: .toPdf(blackComponent));
145: }
146: // </internal>
147: // </interface>
148: // </dynamic>
149: // </class>
150: }
|