01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * 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, 7); //DMBIN_AUTO
43: static final Win32MediaTray TRACTOR = new Win32MediaTray(2, 8); //DMBIN_TRACTOR
44: static final Win32MediaTray SMALL_FORMAT = new Win32MediaTray(3, 9); //DMBIN_SMALLFMT
45: static final Win32MediaTray LARGE_FORMAT = new Win32MediaTray(4, 10); //DMBIN_LARGEFMT
46: static final Win32MediaTray FORMSOURCE = new Win32MediaTray(5, 15); //DMBIN_FORMSOURCE
47:
48: private static ArrayList winStringTable = new ArrayList();
49: private static ArrayList winEnumTable = new ArrayList();
50: public int winID;
51:
52: private Win32MediaTray(int value, int id) {
53: super (value);
54: winID = id;
55: }
56:
57: private synchronized static int nextValue(String name) {
58: winStringTable.add(name);
59: return (getTraySize() - 1);
60: }
61:
62: protected Win32MediaTray(int id, String name) {
63: super (nextValue(name));
64: winID = id;
65: winEnumTable.add(this );
66: }
67:
68: private static final String[] myStringTable = { "Manual-Envelope",
69: "Automatic-Feeder", "Tractor-Feeder", "Small-Format",
70: "Large-Format", "Form-Source", };
71:
72: private static final MediaTray[] myEnumValueTable = {
73: ENVELOPE_MANUAL, AUTO, TRACTOR, SMALL_FORMAT, LARGE_FORMAT,
74: FORMSOURCE, };
75:
76: protected static int getTraySize() {
77: return (myStringTable.length + winStringTable.size());
78: }
79:
80: protected String[] getStringTable() {
81: ArrayList completeList = new ArrayList();
82: for (int i = 0; i < myStringTable.length; i++) {
83: completeList.add(myStringTable[i]);
84: }
85: completeList.addAll(winStringTable);
86: String[] nameTable = new String[completeList.size()];
87: return (String[]) completeList.toArray(nameTable);
88: }
89:
90: protected EnumSyntax[] getEnumValueTable() {
91: ArrayList completeList = new ArrayList();
92: for (int i = 0; i < myEnumValueTable.length; i++) {
93: completeList.add(myEnumValueTable[i]);
94: }
95: completeList.addAll(winEnumTable);
96: MediaTray[] enumTable = new MediaTray[completeList.size()];
97: return (MediaTray[]) completeList.toArray(enumTable);
98: }
99: }
|