Class printer

java.lang.Object
  extended by printer
All Implemented Interfaces:
java.awt.print.Printable

public class printer
extends java.lang.Object
implements java.awt.print.Printable

Print class provides functionalities of printing the images. It holds a private BufferedImage image that is initialized once it is passed through the constructor. It holds one method called print which is executed if the variable param is passed in as 0. Otherwise it throws a printerException. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


Field Summary
(package private)  java.awt.image.BufferedImage image
          Contains the image to be printed.
(package private)  java.awt.print.PageFormat pageFormat
          Indicates the type of page format to be printed.
(package private)  TerpPaint parent
          TerpPaint object used to print functionality.
(package private)  java.awt.print.PrinterJob printerJob
          Describes the printer job.
(package private)  javax.swing.JFrame view
          Print preview frame.
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
printer(java.awt.Frame Parent)
          Constructs the BufferedImage that is passed in to image.
 
Method Summary
 void pageSetup()
          Provides the preferred size and source to be printed.
 void preview()
          Shows the previewed image before printing.
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat page, int param)
          Prints the images if the param is passed in as 0.
 void printTo()
          Prints the selected image.
 void setImage(java.awt.image.BufferedImage imageToPrint)
          Sets the buffered image to be printed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

image

java.awt.image.BufferedImage image
Contains the image to be printed.


pageFormat

java.awt.print.PageFormat pageFormat
Indicates the type of page format to be printed.


printerJob

java.awt.print.PrinterJob printerJob
Describes the printer job.


view

javax.swing.JFrame view
Print preview frame.


parent

TerpPaint parent
TerpPaint object used to print functionality.

Constructor Detail

printer

public printer(java.awt.Frame Parent)
Constructs the BufferedImage that is passed in to image. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
Parent - Frame type that sets the field "image" to it.
Method Detail

print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat page,
                 int param)
          throws java.awt.print.PrinterException
Prints the images if the param is passed in as 0. The xMargin and yMargin are doubles. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Specified by:
print in interface java.awt.print.Printable
Parameters:
graphics - Is casted to a Graphics2D and set to the variable g.
page - Indicates the selection of page format.
param - Must be set to 0 to print. Otherwise the page does not exist and throws an exception.
Returns:
the int PAGE_EXISTS. not found in this class
Throws:
java.awt.print.PrinterException - if param is not 0 or unable to print within margins

pageSetup

public void pageSetup()
Provides the preferred size and source to be printed. Also, orientation is provided such as portrait or landscape type. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


setImage

public void setImage(java.awt.image.BufferedImage imageToPrint)
Sets the buffered image to be printed. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
imageToPrint - BufferedImage to be set and printed.

printTo

public void printTo()
Prints the selected image. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


preview

public void preview()
Shows the previewed image before printing. On preview frame, user can choose either print or close the preview window. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.