aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/print
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>2002-08-09 04:26:17 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2002-08-09 05:26:17 +0100
commit7bde45b2eb84502b62e77e46d947e46dcbd333d6 (patch)
treecdf9958b411887bead2263ea8ef0bdfc8eae6319 /libjava/java/awt/print
parent097684ce62b505168739fc98e952f92a8719a1fa (diff)
downloadgcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.zip
gcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.tar.gz
gcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.tar.bz2
AWT/Swing merge from GNU Classpath.
From-SVN: r56147
Diffstat (limited to 'libjava/java/awt/print')
-rw-r--r--libjava/java/awt/print/Book.java188
-rw-r--r--libjava/java/awt/print/PageFormat.java293
-rw-r--r--libjava/java/awt/print/Pageable.java113
-rw-r--r--libjava/java/awt/print/Paper.java236
-rw-r--r--libjava/java/awt/print/Printable.java90
-rw-r--r--libjava/java/awt/print/PrinterAbortException.java71
-rw-r--r--libjava/java/awt/print/PrinterException.java71
-rw-r--r--libjava/java/awt/print/PrinterGraphics.java61
-rw-r--r--libjava/java/awt/print/PrinterIOException.java98
-rw-r--r--libjava/java/awt/print/PrinterJob.java259
10 files changed, 1480 insertions, 0 deletions
diff --git a/libjava/java/awt/print/Book.java b/libjava/java/awt/print/Book.java
new file mode 100644
index 0000000..19014ba
--- /dev/null
+++ b/libjava/java/awt/print/Book.java
@@ -0,0 +1,188 @@
+/* Book.java -- A mixed group of pages to print.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+import java.util.Vector;
+
+/**
+ * This class allows documents to be created with different paper types,
+ * page formatters, and painters.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class Book implements Pageable
+{
+
+/*
+ * Instance Variables
+ */
+
+// Painter objects for the book
+Vector printables = new Vector();
+
+// Page formats for the book
+Vector page_formats = new Vector();
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>Book</code> that is empty.
+ */
+public
+Book()
+{
+ ;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the number of pages in this book.
+ *
+ * @return The number of pages in this book.
+ */
+public int
+getNumberOfPages()
+{
+ return(printables.size());
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the <code>PageFormat</code> object for the
+ * specified page.
+ *
+ * @param page_numbers The number of the page to get information for, where
+ * page numbers start at 0.
+ *
+ * @return The <code>PageFormat</code> object for the specified page.
+ *
+ * @exception IndexOutOfBoundsException If the page number is not valid.
+ */
+public PageFormat
+getPageFormat(int page_number)
+{
+ return((PageFormat)page_formats.elementAt(page_number));
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the <code>Printable</code> object for the
+ * specified page.
+ *
+ * @param page_numbers The number of the page to get information for, where
+ * page numbers start at 0.
+ *
+ * @return The <code>Printable</code> object for the specified page.
+ *
+ * @exception IndexOutOfBoundsException If the page number is not valid.
+ */
+public Printable
+getPrintable(int page_number)
+{
+ return((Printable)printables.elementAt(page_number));
+}
+
+/*************************************************************************/
+
+/**
+ * This method appends a page to the end of the book.
+ *
+ * @param printable The <code>Printable</code> for this page.
+ * @param page_format The <code>PageFormat</code> for this page.
+ *
+ * @exception NullPointerException If either argument is <code>null</code>.
+ */
+public void
+append(Printable printable, PageFormat page_format)
+{
+ append(printable, page_format, 1);
+}
+
+/*************************************************************************/
+
+/**
+ * This method appends the specified number of pages to the end of the book.
+ * Each one will be associated with the specified <code>Printable</code>
+ * and <code>PageFormat</code>.
+ *
+ * @param printable The <code>Printable</code> for this page.
+ * @param page_format The <code>PageFormat</code> for this page.
+ * @param num_pages The number of pages to append.
+ *
+ * @exception NullPointerException If any argument is <code>null</code>.
+ */
+public void
+append(Printable painter, PageFormat page_format, int num_pages)
+{
+ for (int i = 0; i < num_pages; i++)
+ {
+ printables.addElement(painter);
+ page_formats.addElement(page_format);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * This method changes the <code>Printable</code> and <code>PageFormat</code>
+ * for the specified page. The page must already exist or an exception
+ * will be thrown.
+ *
+ * @param page_num The page number to alter.
+ * @param printable The new <code>Printable</code> for the page.
+ * @param page_format The new <code>PageFormat</code> for the page.
+ *
+ * @param IndexOutOfBoundsException If the specified page does not exist.
+ */
+public void
+setPage(int page_num, Printable printable, PageFormat page_format)
+{
+ printables.setElementAt(printable, page_num);
+ page_formats.setElementAt(page_format, page_num);
+}
+
+} // class Book
+
diff --git a/libjava/java/awt/print/PageFormat.java b/libjava/java/awt/print/PageFormat.java
new file mode 100644
index 0000000..7328ab5
--- /dev/null
+++ b/libjava/java/awt/print/PageFormat.java
@@ -0,0 +1,293 @@
+/* PageFormat.java -- Information about the page format
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+/**
+ * This class contains information about the desired page format to
+ * use for printing a particular set of pages.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class PageFormat implements Cloneable
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * A constant for a landscaped page orientation. Used by
+ * <code>getOrientation</code> and <code>setOrientation</code>.
+ */
+public static final int LANDSCAPE = 0;
+
+/**
+ * A constant for a portrait page orientation. Used by
+ * <code>getOrientation</code> and <code>setOrientation</code>.
+ */
+public static final int PORTRAIT = 1;
+
+/**
+ * A constant for a reversed landscaped page orientation. This is
+ * the orientation used by Macintosh's for landscape. The origin is
+ * in the upper right hand corner instead of the upper left. The
+ * X and Y axes are reversed. Used by <code>getOrientation</code> and
+ * <code>setOrientation</code>.
+ */
+public static final int REVERSE_LANDSCAPE = 2;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+// The page orientation
+private int orientation;
+
+// The paper type
+private Paper paper;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * This method creates a default page layout, which will be in portrait
+ * format.
+ */
+public
+PageFormat()
+{
+ this.paper = new Paper();
+ this.orientation = PORTRAIT;
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * This method returns the width of the page, in 1/72nd's of an inch. The
+ * "width" measured depends on orientation.
+ *
+ * @return The width of the page.
+ */
+public double
+getWidth()
+{
+ return(paper.getWidth());
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the height of the page, in 1/72nd's of an inch.
+ * The "height" measured depends on the orientation.
+ *
+ * @return The height of the page.
+ */
+public double
+getHeight()
+{
+ return(paper.getHeight());
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the X coordinate value of the upper leftmost
+ * drawable area of the paper.
+ *
+ * @return The upper leftmost imageable X coordinate.
+ */
+public double
+getImageableX()
+{
+ return(paper.getImageableX());
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the Y coordinate value of the upper leftmost
+ * drawable area of the paper.
+ *
+ * @return The upper leftmost imageable Y coordinate.
+ */
+public double
+getImageableY()
+{
+ return(paper.getImageableY());
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the imageable width of the paper, in 1/72nd's of
+ * an inch.
+ *
+ * @return The imageable width of the paper.
+ */
+public double
+getImageableWidth()
+{
+ return(paper.getImageableWidth());
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the imageable height of the paper, in 1/72nd's of
+ * an inch.
+ *
+ * @return The imageable height of the paper.
+ */
+public double
+getImageableHeigth()
+{
+ return(paper.getImageableHeight());
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a copy of the <code>paper</code> object being used for this
+ * page format.
+ *
+ * @return A copy of the <code>Paper</code> object for this format.
+ */
+public Paper
+getPaper()
+{
+ return((Paper)paper.clone());
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the <code>Paper</code> object to be used by this page format.
+ *
+ * @param paper The new <code>Paper</code> object for this page format.
+ */
+public void
+setPaper(Paper paper)
+{
+ this.paper = paper;
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the current page orientation. The value returned
+ * will be one of the page orientation constants from this class.
+ *
+ * @return The current page orientation.
+ */
+public int
+getOrientation()
+{
+ return(orientation);
+}
+
+/*************************************************************************/
+
+/**
+ * This method sets the page orientation for this format to the
+ * specified value. It must be one of the page orientation constants
+ * from this class or an exception will be thrown.
+ *
+ * @param orientation The new page orientation.
+ *
+ * @exception IllegalArgumentException If the specified page orientation
+ * value is not one of the constants from this class.
+ */
+public void
+setOrientation(int orientation) throws IllegalArgumentException
+{
+ if ((orientation != PORTRAIT) &&
+ (orientation != LANDSCAPE) &&
+ (orientation != REVERSE_LANDSCAPE))
+ throw new IllegalArgumentException("Bad page orientation value: " +
+ orientation);
+
+ this.orientation = orientation;
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns a matrix used for transforming user space
+ * coordinates to page coordinates. The value returned will be six
+ * doubles as described in <code>java.awt.geom.AffineTransform</code>.
+ *
+ * @return The transformation matrix for this page format.
+ */
+public double[]
+getMatrix()
+{
+ throw new RuntimeException("Not implemented since I don't know what to do");
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns a copy of this object.
+ *
+ * @return A copy of this object.
+ */
+public Object
+clone()
+{
+ try
+ {
+ return(super.clone());
+ }
+ catch(CloneNotSupportedException e)
+ {
+ return(null);
+ }
+}
+
+} // class PageFormat
+
diff --git a/libjava/java/awt/print/Pageable.java b/libjava/java/awt/print/Pageable.java
new file mode 100644
index 0000000..fc631c5
--- /dev/null
+++ b/libjava/java/awt/print/Pageable.java
@@ -0,0 +1,113 @@
+/* Pageable.java -- Pages to be printed
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+/**
+ * This interface represents pages that are to be printed.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Pageable
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * This constant is returned when <code>getNumberOfPages()</code>
+ * cannot determine the number of pages available for printing.
+ */
+public static final int UNKNOWN_NUMBER_OF_PAGES = -1;
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * This method returns the number of pages this object contains, or
+ * <code>UNKNOWN_NUMBER_OF_PAGES</code> if it cannot determine the number
+ * of pages to be printed.
+ *
+ * @return The number of pages to be printed, or
+ * <code>UNKNOWN_NUMBER_OF_PAGES</code> if this is unknown.
+ */
+public abstract int
+getNumberOfPages();
+
+/*************************************************************************/
+
+/**
+ * This method returns the <code>PageFormat</code> instance for the
+ * specified page. Page numbers start at zero. An exception is thrown if
+ * the requested page does not exist.
+ *
+ * @param pageIndex The index of the page to return the
+ * <code>PageFormat</code> for.
+ *
+ * @return The <code>PageFormat</code> for the requested page.
+ *
+ * @exception IndexOutOfBoundsException If the requested page number does
+ * not exist.
+ */
+public abstract PageFormat
+getPageFormat(int pageIndex) throws IndexOutOfBoundsException;
+
+/*************************************************************************/
+
+/**
+ * This method returns the <code>Printable</code> instance for the
+ * specified page. Page numbers start at zero. An exception is thrown if
+ * the requested page does not exist.
+ *
+ * @param pageIndex The index of the page to return the
+ * <code>Printable</code> for.
+ *
+ * @return The <code>Printable</code> for the requested page.
+ *
+ * @exception IndexOutOfBoundsException If the requested page number does
+ * not exist.
+ */
+public abstract Printable
+getPrintable(int pageIndex) throws IndexOutOfBoundsException;
+
+} // interface Pageable
+
diff --git a/libjava/java/awt/print/Paper.java b/libjava/java/awt/print/Paper.java
new file mode 100644
index 0000000..cba4aec
--- /dev/null
+++ b/libjava/java/awt/print/Paper.java
@@ -0,0 +1,236 @@
+/* Paper.java -- Information about a paper type.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+/**
+ * This class describes a particular type of paper.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class Paper
+{
+
+/*
+ * Instance Variables
+ */
+
+// Height of the paper
+private double height;
+
+// Width of the paper
+private double width;
+
+// Upper left imageable X coordinate
+private double imageableX;
+
+// Upper left imageable Y coordinate
+private double imageableY;
+
+// Imageable width of the page
+private double imageableWidth;
+
+// Imageable height of the page
+private double imageableHeight;
+
+/*************************************************************************/
+
+/*
+ * Constructor
+ */
+
+/**
+ * This method creates a letter sized paper with one inch margins
+ */
+public
+Paper()
+{
+ width = 8.5 * 72;
+ height = 11 * 72;
+ imageableX = 72;
+ imageableY = 72;
+ imageableWidth = width - (2 * 72);
+ imageableHeight = height - (2 * 72);
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the height of the paper in 1/72nds of an inch.
+ *
+ * @return The height of the paper in 1/72nds of an inch.
+ */
+public double
+getHeight()
+{
+ return(height);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the width of the paper in 1/72nds of an inch.
+ *
+ * @return The width of the paper in 1/72nds of an inch.
+ */
+public double
+getWidth()
+{
+ return(width);
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the X coordinate of the upper left hand corner
+ * of the imageable area of the paper.
+ *
+ * @return The X coordinate of the upper left hand corner of the imageable
+ * area of the paper.
+ */
+public double
+getImageableX()
+{
+ return(imageableX);
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the Y coordinate of the upper left hand corner
+ * of the imageable area of the paper.
+ *
+ * @return The Y coordinate of the upper left hand corner of the imageable
+ * area of the paper.
+ */
+public double
+getImageableY()
+{
+ return(imageableY);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the width of the imageable area of the paper.
+ *
+ * @return The width of the imageable area of the paper.
+ */
+public double
+getImageableWidth()
+{
+ return(imageableWidth);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the height of the imageable area of the paper.
+ *
+ * @return The height of the imageable area of the paper.
+ */
+public double
+getImageableHeight()
+{
+ return(imageableHeight);
+}
+
+/*************************************************************************/
+
+/**
+ * This method sets the size of the paper to the specified width and
+ * height, which are specified in 1/72nds of an inch.
+ *
+ * @param width The width of the paper in 1/72nds of an inch.
+ * @param height The height of the paper in 1/72nds of an inch.
+ */
+public void
+setSize(double width, double height)
+{
+ this.width = width;
+ this.height = height;
+}
+
+/*************************************************************************/
+
+/**
+ * This method sets the imageable area of the paper by specifying the
+ * coordinates of the upper left hand corner of that area, and its
+ * length and height. All values are in 1/72nds of an inch.
+ *
+ * @param imageableX The X coordinate of the upper left hand corner of
+ * the imageable area, in 1/72nds of an inch.
+ * @param imageableY The Y coordinate of the upper left hand corner of
+ * the imageable area, in 1/72nds of an inch.
+ * @param imageableWidth The width of the imageable area of the paper,
+ * in 1/72nds of an inch.
+ * @param imageableHeight The heigth of the imageable area of the paper,
+ * in 1/72nds of an inch.
+ */
+public void
+setImageableArea(double imageableX, double imageableY,
+ double imageableWidth, double imageableHeight)
+{
+ this.imageableX = imageableX;
+ this.imageableY = imageableY;
+ this.imageableWidth = imageableWidth;
+ this.imageableHeight = imageableHeight;
+}
+
+/*************************************************************************/
+
+/**
+ * This method creates a copy of this object.
+ *
+ * @return A copy of this object.
+ */
+public Object
+clone()
+{
+ try
+ {
+ return(super.clone());
+ }
+ catch(CloneNotSupportedException e)
+ {
+ return(null);
+ }
+}
+
+} // class Paper
+
diff --git a/libjava/java/awt/print/Printable.java b/libjava/java/awt/print/Printable.java
new file mode 100644
index 0000000..8f3d0b6
--- /dev/null
+++ b/libjava/java/awt/print/Printable.java
@@ -0,0 +1,90 @@
+/* Printable.java -- Renders a page to the print device
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+import java.awt.Graphics;
+
+/**
+ * This interface provides a mechanism for the actual printing of pages to the
+ * printer. The object implementing this interface performs the page
+ * rendering.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Printable
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * This value is returned by the <code>print()</code> method to indicate
+ * that the requested page number does not exist.
+ */
+public static final int NO_SUCH_PAGE = 0;
+
+/**
+ * This value is returned by the <code>print()</code> method to indicate
+ * that the requested page exists and has been printed.
+ */
+public static final int PAGE_EXISTS = 1;
+
+/*************************************************************************/
+
+/**
+ * This method prints the specified page to the specified graphics
+ * context in the specified format. The pages are numbered starting
+ * from zero.
+ *
+ * @param graphics The graphics context to render the pages on.
+ * @param format The format in which to print the page.
+ * @param page_number The page number to print, where numbers start at zero.
+ *
+ * @return <code>PAGE_EXISTS</code> if the requested page exists and was
+ * successfully printed, <code>NO_SUCH_PAGE</code> otherwise.
+ *
+ * @exception PrinterException If an error occurs during printing.
+ */
+public abstract int
+print(Graphics graphics, PageFormat format, int page_number)
+ throws PrinterException;
+
+} // interface Printable
+
diff --git a/libjava/java/awt/print/PrinterAbortException.java b/libjava/java/awt/print/PrinterAbortException.java
new file mode 100644
index 0000000..133fdfe
--- /dev/null
+++ b/libjava/java/awt/print/PrinterAbortException.java
@@ -0,0 +1,71 @@
+/* PrinterAbortException.java -- Indicates the print job was aborted
+ Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+/**
+ * This exception is thrown when the print job is aborted, either by the
+ * user or by the application.
+ *
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ * @status updated to 1.4
+ */
+public class PrinterAbortException extends PrinterException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 4725169026278854136L;
+
+ /**
+ * Create a new instance with no detailed error message.
+ */
+ public PrinterAbortException()
+ {
+ }
+
+ /**
+ * Create a new instance with a descriptive error message.
+ *
+ * @param message the descriptive error message
+ */
+ public PrinterAbortException(String message)
+ {
+ super(message);
+ }
+} // class PrinterAbortException
diff --git a/libjava/java/awt/print/PrinterException.java b/libjava/java/awt/print/PrinterException.java
new file mode 100644
index 0000000..9476d93
--- /dev/null
+++ b/libjava/java/awt/print/PrinterException.java
@@ -0,0 +1,71 @@
+/* PrinterException.java -- generic problem in the printing subsystem
+ Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+/**
+ * This is the generic toplevel exception for printing errors. Subclasses
+ * provide more detailed descriptions of the problem.
+ *
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ * @status updated to 1.4
+ */
+public class PrinterException extends Exception
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -3757589981158265819L;
+
+ /**
+ * Create a new instance with no detailed error message.
+ */
+ public PrinterException()
+ {
+ }
+
+ /**
+ * Create a new instance with a descriptive error message.
+ *
+ * @param message the descriptive error message
+ */
+ public PrinterException(String message)
+ {
+ super(message);
+ }
+} // class PrinterException
diff --git a/libjava/java/awt/print/PrinterGraphics.java b/libjava/java/awt/print/PrinterGraphics.java
new file mode 100644
index 0000000..3615107
--- /dev/null
+++ b/libjava/java/awt/print/PrinterGraphics.java
@@ -0,0 +1,61 @@
+/* PrinterGraphics.java -- Hook to return print job controller.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+/**
+ * This interface is implemented by the <code>Graphics</code> instance
+ * that is used for rendering pages. It provides a hook to return the
+ * object that is controlling the print job.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface PrinterGraphics
+{
+
+/**
+ * This method returns the instance of <code>PrinterJob</code> that is
+ * controlling this print job.
+ *
+ * @return The <code>PrinterJob</code> that is controlling this print job.
+ */
+public abstract PrinterJob
+getPrinterJob();
+
+} // interface PrinterGraphics
+
diff --git a/libjava/java/awt/print/PrinterIOException.java b/libjava/java/awt/print/PrinterIOException.java
new file mode 100644
index 0000000..31f6381
--- /dev/null
+++ b/libjava/java/awt/print/PrinterIOException.java
@@ -0,0 +1,98 @@
+/* PrinterIOException.java -- The print job encountered an I/O error
+ Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+import java.io.IOException;
+
+/**
+ * This exception is thrown when the print job encounters an I/O problem
+ * of some kind.
+ *
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @status updated to 1.4
+ */
+public class PrinterIOException extends PrinterException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 5850870712125932846L;
+
+ /**
+ * The exception that caused this (duplicates Throwable).
+ *
+ * @serial the I/O exception that terminated the job
+ */
+ private final IOException mException;
+
+ /**
+ * Initializes a new instance with the given cause.
+ *
+ * @param mException the cause
+ */
+ public PrinterIOException(IOException mException)
+ {
+ super(mException == null ? null : mException.toString());
+ initCause(mException);
+ this.mException = mException;
+ }
+
+ /**
+ * Gets the underlying <code>IOException</code> that caused this exception.
+ * This legacy method has been replaced by {@link #getCause()}.
+ *
+ * @return the cause
+ */
+ public IOException getIOException()
+ {
+ return mException;
+ }
+
+ /**
+ * Gets the cause.
+ *
+ * @return the cause
+ */
+ public Throwable getCause()
+ {
+ return mException;
+ }
+} // class PrinterIOException
+
diff --git a/libjava/java/awt/print/PrinterJob.java b/libjava/java/awt/print/PrinterJob.java
new file mode 100644
index 0000000..b9e558c
--- /dev/null
+++ b/libjava/java/awt/print/PrinterJob.java
@@ -0,0 +1,259 @@
+/* PrinterJob.java -- This job is the printer control class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.print;
+
+/**
+ * This class controls printing.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract class PrinterJob
+{
+
+/*
+ * Class Methods
+ */
+
+/**
+ * Creates a new print job.
+ *
+ * @return A <code>PrinterJob</code> object for the newly created print job.
+ */
+public static PrinterJob
+getPrinterJob()
+{
+ // FIXME: Need to fix this to load a default implementation instance.
+ return(null);
+}
+
+/*************************************************************************/
+
+/*
+ * 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();
+
+/*************************************************************************/
+
+/**
+ * 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 String
+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();
+
+/*************************************************************************/
+
+/**
+ * Returns an instance of the default page which will have the default
+ * paper and orientation.
+ *
+ * @return A default instance of <code>PageFormat</code>.
+ */
+public PageFormat
+defaultPage()
+{
+ return(new PageFormat());
+}
+
+/*************************************************************************/
+
+/**
+ * Clones the specified <code>PageFormat</code> object then alters the
+ * clone so that it represents the default page format.
+ *
+ * @param page_format The <code>PageFormat</code> to clone.
+ *
+ * @return A new default page format.
+ */
+public abstract PageFormat
+defaultPage(PageFormat page_format);
+
+/*************************************************************************/
+
+/**
+ * Displays a dialog box to the user which allows the page format
+ * attributes to be modified.
+ *
+ * @param page_format The <code>PageFormat</code> object to modify.
+ *
+ * @return The modified <code>PageFormat</code>.
+ */
+public abstract PageFormat
+pageDialog(PageFormat page_format);
+
+/*************************************************************************/
+
+/**
+ * Prints the pages.
+ */
+public abstract void
+print();
+
+/**
+ * Displays a dialog box to the user which allows the print job
+ * attributes to be modified.
+ *
+ * @return <code>false</code> if the user cancels the dialog box,
+ * <code>true</code> otherwise.
+ */
+public abstract boolean
+printDialog();
+
+/*************************************************************************/
+
+/**
+ * This sets the pages that are to be printed.
+ *
+ * @param pageable The pages to be printed, which may not be <code>null</code>.
+ */
+public abstract void
+setPageable(Pageable pageable);
+
+/*************************************************************************/
+
+/**
+ * Sets this specified <code>Printable</code> as the one to use for
+ * rendering the pages on the print device.
+ *
+ * @param printable The <code>Printable</code> for the print job.
+ */
+public abstract void
+setPrintable(Printable printable);
+
+/*************************************************************************/
+
+/**
+ * Sets the <code>Printable</code> and the page format for the pages
+ * to be printed.
+ *
+ * @param printable The <code>Printable</code> for the print job.
+ * @param page_format The <code>PageFormat</code> for the print job.
+ */
+public abstract void
+setPrintable(Printable printable, PageFormat page_format);
+
+/*************************************************************************/
+
+/**
+ * Makes any alterations to the specified <code>PageFormat</code>
+ * necessary to make it work with the current printer. The alterations
+ * are made to a clone of the input object, which is then returned.
+ *
+ * @param page_format The <code>PageFormat</code> to validate.
+ *
+ * @return The validated <code>PageFormat</code>.
+ */
+public abstract PageFormat
+validatePage(PageFormat page);
+
+} // class PrinterJob
+