Initial revision

From-SVN: r102074
This commit is contained in:
Tom Tromey
2005-07-16 00:30:23 +00:00
parent 6f4434b39b
commit f911ba985a
4557 changed files with 1000262 additions and 0 deletions
+159
View File
@@ -0,0 +1,159 @@
/* Book.java -- A mixed group of pages to print.
Copyright (C) 1999, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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
{
/**
* Painter objects for the book.
*/
Vector printables = new Vector();
/**
* Page formats for the book.
*/
Vector page_formats = new Vector();
/**
* 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_number 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_number 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 printable, PageFormat page_format, int num_pages)
{
for (int i = 0; i < num_pages; i++)
{
printables.addElement(printable);
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.
*
* @throws 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);
}
}
@@ -0,0 +1,292 @@
/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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 getImageableHeight()
{
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
@@ -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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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.
*/
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.
*/
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.
*/
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.
*/
Printable
getPrintable(int pageIndex) throws IndexOutOfBoundsException;
} // interface Pageable
+236
View File
@@ -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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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 implements Cloneable
{
/*
* 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
@@ -0,0 +1,80 @@
/* Printable.java -- Renders a page to the print device
Copyright (C) 1999, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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
{
/**
* This value is returned by the <code>print()</code> method to indicate
* that the requested page exists and has been printed.
*/
int PAGE_EXISTS = 0;
/**
* This value is returned by the <code>print()</code> method to indicate
* that the requested page number does not exist.
*/
int NO_SUCH_PAGE = 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.
*/
int print(Graphics graphics, PageFormat format, int page_number)
throws PrinterException;
}
@@ -0,0 +1,71 @@
/* PrinterAbortException.java -- Indicates the print job was aborted
Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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
@@ -0,0 +1,71 @@
/* PrinterException.java -- generic problem in the printing subsystem
Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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
@@ -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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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.
*/
PrinterJob
getPrinterJob();
} // interface PrinterGraphics
@@ -0,0 +1,98 @@
/* PrinterIOException.java -- The print job encountered an I/O error
Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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
@@ -0,0 +1,299 @@
/* PrinterJob.java -- This job is the printer control class
Copyright (C) 1999, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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.HeadlessException;
import javax.print.PrintService;
import javax.print.attribute.PrintRequestAttributeSet;
/**
* This class controls printing.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public abstract class PrinterJob
{
// The print service associated with this job
private PrintService printer = null;
/**
* 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;
}
/**
* Initializes a new instance of <code>PrinterJob</code>.
*/
public PrinterJob()
{
}
/**
* 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.
*
* @return <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)
throws HeadlessException;
/**
* @since 1.4
*/
public PageFormat pageDialog(PrintRequestAttributeSet attributes)
throws HeadlessException
{
// FIXME: Implement this for real.
return pageDialog((PageFormat) null);
}
/**
* Prints the pages.
*/
public abstract void print () throws PrinterException;
/**
* Prints the page with given attributes.
*/
public abstract void print (PrintRequestAttributeSet attributes)
throws PrinterException;
/**
* 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()
throws HeadlessException;
/**
* 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 boolean printDialog(PrintRequestAttributeSet attributes)
throws HeadlessException
{
// FIXME: Implement this for real.
return 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_format);
/**
* 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();
}
}
@@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in java.awt.print package.
Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 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. -->
<html>
<head><title>GNU Classpath - java.awt.print</title></head>
<body>
<p>Classes for printer jobs, pages, paper sizes, graphics and formats.</p>
</body>
</html>