|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.javatools.editor.print.EditorPageable
The EditorPageable
is an implementation of the
Pageable
interface to support printed output of a
BasicDocument
optionally using the syntax highlighting
features of the editor framework.
Use the PrintOptions
class to control the appearance
of the printed output, whether we print out the syntax highlighting
foreground colors and font styles, line numbers, page numbers,
wrapping behavior, and so on. Note that this implementation will
not print out highlights, nor will it print out any background
colors. In case a syntax highlight foreground color is
Color.white
, black will be used in its place.
Field Summary |
Fields inherited from interface java.awt.print.Pageable |
UNKNOWN_NUMBER_OF_PAGES |
Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
EditorPageable(java.lang.String fileName,
BasicDocument document,
PrintOptions printOptions,
java.awt.print.PageFormat pageFormat)
Construct a new EditorPageable that will be used for
printing a document. |
Method Summary | |
int |
getNumberOfPages()
Returns the number of pages in the set. |
java.awt.print.PageFormat |
getPageFormat(int pageIndex)
Returns the PageFormat of the page specified by
pageIndex . |
java.awt.print.Printable |
getPrintable(int pageIndex)
Returns the Printable instance responsible for
rendering the page specified by pageIndex . |
protected void |
invalidate()
Invalidates our repagination info. |
protected boolean |
isPageIndexValid(int pageIndex)
Checks if a page index is valid. |
int |
print(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Prints the page at the specified index into the specified Graphics context in the specified format. |
protected void |
printHeader(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Print out the header for the printed output, based on the settings of the print options. |
protected void |
printLineNumbers(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Print out the line numbers on the left side of the page, depending on the settings in the print options. |
protected void |
printText(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Print out the text content in the main part of the page. |
protected void |
printWrappedSymbols(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Print out the wrapped symbols on the right, if we are performing line wrapping. |
void |
repaginate()
Force a repagination to occur. |
protected void |
repaginateIfNeeded()
Performs a repagination if we don't have any page info currently. |
void |
setPageFormat(java.awt.print.PageFormat pageFormat)
Changes the page format of the document for printing. |
void |
setPrintOptions(PrintOptions printOptions)
Sets the print options for printing. |
protected void |
verifyPageIndexValid(int pageIndex)
Verifies that a page index is valid. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EditorPageable(java.lang.String fileName, BasicDocument document, PrintOptions printOptions, java.awt.print.PageFormat pageFormat)
EditorPageable
that will be used for
printing a document. The specified file name is used for
printing the file header (if enabled), and the print options used
for controlling the appearance of the output. The
LanguageSupport
of the document will be used to
determine the syntax highlight rendering used.
fileName
- the name of the file for the file headerdocument
- the document to printprintOptions
- the printing options to useMethod Detail |
public void setPrintOptions(PrintOptions printOptions)
printOptions
- the print options to usepublic void setPageFormat(java.awt.print.PageFormat pageFormat)
public void repaginate()
protected void invalidate()
protected void repaginateIfNeeded()
protected boolean isPageIndexValid(int pageIndex)
pageIndex
- the page to check
protected void verifyPageIndexValid(int pageIndex) throws java.lang.IndexOutOfBoundsException
pageIndex
- the page to check
java.lang.IndexOutOfBoundsException
- if the page is invalidpublic int getNumberOfPages()
Pageable
implementations return the true number of pages rather than the
UNKNOWN_NUMBER_OF_PAGES constant.
getNumberOfPages
in interface java.awt.print.Pageable
Pageable
.public java.awt.print.PageFormat getPageFormat(int pageIndex) throws java.lang.IndexOutOfBoundsException
PageFormat
of the page specified by
pageIndex
.
getPageFormat
in interface java.awt.print.Pageable
pageIndex
- the zero based index of the page whose
PageFormat
is being requested
PageFormat
describing the size and
orientation.
IndexOutOfBoundsException
- the
Pageable
does not contain the requested page.
java.lang.IndexOutOfBoundsException
public java.awt.print.Printable getPrintable(int pageIndex) throws java.lang.IndexOutOfBoundsException
Printable
instance responsible for
rendering the page specified by pageIndex
.
getPrintable
in interface java.awt.print.Pageable
pageIndex
- the zero based index of the page whose
Printable
is being requested
Printable
that renders the page.
IndexOutOfBoundsException
- the
Pageable
does not contain the requested page.
java.lang.IndexOutOfBoundsException
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex) throws java.awt.print.PrinterException
Graphics
context in the specified format. A
PrinterJob
calls the Printable
interface to request that a page be rendered into the context
specified by graphics
. The format of the page to be
drawn is specified by pageFormat
. The zero based
index of the requested page is specified by
pageIndex
. If the requested page does not exist
then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is
returned. The Graphics
class or subclass implements
the PrinterGraphics
interface to provide additional
information. If the Printable
object aborts the
print job then it throws a PrinterException
.
print
in interface java.awt.print.Printable
graphics
- the context into which the page is drawnpageFormat
- the size and orientation of the page being drawnpageIndex
- the zero based index of the page to be drawn
pageIndex
specifies a
non-existent page.
java.awt.print.PrinterException
- thrown when the print job is terminated.protected void printHeader(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
graphics
- the context into which the page is drawnpageFormat
- the size and orientation of the page being drawnpageIndex
- the zero based index of the page to be drawnprotected void printLineNumbers(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
graphics
- the context into which the page is drawnpageFormat
- the size and orientation of the page being drawnpageIndex
- the zero based index of the page to be drawnprotected void printWrappedSymbols(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
graphics
- the context into which the page is drawnpageFormat
- the size and orientation of the page being drawnpageIndex
- the zero based index of the page to be drawnprotected void printText(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
graphics
- the context into which the page is drawnpageFormat
- the size and orientation of the page being drawnpageIndex
- the zero based index of the page to be drawn
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.