1 /* 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package javax.print.attribute.standard; 26 27 import javax.print.attribute.Attribute; 28 import javax.print.attribute.EnumSyntax; 29 import javax.print.attribute.DocAttribute; 30 import javax.print.attribute.PrintRequestAttribute; 31 import javax.print.attribute.PrintJobAttribute; 32 33 /** 34 * Class Finishings is a printing attribute class, an enumeration, that 35 * identifies whether the printer applies a finishing operation of some kind 36 * of binding to each copy of each printed document in the job. For multidoc 37 * print jobs (jobs with multiple documents), the 38 * {@link MultipleDocumentHandling 39 * MultipleDocumentHandling} attribute determines what constitutes a "copy" 40 * for purposes of finishing. 41 * <P> 42 * Standard Finishings values are: 43 * <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% SUMMARY="layout"> 44 * <TR> 45 * <TD STYLE="WIDTH:10%"> 46 * 47 * </TD> 48 * <TD STYLE="WIDTH:27%"> 49 * {@link #NONE NONE} 50 * </TD> 51 * <TD STYLE="WIDTH:27%"> 52 * {@link #STAPLE STAPLE} 53 * </TD> 54 * <TD STYLE="WIDTH:36%"> 55 * {@link #EDGE_STITCH EDGE_STITCH} 56 * </TD> 57 * </TR> 58 * <TR> 59 * <TD> 60 * 61 * </TD> 62 * <TD> 63 * {@link #BIND BIND} 64 * </TD> 65 * <TD> 66 * {@link #SADDLE_STITCH SADDLE_STITCH} 67 * </TD> 68 * <TD> 69 * {@link #COVER COVER} 70 * </TD> 71 * <TD> 72 * 73 * </TD> 74 * </TR> 75 * </TABLE> 76 * <P> 77 * The following Finishings values are more specific; they indicate a 78 * corner or an edge as if the document were a portrait document: 79 * <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% SUMMARY="layout"> 80 * <TR> 81 * <TD STYLE="WIDTH:10%"> 82 * 83 * </TD> 84 * <TD STYLE="WIDTH:27%"> 85 * {@link #STAPLE_TOP_LEFT STAPLE_TOP_LEFT} 86 * </TD> 87 * <TD STYLE="WIDTH:27%"> 88 * {@link #EDGE_STITCH_LEFT EDGE_STITCH_LEFT} 89 * </TD> 90 * <TD STYLE="WIDTH:27%"> 91 * {@link #STAPLE_DUAL_LEFT STAPLE_DUAL_LEFT} 92 * </TD> 93 * <TD STYLE="WIDTH:9%"> 94 * 95 * </TD> 96 * </TR> 97 * <TR> 98 * <TD STYLE="WIDTH:10%"> 99 * 100 * </TD> 101 * <TD STYLE="WIDTH:27%"> 102 * {@link #STAPLE_BOTTOM_LEFT STAPLE_BOTTOM_LEFT} 103 * </TD> 104 * <TD STYLE="WIDTH:27%"> 105 * {@link #EDGE_STITCH_TOP EDGE_STITCH_TOP} 106 * </TD> 107 * <TD STYLE="WIDTH:27%"> 108 * {@link #STAPLE_DUAL_TOP STAPLE_DUAL_TOP} 109 * </TD> 110 * <TD STYLE="WIDTH:9%"> 111 * 112 * </TD> 113 * </TR> 114 * <TR> 115 * <TD STYLE="WIDTH:10%"> 116 * 117 * </TD> 118 * <TD STYLE="WIDTH:27%"> 119 * {@link #STAPLE_TOP_RIGHT STAPLE_TOP_RIGHT} 120 * </TD> 121 * <TD STYLE="WIDTH:27%"> 122 * {@link #EDGE_STITCH_RIGHT EDGE_STITCH_RIGHT} 123 * </TD> 124 * <TD STYLE="WIDTH:27%"> 125 * {@link #STAPLE_DUAL_RIGHT STAPLE_DUAL_RIGHT} 126 * </TD> 127 * <TD STYLE="WIDTH:9%"> 128 * 129 * </TD> 130 * </TR> 131 * <TR> 132 * <TD STYLE="WIDTH:10%"> 133 * 134 * </TD> 135 * <TD STYLE="WIDTH:27%"> 136 * {@link #STAPLE_BOTTOM_RIGHT STAPLE_BOTTOM_RIGHT} 137 * </TD> 138 * <TD STYLE="WIDTH:27%"> 139 * {@link #EDGE_STITCH_BOTTOM EDGE_STITCH_BOTTOM} 140 * </TD> 141 * <TD STYLE="WIDTH:27%"> 142 * {@link #STAPLE_DUAL_BOTTOM STAPLE_DUAL_BOTTOM} 143 * </TD> 144 * <TD STYLE="WIDTH:9%"> 145 * 146 * </TD> 147 * </TR> 148 * </TABLE> 149 * <P> 150 * The STAPLE_<I>XXX</I> values are specified with respect to the 151 * document as if the document were a portrait document. If the document is 152 * actually a landscape or a reverse-landscape document, the client supplies the 153 * appropriate transformed value. For example, to position a staple in the upper 154 * left hand corner of a landscape document when held for reading, the client 155 * supplies the STAPLE_BOTTOM_LEFT value (since landscape is 156 * defined as a +90 degree rotation from portrait, i.e., anti-clockwise). On the 157 * other hand, to position a staple in the upper left hand corner of a 158 * reverse-landscape document when held for reading, the client supplies the 159 * STAPLE_TOP_RIGHT value (since reverse-landscape is defined as a 160 * -90 degree rotation from portrait, i.e., clockwise). 161 * <P> 162 * The angle (vertical, horizontal, angled) of each staple with respect to the 163 * document depends on the implementation which may in turn depend on the value 164 * of the attribute. 165 * <P> 166 * The effect of a Finishings attribute on a multidoc print job (a job 167 * with multiple documents) depends on whether all the docs have the same 168 * binding specified or whether different docs have different bindings 169 * specified, and on the (perhaps defaulted) value of the {@link 170 * MultipleDocumentHandling MultipleDocumentHandling} attribute. 171 * <UL> 172 * <LI> 173 * If all the docs have the same binding specified, then any value of {@link 174 * MultipleDocumentHandling MultipleDocumentHandling} makes sense, and the 175 * printer's processing depends on the {@link MultipleDocumentHandling 176 * MultipleDocumentHandling} value: 177 * <UL> 178 * <LI> 179 * SINGLE_DOCUMENT -- All the input docs will be bound together as one output 180 * document with the specified binding. 181 * 182 * <LI> 183 * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be bound together as one 184 * output document with the specified binding, and the first impression of each 185 * input doc will always start on a new media sheet. 186 * 187 * <LI> 188 * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will be bound 189 * separately with the specified binding. 190 * 191 * <LI> 192 * SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each input doc will be bound separately 193 * with the specified binding. 194 * </UL> 195 * 196 * <LI> 197 * If different docs have different bindings specified, then only two values of 198 * {@link MultipleDocumentHandling MultipleDocumentHandling} make sense, and the 199 * printer reports an error when the job is submitted if any other value is 200 * specified: 201 * <UL> 202 * <LI> 203 * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will be bound 204 * separately with its own specified binding. 205 * 206 * <LI> 207 * SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each input doc will be bound separately 208 * with its own specified binding. 209 * </UL> 210 * </UL> 211 * <P> 212 * <B>IPP Compatibility:</B> Class Finishings encapsulates some of the 213 * IPP enum values that can be included in an IPP "finishings" attribute, which 214 * is a set of enums. The category name returned by 215 * <CODE>getName()</CODE> is the IPP attribute name. The enumeration's 216 * integer value is the IPP enum value. The <code>toString()</code> method 217 * returns the IPP string representation of the attribute value. 218 * In IPP Finishings is a multi-value attribute, this API currently allows 219 * only one binding to be specified. 220 * 221 * @author Alan Kaminsky 222 */ 223 public class Finishings extends EnumSyntax 224 implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { 225 226 private static final long serialVersionUID = -627840419548391754L; 227 228 /** 229 * Perform no binding. 230 */ 231 public static final Finishings NONE = new Finishings(3); 232 233 /** 234 * Bind the document(s) with one or more staples. The exact number and 235 * placement of the staples is site-defined. 236 */ 237 public static final Finishings STAPLE = new Finishings(4); 238 239 /** 240 * This value is specified when it is desired to select a non-printed (or 241 * pre-printed) cover for the document. This does not supplant the 242 * specification of a printed cover (on cover stock medium) by the 243 * document itself. 244 */ 245 public static final Finishings COVER = new Finishings(6); 246 247 /** 248 * This value indicates that a binding is to be applied to the document; 249 * the type and placement of the binding is site-defined. 250 */ 251 public static final Finishings BIND = new Finishings(7); 252 253 /** 254 * Bind the document(s) with one or more staples (wire stitches) along the 255 * middle fold. The exact number and placement of the staples and the 256 * middle fold is implementation- and/or site-defined. 257 */ 258 public static final Finishings SADDLE_STITCH = 259 new Finishings(8); 260 261 /** 262 * Bind the document(s) with one or more staples (wire stitches) along one 263 * edge. The exact number and placement of the staples is implementation- 264 * and/or site- defined. 265 */ 266 public static final Finishings EDGE_STITCH = 267 new Finishings(9); 268 269 /** 270 * Bind the document(s) with one or more staples in the top left corner. 271 */ 272 public static final Finishings STAPLE_TOP_LEFT = 273 new Finishings(20); 274 275 /** 276 * Bind the document(s) with one or more staples in the bottom left 277 * corner. 278 */ 279 public static final Finishings STAPLE_BOTTOM_LEFT = 280 new Finishings(21); 281 282 /** 283 * Bind the document(s) with one or more staples in the top right corner. 284 */ 285 public static final Finishings STAPLE_TOP_RIGHT = 286 new Finishings(22); 287 288 /** 289 * Bind the document(s) with one or more staples in the bottom right 290 * corner. 291 */ 292 public static final Finishings STAPLE_BOTTOM_RIGHT = 293 new Finishings(23); 294 295 /** 296 * Bind the document(s) with one or more staples (wire stitches) along the 297 * left edge. The exact number and placement of the staples is 298 * implementation- and/or site-defined. 299 */ 300 public static final Finishings EDGE_STITCH_LEFT = 301 new Finishings(24); 302 303 /** 304 * Bind the document(s) with one or more staples (wire stitches) along the 305 * top edge. The exact number and placement of the staples is 306 * implementation- and/or site-defined. 307 */ 308 public static final Finishings EDGE_STITCH_TOP = 309 new Finishings(25); 310 311 /** 312 * Bind the document(s) with one or more staples (wire stitches) along the 313 * right edge. The exact number and placement of the staples is 314 * implementation- and/or site-defined. 315 */ 316 public static final Finishings EDGE_STITCH_RIGHT = 317 new Finishings(26); 318 319 /** 320 * Bind the document(s) with one or more staples (wire stitches) along the 321 * bottom edge. The exact number and placement of the staples is 322 * implementation- and/or site-defined. 323 */ 324 public static final Finishings EDGE_STITCH_BOTTOM = 325 new Finishings(27); 326 327 /** 328 * Bind the document(s) with two staples (wire stitches) along the left 329 * edge assuming a portrait document (see above). 330 */ 331 public static final Finishings STAPLE_DUAL_LEFT = 332 new Finishings(28); 333 334 /** 335 * Bind the document(s) with two staples (wire stitches) along the top 336 * edge assuming a portrait document (see above). 337 */ 338 public static final Finishings STAPLE_DUAL_TOP = 339 new Finishings(29); 340 341 /** 342 * Bind the document(s) with two staples (wire stitches) along the right 343 * edge assuming a portrait document (see above). 344 */ 345 public static final Finishings STAPLE_DUAL_RIGHT = 346 new Finishings(30); 347 348 /** 349 * Bind the document(s) with two staples (wire stitches) along the bottom 350 * edge assuming a portrait document (see above). 351 */ 352 public static final Finishings STAPLE_DUAL_BOTTOM = 353 new Finishings(31); 354 355 /** 356 * Construct a new finishings binding enumeration value with the given 357 * integer value. 358 * 359 * @param value Integer value. 360 */ 361 protected Finishings(int value) { 362 super(value); 363 } 364 365 private static final String[] myStringTable = 366 {"none", 367 "staple", 368 null, 369 "cover", 370 "bind", 371 "saddle-stitch", 372 "edge-stitch", 373 null, // The next ten enum values are reserved. 374 null, 375 null, 376 null, 377 null, 378 null, 379 null, 380 null, 381 null, 382 null, 383 "staple-top-left", 384 "staple-bottom-left", 385 "staple-top-right", 386 "staple-bottom-right", 387 "edge-stitch-left", 388 "edge-stitch-top", 389 "edge-stitch-right", 390 "edge-stitch-bottom", 391 "staple-dual-left", 392 "staple-dual-top", 393 "staple-dual-right", 394 "staple-dual-bottom" 395 }; 396 397 private static final Finishings[] myEnumValueTable = 398 {NONE, 399 STAPLE, 400 null, 401 COVER, 402 BIND, 403 SADDLE_STITCH, 404 EDGE_STITCH, 405 null, // The next ten enum values are reserved. 406 null, 407 null, 408 null, 409 null, 410 null, 411 null, 412 null, 413 null, 414 null, 415 STAPLE_TOP_LEFT, 416 STAPLE_BOTTOM_LEFT, 417 STAPLE_TOP_RIGHT, 418 STAPLE_BOTTOM_RIGHT, 419 EDGE_STITCH_LEFT, 420 EDGE_STITCH_TOP, 421 EDGE_STITCH_RIGHT, 422 EDGE_STITCH_BOTTOM, 423 STAPLE_DUAL_LEFT, 424 STAPLE_DUAL_TOP, 425 STAPLE_DUAL_RIGHT, 426 STAPLE_DUAL_BOTTOM 427 }; 428 429 /** 430 * Returns the string table for class Finishings. 431 */ 432 protected String[] getStringTable() { 433 return (String[])myStringTable.clone(); 434 } 435 436 /** 437 * Returns the enumeration value table for class Finishings. 438 */ 439 protected EnumSyntax[] getEnumValueTable() { 440 return (EnumSyntax[])myEnumValueTable.clone(); 441 } 442 443 /** 444 * Returns the lowest integer value used by class Finishings. 445 */ 446 protected int getOffset() { 447 return 3; 448 } 449 450 /** 451 * Get the printing attribute class which is to be used as the "category" 452 * for this printing attribute value. 453 * <P> 454 * For class Finishings and any vendor-defined subclasses, the 455 * category is class Finishings itself. 456 * 457 * @return Printing attribute class (category), an instance of class 458 * {@link java.lang.Class java.lang.Class}. 459 */ 460 public final Class<? extends Attribute> getCategory() { 461 return Finishings.class; 462 } 463 464 /** 465 * Get the name of the category of which this attribute value is an 466 * instance. 467 * <P> 468 * For class Finishings and any vendor-defined subclasses, the 469 * category name is <CODE>"finishings"</CODE>. 470 * 471 * @return Attribute category name. 472 */ 473 public final String getName() { 474 return "finishings"; 475 } 476 477 }