J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2002 Sun Microsystems, Inc. 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. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package sun.print; |
| 27 | |
| 28 | import javax.print.attribute.standard.MediaTray; |
| 29 | import javax.print.attribute.EnumSyntax; |
| 30 | import java.util.ArrayList; |
| 31 | |
| 32 | /** |
| 33 | * Class Win32MediaTray is a subclass of MediaTray which declares |
| 34 | * Windows media trays or bins not covered by MediaTray's standard values. |
| 35 | * It also implements driver-defined trays. |
| 36 | **/ |
| 37 | |
| 38 | public class Win32MediaTray extends MediaTray { |
| 39 | |
| 40 | static final Win32MediaTray ENVELOPE_MANUAL = new Win32MediaTray(0, |
| 41 | 6); //DMBIN_ENVMANUAL |
| 42 | static final Win32MediaTray AUTO = new Win32MediaTray(1, |
| 43 | 7); //DMBIN_AUTO |
| 44 | static final Win32MediaTray TRACTOR = new Win32MediaTray(2, |
| 45 | 8); //DMBIN_TRACTOR |
| 46 | static final Win32MediaTray SMALL_FORMAT = new Win32MediaTray(3, |
| 47 | 9); //DMBIN_SMALLFMT |
| 48 | static final Win32MediaTray LARGE_FORMAT = new Win32MediaTray(4, |
| 49 | 10); //DMBIN_LARGEFMT |
| 50 | static final Win32MediaTray FORMSOURCE = new Win32MediaTray(5, |
| 51 | 15); //DMBIN_FORMSOURCE |
| 52 | |
| 53 | private static ArrayList winStringTable = new ArrayList(); |
| 54 | private static ArrayList winEnumTable = new ArrayList(); |
| 55 | public int winID; |
| 56 | |
| 57 | private Win32MediaTray(int value, int id) { |
| 58 | super (value); |
| 59 | winID = id; |
| 60 | } |
| 61 | |
| 62 | private synchronized static int nextValue(String name) { |
| 63 | winStringTable.add(name); |
| 64 | return (getTraySize()-1); |
| 65 | } |
| 66 | |
| 67 | protected Win32MediaTray(int id, String name) { |
| 68 | super (nextValue(name)); |
| 69 | winID = id; |
| 70 | winEnumTable.add(this); |
| 71 | } |
| 72 | |
| 73 | private static final String[] myStringTable ={ |
| 74 | "Manual-Envelope", |
| 75 | "Automatic-Feeder", |
| 76 | "Tractor-Feeder", |
| 77 | "Small-Format", |
| 78 | "Large-Format", |
| 79 | "Form-Source", |
| 80 | }; |
| 81 | |
| 82 | private static final MediaTray[] myEnumValueTable = { |
| 83 | ENVELOPE_MANUAL, |
| 84 | AUTO, |
| 85 | TRACTOR, |
| 86 | SMALL_FORMAT, |
| 87 | LARGE_FORMAT, |
| 88 | FORMSOURCE, |
| 89 | }; |
| 90 | |
| 91 | protected static int getTraySize() { |
| 92 | return (myStringTable.length+winStringTable.size()); |
| 93 | } |
| 94 | |
| 95 | protected String[] getStringTable() { |
| 96 | ArrayList completeList = new ArrayList(); |
| 97 | for (int i=0; i < myStringTable.length; i++) { |
| 98 | completeList.add(myStringTable[i]); |
| 99 | } |
| 100 | completeList.addAll(winStringTable); |
| 101 | String[] nameTable = new String[completeList.size()]; |
| 102 | return (String[])completeList.toArray(nameTable); |
| 103 | } |
| 104 | |
| 105 | protected EnumSyntax[] getEnumValueTable() { |
| 106 | ArrayList completeList = new ArrayList(); |
| 107 | for (int i=0; i < myEnumValueTable.length; i++) { |
| 108 | completeList.add(myEnumValueTable[i]); |
| 109 | } |
| 110 | completeList.addAll(winEnumTable); |
| 111 | MediaTray[] enumTable = new MediaTray[completeList.size()]; |
| 112 | return (MediaTray[])completeList.toArray(enumTable); |
| 113 | } |
| 114 | } |