001: /*
002: * Copyright (c) 2007, intarsys consulting GmbH
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * - Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * - Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * - Neither the name of intarsys nor the names of its contributors may be used
015: * to endorse or promote products derived from this software without specific
016: * prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028: * POSSIBILITY OF SUCH DAMAGE.
029: */
030: package de.intarsys.pdf.content;
031:
032: import java.util.Arrays;
033: import java.util.HashMap;
034: import java.util.List;
035: import java.util.Map;
036:
037: /**
038: * A class enumerating the operators valid in a content stream. PDF 1.4 complete
039: * operator summary (App A)
040: *
041: */
042: public class CSOperators {
043: // list of well known operators
044: static public final CSOperator CSO_BMC = CSOperator.create("BMC"); //$NON-NLS-1$
045:
046: static public final CSOperator CSO_EMC = CSOperator.create("EMC"); //$NON-NLS-1$
047:
048: static public final CSOperator CSO_BT = CSOperator.create("BT"); //$NON-NLS-1$
049:
050: static public final CSOperator CSO_ET = CSOperator.create("ET"); //$NON-NLS-1$
051:
052: static public final CSOperator CSO_Tf = CSOperator.create("Tf"); //$NON-NLS-1$
053:
054: static public final CSOperator CSO_Tstar = CSOperator.create("T*"); //$NON-NLS-1$
055:
056: static public final CSOperator CSO_W = CSOperator.create("W"); //$NON-NLS-1$
057:
058: static public final CSOperator CSO_h = CSOperator.create("h"); //$NON-NLS-1$
059:
060: static public final CSOperator CSO_bstar = CSOperator.create("b*"); //$NON-NLS-1$
061:
062: static public final CSOperator CSO_b = CSOperator.create("b"); //$NON-NLS-1$
063:
064: static public final CSOperator CSO_s = CSOperator.create("s"); //$NON-NLS-1$
065:
066: static public final CSOperator CSO_y = CSOperator.create("y"); //$NON-NLS-1$
067:
068: static public final CSOperator CSO_v = CSOperator.create("v"); //$NON-NLS-1$
069:
070: static public final CSOperator CSO_c = CSOperator.create("c"); //$NON-NLS-1$
071:
072: static public final CSOperator CSO_Wstar = CSOperator.create("W*"); //$NON-NLS-1$
073:
074: static public final CSOperator CSO_fstar = CSOperator.create("f*"); //$NON-NLS-1$
075:
076: static public final CSOperator CSO_Bstar = CSOperator.create("B*"); //$NON-NLS-1$
077:
078: static public final CSOperator CSO_f = CSOperator.create("f"); //$NON-NLS-1$
079:
080: static public final CSOperator CSO_F = CSOperator.create("F"); //$NON-NLS-1$
081:
082: static public final CSOperator CSO_B = CSOperator.create("B"); //$NON-NLS-1$
083:
084: static public final CSOperator CSO_l = CSOperator.create("l"); //$NON-NLS-1$
085:
086: static public final CSOperator CSO_TD = CSOperator.create("TD"); //$NON-NLS-1$
087:
088: static public final CSOperator CSO_Td = CSOperator.create("Td"); //$NON-NLS-1$
089:
090: static public final CSOperator CSO_m = CSOperator.create("m"); //$NON-NLS-1$
091:
092: static public final CSOperator CSO_n = CSOperator.create("n"); //$NON-NLS-1$
093:
094: static public final CSOperator CSO_re = CSOperator.create("re"); //$NON-NLS-1$
095:
096: static public final CSOperator CSO_Q = CSOperator.create("Q"); //$NON-NLS-1$
097:
098: static public final CSOperator CSO_q = CSOperator.create("q"); //$NON-NLS-1$
099:
100: static public final CSOperator CSO_Tc = CSOperator.create("Tc"); //$NON-NLS-1$
101:
102: static public final CSOperator CSO_i = CSOperator.create("i"); //$NON-NLS-1$
103:
104: static public final CSOperator CSO_g = CSOperator.create("g"); //$NON-NLS-1$
105:
106: static public final CSOperator CSO_G = CSOperator.create("G"); //$NON-NLS-1$
107:
108: static public final CSOperator CSO_Tz = CSOperator.create("Tz"); //$NON-NLS-1$
109:
110: static public final CSOperator CSO_TL = CSOperator.create("TL"); //$NON-NLS-1$
111:
112: static public final CSOperator CSO_J = CSOperator.create("J"); //$NON-NLS-1$
113:
114: static public final CSOperator CSO_d = CSOperator.create("d"); //$NON-NLS-1$
115:
116: static public final CSOperator CSO_j = CSOperator.create("j"); //$NON-NLS-1$
117:
118: static public final CSOperator CSO_w = CSOperator.create("w"); //$NON-NLS-1$
119:
120: static public final CSOperator CSO_M = CSOperator.create("M"); //$NON-NLS-1$
121:
122: static public final CSOperator CSO_rg = CSOperator.create("rg"); //$NON-NLS-1$
123:
124: static public final CSOperator CSO_RG = CSOperator.create("RG"); //$NON-NLS-1$
125:
126: static public final CSOperator CSO_Tm = CSOperator.create("Tm"); //$NON-NLS-1$
127:
128: static public final CSOperator CSO_Tr = CSOperator.create("Tr"); //$NON-NLS-1$
129:
130: static public final CSOperator CSO_Ts = CSOperator.create("Ts"); //$NON-NLS-1$
131:
132: static public final CSOperator CSO_Tw = CSOperator.create("Tw"); //$NON-NLS-1$
133:
134: static public final CSOperator CSO_Tj = CSOperator.create("Tj"); //$NON-NLS-1$
135:
136: static public final CSOperator CSO_S = CSOperator.create("S"); //$NON-NLS-1$
137:
138: static public final CSOperator CSO_cm = CSOperator.create("cm"); //$NON-NLS-1$
139:
140: static public final CSOperator CSO_gs = CSOperator.create("gs"); //$NON-NLS-1$
141:
142: static public final CSOperator CSO_CS = CSOperator.create("CS"); //$NON-NLS-1$
143:
144: static public final CSOperator CSO_cs = CSOperator.create("cs"); //$NON-NLS-1$
145:
146: static public final CSOperator CSO_Do = CSOperator.create("Do"); //$NON-NLS-1$
147:
148: static public final CSOperator CSO_TJ = CSOperator.create("TJ"); //$NON-NLS-1$
149:
150: static public final CSOperator CSO_Quote = CSOperator.create("'"); //$NON-NLS-1$
151:
152: static public final CSOperator CSO_DoubleQuote = CSOperator
153: .create("\""); //$NON-NLS-1$
154:
155: static public final CSOperator CSO_BDC = CSOperator.create("BDC"); //$NON-NLS-1$
156:
157: static public final CSOperator CSO_BI = CSOperator.create("BI"); //$NON-NLS-1$
158:
159: static public final CSOperator CSO_BX = CSOperator.create("BX"); //$NON-NLS-1$
160:
161: static public final CSOperator CSO_d0 = CSOperator.create("d0"); //$NON-NLS-1$
162:
163: static public final CSOperator CSO_d1 = CSOperator.create("d1"); //$NON-NLS-1$
164:
165: static public final CSOperator CSO_DP = CSOperator.create("DP"); //$NON-NLS-1$
166:
167: static public final CSOperator CSO_EI = CSOperator.create("EI"); //$NON-NLS-1$
168:
169: static public final CSOperator CSO_EX = CSOperator.create("EX"); //$NON-NLS-1$
170:
171: static public final CSOperator CSO_ID = CSOperator.create("ID"); //$NON-NLS-1$
172:
173: static public final CSOperator CSO_K = CSOperator.create("K"); //$NON-NLS-1$
174:
175: static public final CSOperator CSO_k = CSOperator.create("k"); //$NON-NLS-1$
176:
177: static public final CSOperator CSO_MP = CSOperator.create("MP"); //$NON-NLS-1$
178:
179: static public final CSOperator CSO_ri = CSOperator.create("ri"); //$NON-NLS-1$
180:
181: static public final CSOperator CSO_SC = CSOperator.create("SC"); //$NON-NLS-1$
182:
183: static public final CSOperator CSO_sc = CSOperator.create("sc"); //$NON-NLS-1$
184:
185: static public final CSOperator CSO_SCN = CSOperator.create("SCN"); //$NON-NLS-1$
186:
187: static public final CSOperator CSO_scn = CSOperator.create("scn"); //$NON-NLS-1$
188:
189: static public final CSOperator CSO_sh = CSOperator.create("sh"); //$NON-NLS-1$
190:
191: static public final List CSO_All = Arrays.asList(new CSOperator[] {
192: CSO_b, CSO_B, CSO_BDC, CSO_BI, CSO_BMC, CSO_bstar,
193: CSO_Bstar, CSO_BT, CSO_BX, CSO_c, CSO_cm, CSO_cs, CSO_CS,
194: CSO_d, CSO_d0, CSO_d1, CSO_Do, CSO_DoubleQuote, CSO_DP,
195: CSO_EI, CSO_EMC, CSO_ET, CSO_EX, CSO_f, CSO_F, CSO_fstar,
196: CSO_g, CSO_G, CSO_gs, CSO_h, CSO_i, CSO_ID, CSO_j, CSO_J,
197: CSO_k, CSO_K, CSO_l, CSO_m, CSO_M, CSO_MP, CSO_n, CSO_q,
198: CSO_Q, CSO_Quote, CSO_re, CSO_rg, CSO_RG, CSO_ri, CSO_s,
199: CSO_S, CSO_sc, CSO_scn, CSO_SC, CSO_SCN, CSO_sh, CSO_Tc,
200: CSO_Td, CSO_TD, CSO_Tf, CSO_Tj, CSO_TJ, CSO_TL, CSO_Tm,
201: CSO_Tr, CSO_Ts, CSO_Tstar, CSO_Tw, CSO_Tz, CSO_v, CSO_w,
202: CSO_W, CSO_Wstar, CSO_y });
203:
204: static private final Map descriptions = new HashMap();
205:
206: static {
207: descriptions
208: .put(CSO_b,
209: "close, fill and stroke path using nonzero winding rule"); //$NON-NLS-1$
210: descriptions.put(CSO_B,
211: "fill and stroke path using nonzero winding rule"); //$NON-NLS-1$
212: descriptions.put(CSO_bstar,
213: "close, fill and stroke path using even-odd rule"); //$NON-NLS-1$
214: descriptions.put(CSO_Bstar,
215: "fill and stroke path using even-odd rule"); //$NON-NLS-1$
216: descriptions.put(CSO_BDC,
217: "begin marked-content with property list"); //$NON-NLS-1$
218: descriptions.put(CSO_BI, "begin inline image"); //$NON-NLS-1$
219: descriptions.put(CSO_BMC, "begin marked content"); //$NON-NLS-1$
220: descriptions.put(CSO_BT, "begin text"); //$NON-NLS-1$
221: descriptions.put(CSO_BX, "gebin compatibility section"); //$NON-NLS-1$
222: descriptions.put(CSO_c,
223: "append curved segment (three control points)"); //$NON-NLS-1$
224: descriptions.put(CSO_cm,
225: "concatenate matrix to current transformation matrix"); //$NON-NLS-1$
226: descriptions.put(CSO_CS, "set color space for stroking"); //$NON-NLS-1$
227: descriptions.put(CSO_cs, "set color space for non stroking"); //$NON-NLS-1$
228: descriptions.put(CSO_d, "set line dash pattern"); //$NON-NLS-1$
229: descriptions.put(CSO_d0, "set glyph width in type 3 font"); //$NON-NLS-1$
230: descriptions.put(CSO_d1,
231: "set glyph width and bounding box in type 3 font"); //$NON-NLS-1$
232: descriptions.put(CSO_Do, "invoke named XObject"); //$NON-NLS-1$
233: descriptions.put(CSO_DP,
234: "define marked content point with property list"); //$NON-NLS-1$
235: descriptions.put(CSO_EI, "end inline image"); //$NON-NLS-1$
236: descriptions.put(CSO_EMC, "end marked content sequence"); //$NON-NLS-1$
237: descriptions.put(CSO_ET, "end text object"); //$NON-NLS-1$
238: descriptions.put(CSO_EX, "end compatibility section"); //$NON-NLS-1$
239: descriptions.put(CSO_f, "fill path using nonzero winding rule"); //$NON-NLS-1$
240: descriptions.put(CSO_F, "fill path using nonzero winding rule"); //$NON-NLS-1$
241: descriptions.put(CSO_fstar, "fill path using even-odd rule"); //$NON-NLS-1$
242: descriptions.put(CSO_G, "set gray level for stroking"); //$NON-NLS-1$
243: descriptions.put(CSO_g, "set gray level for nonstroking"); //$NON-NLS-1$
244: descriptions.put(CSO_gs,
245: "set parameters from graphics state parameter dict"); //$NON-NLS-1$
246: descriptions.put(CSO_h, "close subpath"); //$NON-NLS-1$
247: descriptions.put(CSO_i, "set flatness tolerance"); //$NON-NLS-1$
248: descriptions.put(CSO_ID, "bgein inline image data"); //$NON-NLS-1$
249: descriptions.put(CSO_j, "set line join style"); //$NON-NLS-1$
250: descriptions.put(CSO_J, "set line cap style"); //$NON-NLS-1$
251: descriptions.put(CSO_K, "set CMYK color for stroking"); //$NON-NLS-1$
252: descriptions.put(CSO_k, "set CMYK color for non stroking"); //$NON-NLS-1$
253: descriptions.put(CSO_l, "append straight line segment to path"); //$NON-NLS-1$
254: descriptions.put(CSO_m, "begin new subpath"); //$NON-NLS-1$
255: descriptions.put(CSO_M, "set miter limit"); //$NON-NLS-1$
256: descriptions.put(CSO_MP, "define marked content point"); //$NON-NLS-1$
257: descriptions.put(CSO_n, "end path without filling or stroking"); //$NON-NLS-1$
258: descriptions.put(CSO_q, "save graphics state"); //$NON-NLS-1$
259: descriptions.put(CSO_Q, "restore graphics state"); //$NON-NLS-1$
260: descriptions.put(CSO_re, "append rectangle to path"); //$NON-NLS-1$
261: descriptions.put(CSO_RG,
262: "set RGB color for stroking operations"); //$NON-NLS-1$
263: descriptions.put(CSO_rg,
264: "set RGB color for nonstroking operations"); //$NON-NLS-1$
265: descriptions.put(CSO_ri, "set color rendering intent"); //$NON-NLS-1$
266: descriptions.put(CSO_s, "close and stroke path"); //$NON-NLS-1$
267: descriptions.put(CSO_S, "stroke path"); //$NON-NLS-1$
268: descriptions.put(CSO_SC, "set color for stroking operations"); //$NON-NLS-1$
269: descriptions
270: .put(CSO_sc, "set color for nonstroking operations"); //$NON-NLS-1$
271: descriptions
272: .put(CSO_SCN,
273: "set color for stroking operations (ICCBased and special color spaces)"); //$NON-NLS-1$
274: descriptions
275: .put(CSO_scn,
276: "set color for nonstroking operations (ICCBased and special color spaces)"); //$NON-NLS-1$
277: descriptions.put(CSO_sh,
278: "paint area defined by shading pattern"); //$NON-NLS-1$
279: descriptions.put(CSO_Tstar, "move to start of next line"); //$NON-NLS-1$
280: descriptions.put(CSO_Tc, "set character spacing"); //$NON-NLS-1$
281: descriptions.put(CSO_Td, "move text position"); //$NON-NLS-1$
282: descriptions.put(CSO_TD, "move text position and set leading"); //$NON-NLS-1$
283: descriptions.put(CSO_Tf, "set text font and size"); //$NON-NLS-1$
284: descriptions.put(CSO_Tj, "show text"); //$NON-NLS-1$
285: descriptions.put(CSO_TJ,
286: "show text, allowing individual glyph positioning"); //$NON-NLS-1$
287: descriptions.put(CSO_TL, "set text leading"); //$NON-NLS-1$
288: descriptions
289: .put(CSO_Tm, "set text matrix and text line matrix"); //$NON-NLS-1$
290: descriptions.put(CSO_Tr, "set text rendering mode"); //$NON-NLS-1$
291: descriptions.put(CSO_Ts, "set text rise"); //$NON-NLS-1$
292: descriptions.put(CSO_Tw, "set word spacing"); //$NON-NLS-1$
293: descriptions.put(CSO_Tz, "set horizontal text spacing"); //$NON-NLS-1$
294: descriptions
295: .put(CSO_v,
296: "append curved segment to path (initial point replicated)"); //$NON-NLS-1$
297: descriptions.put(CSO_w, "set line width"); //$NON-NLS-1$
298: descriptions.put(CSO_W,
299: "set clipping path using nonzero winding rule"); //$NON-NLS-1$
300: descriptions.put(CSO_Wstar,
301: "set clipping path using even-odd rule"); //$NON-NLS-1$
302: descriptions
303: .put(CSO_y,
304: "append curved segment to path (final point rpelicated)"); //$NON-NLS-1$
305: descriptions.put(CSO_Quote, "move to next line and show text"); //$NON-NLS-1$
306: descriptions
307: .put(CSO_DoubleQuote,
308: "set word and character spacing, move to next line, show text"); //$NON-NLS-1$
309: }
310:
311: /**
312: * Enumeration class
313: */
314: private CSOperators() {
315: //
316: }
317:
318: public static String getDescription(CSOperator operator) {
319: String result = (String) descriptions.get(operator);
320: if (result == null) {
321: result = "<unkown>"; //$NON-NLS-1$
322: }
323: return result;
324: }
325: }
|