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