OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [java/] [awt/] [print/] [PrinterJob.java] - Blame information for rev 771

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 771 jeremybenn
/* PrinterJob.java -- This job is the printer control class
2
   Copyright (C) 1999, 2004, 2005, 2006  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package java.awt.print;
40
 
41
import gnu.java.awt.print.JavaPrinterJob;
42
 
43
import java.awt.HeadlessException;
44
import javax.print.PrintService;
45
import javax.print.PrintServiceLookup;
46
import javax.print.DocFlavor;
47
import javax.print.StreamPrintServiceFactory;
48
import javax.print.attribute.PrintRequestAttributeSet;
49
 
50
/**
51
 * This class controls printing.
52
 *
53
 * @author Aaron M. Renn (arenn@urbanophile.com)
54
 */
55
public abstract class PrinterJob
56
{
57
  // The print service associated with this job
58
  private PrintService printer = null;
59
 
60
  /**
61
   * Creates a new print job.
62
   *
63
   * @return A <code>PrinterJob</code> object for the newly created print job.
64
   */
65
  public static PrinterJob getPrinterJob()
66
  {
67
    return new JavaPrinterJob();
68
  }
69
 
70
  /**
71
   * Initializes a new instance of <code>PrinterJob</code>.
72
   */
73
  public PrinterJob()
74
  {
75
  }
76
 
77
  /**
78
   * Returns the number of copies to be printed.
79
   *
80
   * @return The number of copies to be printed.
81
   */
82
  public abstract int getCopies();
83
 
84
  /**
85
   * Sets the number of copies to be printed.
86
   *
87
   * @param copies The number of copies to be printed.
88
   */
89
  public abstract void setCopies(int copies);
90
 
91
  /**
92
   * Returns the name of the print job.
93
   *
94
   * @return The name of the print job.
95
   */
96
  public abstract String getJobName();
97
 
98
  /**
99
   * Sets the name of the print job.
100
   *
101
   * @param job_name The name of the print job.
102
   */
103
  public abstract void setJobName(String job_name);
104
 
105
  /**
106
   * Returns the printing user name.
107
   *
108
   * @return The printing username.
109
   */
110
  public abstract String getUserName();
111
 
112
  /**
113
   * Cancels an in progress print job.
114
   */
115
  public abstract void cancel();
116
 
117
  /**
118
   * Tests whether or not this job has been cancelled.
119
   *
120
   * @return <code>true</code> if this job has been cancelled, <code>false</code>
121
   * otherwise.
122
   */
123
  public abstract boolean isCancelled();
124
 
125
  /**
126
   * Returns an instance of the default page which will have the default
127
   * paper and orientation.
128
   *
129
   * @return A default instance of <code>PageFormat</code>.
130
   */
131
  public PageFormat defaultPage()
132
  {
133
    return new PageFormat();
134
  }
135
 
136
  /**
137
   * Clones the specified <code>PageFormat</code> object then alters the
138
   * clone so that it represents the default page format.
139
   *
140
   * @param page_format The <code>PageFormat</code> to clone.
141
   *
142
   * @return A new default page format.
143
   */
144
  public abstract PageFormat defaultPage(PageFormat page_format);
145
 
146
  /**
147
   * Displays a dialog box to the user which allows the page format
148
   * attributes to be modified.
149
   *
150
   * @param page_format The <code>PageFormat</code> object to modify.
151
   *
152
   * @return The modified <code>PageFormat</code>.
153
   */
154
  public abstract PageFormat pageDialog(PageFormat page_format)
155
    throws HeadlessException;
156
 
157
  /**
158
   * @since 1.4
159
   */
160
  public PageFormat pageDialog(PrintRequestAttributeSet attributes)
161
    throws HeadlessException
162
  {
163
    // FIXME: Implement this for real.
164
    return pageDialog((PageFormat) null);
165
  }
166
 
167
  /**
168
   * Prints the pages.
169
   */
170
  public abstract void print () throws PrinterException;
171
 
172
  /**
173
   * Prints the page with given attributes.
174
   */
175
  public void print (PrintRequestAttributeSet attributes)
176
    throws PrinterException
177
  {
178
    print ();
179
  }
180
 
181
  /**
182
   * Displays a dialog box to the user which allows the print job
183
   * attributes to be modified.
184
   *
185
   * @return <code>false</code> if the user cancels the dialog box,
186
   * <code>true</code> otherwise.
187
   */
188
  public abstract boolean printDialog()
189
    throws HeadlessException;
190
 
191
  /**
192
   * Displays a dialog box to the user which allows the print job
193
   * attributes to be modified.
194
   *
195
   * @return <code>false</code> if the user cancels the dialog box,
196
   * <code>true</code> otherwise.
197
   */
198
  public boolean printDialog(PrintRequestAttributeSet attributes)
199
    throws HeadlessException
200
  {
201
    // FIXME: Implement this for real.
202
    return printDialog();
203
  }
204
 
205
  /**
206
   * This sets the pages that are to be printed.
207
   *
208
   * @param pageable The pages to be printed, which may not be <code>null</code>.
209
   */
210
  public abstract void setPageable(Pageable pageable);
211
 
212
  /**
213
   * Sets this specified <code>Printable</code> as the one to use for
214
   * rendering the pages on the print device.
215
   *
216
   * @param printable The <code>Printable</code> for the print job.
217
   */
218
  public abstract void setPrintable(Printable printable);
219
 
220
  /**
221
   * Sets the <code>Printable</code> and the page format for the pages
222
   * to be printed.
223
   *
224
   * @param printable The <code>Printable</code> for the print job.
225
   * @param page_format The <code>PageFormat</code> for the print job.
226
   */
227
  public abstract void setPrintable(Printable printable, PageFormat page_format);
228
 
229
  /**
230
   * Makes any alterations to the specified <code>PageFormat</code>
231
   * necessary to make it work with the current printer.  The alterations
232
   * are made to a clone of the input object, which is then returned.
233
   *
234
   * @param page_format The <code>PageFormat</code> to validate.
235
   *
236
   * @return The validated <code>PageFormat</code>.
237
   */
238
  public abstract PageFormat validatePage(PageFormat page_format);
239
 
240
  /**
241
   * Find and return 2D image print services.
242
   *
243
   * This is the same as calling PrintServiceLookup.lookupPrintServices()
244
   * with Pageable service-specified DocFlavor.
245
   * @return Array of PrintService objects, could be empty.
246
   * @since 1.4
247
   */
248
  public static PrintService[] lookupPrintServices()
249
  {
250
    return PrintServiceLookup.lookupPrintServices
251
      (
252
       new DocFlavor("application/x-java-jvm-local-objectref",
253
                     "java.awt.print.Pageable"),
254
       null);
255
  }
256
 
257
  /**
258
   * Find and return 2D image stream print services.
259
   *
260
   * This is the same as calling
261
   * StreamPrintServiceFactory.lookupStreamPrintServices()
262
   * with Pageable service-specified DocFlavor.
263
   * @param mimeType The output format mime type, or null for any type.
264
   * @return Array of stream print services, could be empty.
265
   * @since 1.4
266
   */
267
  public static StreamPrintServiceFactory[]
268
    lookupStreamPrintServices(String mimeType)
269
  {
270
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
271
      DocFlavor.SERVICE_FORMATTED.PAGEABLE, mimeType);
272
  }
273
 
274
  /**
275
   * Return the printer for this job.  If print services aren't supported by
276
   * the subclass, returns null.
277
   *
278
   * @return The associated PrintService.
279
   * @since 1.4
280
   */
281
  public PrintService getPrintService()
282
  {
283
    return printer;
284
  }
285
 
286
  /**
287
   * Change the printer for this print job to service.  Subclasses that
288
   * support setting the print service override this method.  Throws
289
   * PrinterException when the class doesn't support setting the printer,
290
   * the service doesn't support Pageable or Printable interfaces for 2D
291
   * print output.
292
   * @param service The new printer to use.
293
   * @throws PrinterException if service is not valid.
294
   */
295
  public void setPrintService(PrintService service)
296
    throws PrinterException
297
  {
298
    printer = service;
299
  }
300
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.