[gui] Add PrinterJob methods

Jerry Quinn jlquinn@optonline.net
Mon Nov 15 05:21:00 GMT 2004


2004-11-15  Jerry Quinn  <jlquinn@optonline.net>

	* java/awt/print/PrinterJob.java (lookupPrintServices,
	getPrintService, setPrintService): Implement.
	(lookupStreamPrintServices): Add commented out implementation.
	(printer): New field.

Index: PrinterJob.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/print/PrinterJob.java,v
retrieving revision 1.3.20.1
retrieving revision 1.3.20.2
diff -u -r1.3.20.1 -r1.3.20.2
--- PrinterJob.java	10 Nov 2004 07:19:47 -0000	1.3.20.1
+++ PrinterJob.java	15 Nov 2004 05:19:15 -0000	1.3.20.2
@@ -37,6 +37,7 @@


  package java.awt.print;
+import javax.print.PrintService;
  import javax.print.attribute.PrintRequestAttributeSet;

  /**
@@ -46,6 +47,8 @@
    */
  public abstract class PrinterJob
  {
+  // The print service associated with this job
+  private PrintService printer = null;

  /*
   * Class Methods
@@ -258,5 +261,72 @@
  public abstract PageFormat
  validatePage(PageFormat page);

+  /**
+   * Find and return 2D image print services.
+   *
+   * This is the same as calling PrintServiceLookup.lookupPrintServices()
+   * with Pageable service-specified DocFlavor.
+   * @return Array of PrintService objects, could be empty.
+   * @since 1.4
+   */
+  public static PrintService[] lookupPrintServices()
+  {
+    return new PrintService[0];
+    // FIXME:
+    // Enable this when javax.print has this implemented.
+//    return PrintServiceLookup.lookupPrintServices(
+//          new DocFlavor("application/x-java-jvm-local-objectref",
+//                        "java.awt.print.Pageable"),
+//          null);
+  }
+
+  /**
+   * Find and return 2D image stream print services.
+   *
+   * This is the same as calling
+   * StreamPrintServiceFactory.lookupStreamPrintServices()
+   * with Pageable service-specified DocFlavor.
+   * @param mimeType The output format mime type, or null for any type.
+   * @return Array of stream print services, could be empty.
+   * @since 1.4
+   */
+  	// FIXME:
+  	// Enable when javax.print has StreamPrintServiceFactory
+//  public static StreamPrintServiceFactory[] 
lookupStreamPrintServices(String mimeType)
+//  {
+//    return StreamPrintServiceFactory.lookupStreamServiceFactories(
+//      new DocFlavor("application/x-java-jvm-local-objectref",
+//      "java.awt.print.Pageable"),
+//    	mimeType);
+//  }
+
+  /**
+   * Return the printer for this job.  If print services aren't supported by
+   * the subclass, returns null.
+   *
+   * @return The associated PrintService.
+   * @since 1.4
+   */
+  public PrintService getPrintService()
+  {
+    return null;
+  }
+
+
+  /**
+   * Change the printer for this print job to service.  Subclasses that
+   * support setting the print service override this method.  Throws
+   * PrinterException when the class doesn't support setting the printer,
+   * the service doesn't support Pageable or Printable interfaces for 2D
+   * print output.
+   * @param service The new printer to use.
+   * @throws PrinterException if service is not valid.
+   */
+  public void setPrintService(PrintService service)
+    throws PrinterException
+  {
+    throw new PrinterException();
+  }
+
  } // class PrinterJob




More information about the Java-patches mailing list