1 |
/* PrinterJob.java -- This job is the printer control class |
/* PrinterJob.java -- This job is the printer control class |
2 |
Copyright (C) 1999 Free Software Foundation, Inc. |
Copyright (C) 1999, 2004 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
37 |
|
|
38 |
|
|
39 |
package java.awt.print; |
package java.awt.print; |
40 |
|
|
41 |
|
import javax.print.DocFlavor; |
42 |
import javax.print.PrintService; |
import javax.print.PrintService; |
43 |
|
import javax.print.PrintServiceLookup; |
44 |
|
//import javax.print.StreamPrintServiceFactory; |
45 |
import javax.print.attribute.PrintRequestAttributeSet; |
import javax.print.attribute.PrintRequestAttributeSet; |
46 |
|
|
47 |
/** |
/** |
48 |
* This class controls printing. |
* This class controls printing. |
49 |
* |
* |
50 |
* @author Aaron M. Renn (arenn@urbanophile.com) |
* @author Aaron M. Renn (arenn@urbanophile.com) |
51 |
*/ |
*/ |
52 |
public abstract class PrinterJob |
public abstract class PrinterJob |
53 |
{ |
{ |
54 |
// The print service associated with this job |
// The print service associated with this job |
55 |
private PrintService printer = null; |
private PrintService printer = null; |
56 |
|
|
57 |
/* |
/** |
58 |
* Class Methods |
* Creates a new print job. |
59 |
*/ |
* |
60 |
|
* @return A <code>PrinterJob</code> object for the newly created print job. |
61 |
/** |
*/ |
62 |
* Creates a new print job. |
public static PrinterJob getPrinterJob() |
63 |
* |
{ |
|
* @return A <code>PrinterJob</code> object for the newly created print job. |
|
|
*/ |
|
|
public static PrinterJob |
|
|
getPrinterJob() |
|
|
{ |
|
64 |
// FIXME: Need to fix this to load a default implementation instance. |
// FIXME: Need to fix this to load a default implementation instance. |
65 |
return(null); |
return null; |
66 |
} |
} |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/* |
|
|
* Constructors |
|
|
*/ |
|
|
|
|
|
/** |
|
|
* Initializes a new instance of <code>PrinterJob</code>. |
|
|
*/ |
|
|
public |
|
|
PrinterJob() |
|
|
{ |
|
|
; |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/* |
|
|
* Instance Methods |
|
|
*/ |
|
|
|
|
|
/** |
|
|
* Returns the number of copies to be printed. |
|
|
* |
|
|
* @return The number of copies to be printed. |
|
|
*/ |
|
|
public abstract int |
|
|
getCopies(); |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Sets the number of copies to be printed. |
|
|
* |
|
|
* @param copies The number of copies to be printed. |
|
|
*/ |
|
|
public abstract void setCopies (int copies); |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns the name of the print job. |
|
|
* |
|
|
* @return The name of the print job. |
|
|
*/ |
|
|
public abstract String |
|
|
getJobName(); |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Sets the name of the print job. |
|
|
* |
|
|
* @param job_name The name of the print job. |
|
|
*/ |
|
|
public abstract void setJobName (String job_name); |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns the printing user name. |
|
|
* |
|
|
* @return The printing username. |
|
|
*/ |
|
|
public abstract String |
|
|
getUserName(); |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Cancels an in progress print job. |
|
|
*/ |
|
|
public abstract void |
|
|
cancel(); |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Tests whether or not this job has been cancelled. |
|
|
* |
|
|
* @param <code>true</code> if this job has been cancelled, <code>false</code> |
|
|
* otherwise. |
|
|
*/ |
|
|
public abstract boolean |
|
|
isCancelled(); |
|
67 |
|
|
68 |
/*************************************************************************/ |
/** |
69 |
|
* Initializes a new instance of <code>PrinterJob</code>. |
70 |
|
*/ |
71 |
|
public PrinterJob() |
72 |
|
{ |
73 |
|
} |
74 |
|
|
75 |
/** |
/** |
76 |
* Returns an instance of the default page which will have the default |
* Returns the number of copies to be printed. |
77 |
* paper and orientation. |
* |
78 |
* |
* @return The number of copies to be printed. |
79 |
* @return A default instance of <code>PageFormat</code>. |
*/ |
80 |
*/ |
public abstract int getCopies(); |
|
public PageFormat |
|
|
defaultPage() |
|
|
{ |
|
|
return(new PageFormat()); |
|
|
} |
|
81 |
|
|
82 |
/*************************************************************************/ |
/** |
83 |
|
* Sets the number of copies to be printed. |
84 |
|
* |
85 |
|
* @param copies The number of copies to be printed. |
86 |
|
*/ |
87 |
|
public abstract void setCopies(int copies); |
88 |
|
|
89 |
/** |
/** |
90 |
* Clones the specified <code>PageFormat</code> object then alters the |
* Returns the name of the print job. |
91 |
* clone so that it represents the default page format. |
* |
92 |
* |
* @return The name of the print job. |
93 |
* @param page_format The <code>PageFormat</code> to clone. |
*/ |
94 |
* |
public abstract String getJobName(); |
|
* @return A new default page format. |
|
|
*/ |
|
|
public abstract PageFormat |
|
|
defaultPage(PageFormat page_format); |
|
95 |
|
|
96 |
/*************************************************************************/ |
/** |
97 |
|
* Sets the name of the print job. |
98 |
|
* |
99 |
|
* @param job_name The name of the print job. |
100 |
|
*/ |
101 |
|
public abstract void setJobName(String job_name); |
102 |
|
|
103 |
/** |
/** |
104 |
* Displays a dialog box to the user which allows the page format |
* Returns the printing user name. |
105 |
* attributes to be modified. |
* |
106 |
* |
* @return The printing username. |
107 |
* @param page_format The <code>PageFormat</code> object to modify. |
*/ |
108 |
* |
public abstract String getUserName(); |
|
* @return The modified <code>PageFormat</code>. |
|
|
*/ |
|
|
public abstract PageFormat |
|
|
pageDialog(PageFormat page_format); |
|
109 |
|
|
110 |
/*************************************************************************/ |
/** |
111 |
|
* Cancels an in progress print job. |
112 |
|
*/ |
113 |
|
public abstract void cancel(); |
114 |
|
|
115 |
/** |
/** |
116 |
* Prints the pages. |
* Tests whether or not this job has been cancelled. |
117 |
*/ |
* |
118 |
public abstract void print () throws PrinterException; |
* @return <code>true</code> if this job has been cancelled, <code>false</code> |
119 |
public abstract void print (PrintRequestAttributeSet attributes) throws PrinterException; |
* otherwise. |
120 |
|
*/ |
121 |
|
public abstract boolean isCancelled(); |
122 |
|
|
123 |
|
/** |
124 |
|
* Returns an instance of the default page which will have the default |
125 |
|
* paper and orientation. |
126 |
|
* |
127 |
|
* @return A default instance of <code>PageFormat</code>. |
128 |
|
*/ |
129 |
|
public PageFormat defaultPage() |
130 |
|
{ |
131 |
|
return new PageFormat(); |
132 |
|
} |
133 |
|
|
134 |
/** |
/** |
135 |
* Displays a dialog box to the user which allows the print job |
* Clones the specified <code>PageFormat</code> object then alters the |
136 |
* attributes to be modified. |
* clone so that it represents the default page format. |
137 |
* |
* |
138 |
* @return <code>false</code> if the user cancels the dialog box, |
* @param page_format The <code>PageFormat</code> to clone. |
139 |
* <code>true</code> otherwise. |
* |
140 |
*/ |
* @return A new default page format. |
141 |
public abstract boolean |
*/ |
142 |
printDialog(); |
public abstract PageFormat defaultPage(PageFormat page_format); |
143 |
|
|
144 |
public abstract boolean |
/** |
145 |
printDialog(PrintRequestAttributeSet attributes); |
* Displays a dialog box to the user which allows the page format |
146 |
|
* attributes to be modified. |
147 |
|
* |
148 |
|
* @param page_format The <code>PageFormat</code> object to modify. |
149 |
|
* |
150 |
|
* @return The modified <code>PageFormat</code>. |
151 |
|
*/ |
152 |
|
public abstract PageFormat pageDialog(PageFormat page_format); |
153 |
|
|
154 |
/*************************************************************************/ |
/** |
155 |
|
* Prints the pages. |
156 |
|
*/ |
157 |
|
public abstract void print () throws PrinterException; |
158 |
|
|
159 |
/** |
/** |
160 |
* This sets the pages that are to be printed. |
* Prints the page with given attributes. |
161 |
* |
*/ |
162 |
* @param pageable The pages to be printed, which may not be <code>null</code>. |
public abstract void print (PrintRequestAttributeSet attributes) |
163 |
*/ |
throws PrinterException; |
|
public abstract void |
|
|
setPageable(Pageable pageable); |
|
164 |
|
|
165 |
/*************************************************************************/ |
/** |
166 |
|
* Displays a dialog box to the user which allows the print job |
167 |
|
* attributes to be modified. |
168 |
|
* |
169 |
|
* @return <code>false</code> if the user cancels the dialog box, |
170 |
|
* <code>true</code> otherwise. |
171 |
|
*/ |
172 |
|
public abstract boolean printDialog(); |
173 |
|
|
174 |
/** |
/** |
175 |
* Sets this specified <code>Printable</code> as the one to use for |
* Displays a dialog box to the user which allows the print job |
176 |
* rendering the pages on the print device. |
* attributes to be modified. |
177 |
* |
* |
178 |
* @param printable The <code>Printable</code> for the print job. |
* @return <code>false</code> if the user cancels the dialog box, |
179 |
*/ |
* <code>true</code> otherwise. |
180 |
public abstract void |
*/ |
181 |
setPrintable(Printable printable); |
public abstract boolean printDialog(PrintRequestAttributeSet attributes); |
182 |
|
|
183 |
/*************************************************************************/ |
/** |
184 |
|
* This sets the pages that are to be printed. |
185 |
|
* |
186 |
|
* @param pageable The pages to be printed, which may not be <code>null</code>. |
187 |
|
*/ |
188 |
|
public abstract void setPageable(Pageable pageable); |
189 |
|
|
190 |
/** |
/** |
191 |
* Sets the <code>Printable</code> and the page format for the pages |
* Sets this specified <code>Printable</code> as the one to use for |
192 |
* to be printed. |
* rendering the pages on the print device. |
193 |
* |
* |
194 |
* @param printable The <code>Printable</code> for the print job. |
* @param printable The <code>Printable</code> for the print job. |
195 |
* @param page_format The <code>PageFormat</code> for the print job. |
*/ |
196 |
*/ |
public abstract void setPrintable(Printable printable); |
|
public abstract void |
|
|
setPrintable(Printable printable, PageFormat page_format); |
|
197 |
|
|
198 |
/*************************************************************************/ |
/** |
199 |
|
* Sets the <code>Printable</code> and the page format for the pages |
200 |
|
* to be printed. |
201 |
|
* |
202 |
|
* @param printable The <code>Printable</code> for the print job. |
203 |
|
* @param page_format The <code>PageFormat</code> for the print job. |
204 |
|
*/ |
205 |
|
public abstract void setPrintable(Printable printable, PageFormat page_format); |
206 |
|
|
207 |
/** |
/** |
208 |
* Makes any alterations to the specified <code>PageFormat</code> |
* Makes any alterations to the specified <code>PageFormat</code> |
209 |
* necessary to make it work with the current printer. The alterations |
* necessary to make it work with the current printer. The alterations |
210 |
* are made to a clone of the input object, which is then returned. |
* are made to a clone of the input object, which is then returned. |
211 |
* |
* |
212 |
* @param page_format The <code>PageFormat</code> to validate. |
* @param page_format The <code>PageFormat</code> to validate. |
213 |
* |
* |
214 |
* @return The validated <code>PageFormat</code>. |
* @return The validated <code>PageFormat</code>. |
215 |
*/ |
*/ |
216 |
public abstract PageFormat |
public abstract PageFormat validatePage(PageFormat page_format); |
|
validatePage(PageFormat page); |
|
217 |
|
|
218 |
/** |
/** |
219 |
* Find and return 2D image print services. |
* Find and return 2D image print services. |
266 |
return null; |
return null; |
267 |
} |
} |
268 |
|
|
|
|
|
269 |
/** |
/** |
270 |
* Change the printer for this print job to service. Subclasses that |
* Change the printer for this print job to service. Subclasses that |
271 |
* support setting the print service override this method. Throws |
* support setting the print service override this method. Throws |
280 |
{ |
{ |
281 |
throw new PrinterException(); |
throw new PrinterException(); |
282 |
} |
} |
283 |
|
} |
|
} // class PrinterJob |
|
|
|
|