Oracle Fusion Middleware Java API Reference for Oracle Data Visualization Components
11g Release 1 (11.1.1.4.0)

E12063-05

oracle.dss.graph
Class GraphPrinter

java.lang.Object
  extended by oracle.dss.dataView.ViewPrinter
      extended by oracle.dss.graph.GraphPrinter
All Implemented Interfaces:
java.awt.print.Printable, UIViewPrinter

public class GraphPrinter
extends ViewPrinter

Printer for a Graph. When you use the PrintDialog object from the oracle.dss.dataView.gui package, you do not need to call the methods in this class. When you use your own UI, you call methods on this GraphPrinter to specify how to print a Graph and to print the Graph. If you assume responsibility for page layout and calculation, you cannot use the PrintDialog; you must call methods on this GraphPrinter to print.

The following example shows how to print a Graph, using the oracle.dss.dataView.gui.PrintDialog.

    GraphPrinter printer = new GraphPrinter();
    //One way to get a frame in which to display the Print dialog
    Frame frame = oracle.bali.ewt.util.WindowUtils.parentFrame(graph);
    PrintDialog dialog = new PrintDialog(frame, printer);
    dialog.show();
    dialog.dispose();
    dialog = null;
 

The printing APIs in this class are based on Java 2D printing API. AWT Printing is not supported.

See Also:
ViewPrinter, oracle.dss.dataView.gui.PrintDialog

Nested Class Summary
 
Nested classes/interfaces inherited from class oracle.dss.dataView.ViewPrinter
ViewPrinter.HPosWrapper
 
Field Summary
 
Fields inherited from class oracle.dss.dataView.ViewPrinter
_callback, ABOVE_FOOTER, ADJUST_FOR_HEADERS_AND_FOOTERS, ALL_LOGICAL_PAGES, BELOW_HEADER, BOTTOM_FORMATTED_TEXT_AREA, bottomFTAHeight, bottomMargin, callbackMask, CenterFooter, CenterHeader, CURRENT_LOGICAL_PAGE, currentLogicalPage, currLogPage, dataUnavailableMsg, dataView, dimension, fitToNumPagesTall, fitToNumPagesWide, FOOTER_CENTER, FOOTER_LEFT, FOOTER_RIGHT, footerHeight, footnote, FOOTNOTE, footnoteHeight, GRIDVIEW_COLUMN_HEADER, GRIDVIEW_ROW_HEADER, HEADER_CENTER, HEADER_LEFT, HEADER_RIGHT, headerHeight, HEADERS_AND_FOOTERS_ALL, HEADERS_AND_FOOTERS_NONE, IGNORE_HEADERS_AND_FOOTERS, LeftFooter, LeftHeader, leftMargin, logicalPage, m_aboveFooterWidth, m_belowHeaderWidth, m_bottomFormattedText, m_bPreviewMode, m_graphPrintScaleType, m_gridlinesVisible, m_gridViewPrintScaleType, m_insuffSpace, m_pageFormat, m_repeatComponents, m_selectedHPos, m_seqPageNumber, m_tokenSubstitution, m_topFormattedText, MarginAdjustment, MIN_PRINT_ZOOM_FACTOR, OCCLUDE_HEADERS_AND_FOOTERS, oldBottomFTASize, oldFootnoteSize, oldSubtitleSize, oldTitleSize, oldTopFTASize, ORIGINAL_SIZE, PAGE_HEADER, PAGING_CONTROL_GAP, paperHeight, paperWidth, pIndex, printableHeight, printableWidth, printByColumns, printZoomFactor, rangeType, record, repeatAdornHeight, resize, RightFooter, RightHeader, rightMargin, SCALE_TO_FIT_FULL_PAGE, SCALE_TO_FIT_PAGE, SCALE_TO_FIT_PAGES, SCALE_TO_ZOOM_FACTOR, SELECTED_LOGICAL_PAGES, subSetRecord, subtitle, SUBTITLE, subtitleHeight, TEXT_COMPONENTS_ALL, TEXT_COMPONENTS_NONE, title, TITLE, titleHeight, TOP_FORMATTED_TEXT_AREA, topFTAHeight, topMargin, totalAdornHeight, UNIT_CM, UNIT_INCHES, UNIT_PIXELS, units, viewDim, viewLogPage, viewLogPageNum
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface oracle.dss.dataView.UIViewPrinter
CROSSTAB_PRINTER, GRAPH_PRINTER, TABLE_PRINTER, WORKSHEET_WITH_CROSSTAB_AND_GRAPH_PRINTER, WORKSHEET_WITH_CROSSTAB_PRINTER, WORKSHEET_WITH_GRAPH_PRINTER, WORKSHEET_WITH_TABLE_AND_GRAPH_PRINTER, WORKSHEET_WITH_TABLE_PRINTER
 
Constructor Summary
GraphPrinter(Graph g)
          Constructor.
 
Method Summary
protected  boolean checkForNoData()
           
 void endPrint()
          Sets the Graph back to its original state.
protected  void fetchAllData()
           
 Graph getGraph()
          Retrieves the Graph that this GraphPrinter prints.
 int getScaleFontSize()
          Retrieves which text components should be resized when the Graph is scaled to a different size for printing.
 int getViewPrinterType()
          Retrieves the type of ViewPrinter.
 boolean goToFirstPage()
          Deprecated. As of 1.6.0.9, replaced by prepareFirstPage(Graphics)
 boolean goToNextPage()
          Deprecated. As of 1.6.0.9, replaced by prepareNextPage(Graphics)
 boolean goToPrevPage()
          Deprecated. As of 1.6.0.9, replaced by preparePrevPage(Graphics)
 boolean hasNextPage()
          Indicates whether the view has a physical page after the current physical page.
 boolean hasPrevPage()
          Indicates whether the view has a physical page before the current physical page.
 boolean isFirstPhysicalPage()
          Indicates whether the current physical page is the first physical page in the current logical page.
 boolean isLastPhysicalPage()
          Indicates whether the current physical page is the last physical page in the current logical page.
 boolean prepareFirstPage(java.awt.Graphics g)
          Prepares the first physical page in the graph for printing and makes it the current page to print.
 boolean prepareNextPage(java.awt.Graphics g)
          Prepares the next physical page for printing and makes it the current page to print.
 boolean preparePrevPage(java.awt.Graphics g)
          Prepares the previous physical page for printing and makes it the current page to print.
 boolean printPage(java.awt.Graphics g)
          Prints the Graph to a Graphics object.
protected  void printPages(java.awt.PrintJob pjob, boolean currentLogPage)
          Deprecated. As of 3.2.0.16, replaced by 2D printing API
protected  void printToGraphics(java.awt.Graphics g, PaginationRecord record)
           
protected  void resetCurrentLogicalPage()
           
protected  void setDataview(Dataview dv)
           
 void setGraph(Graph graph)
          Specifies the Graph that this GraphPrinter should print.
 boolean setLogicalPage(int[] hPos)
          Specifies the logical page to print, when you use the printPage method to print.
 void setScaleFontSize(int mask)
          Specifies which text components should be resized when the graph is scaled to a different size for printing.
 boolean startPrint()
          Puts the Graph in a state for printing.
 boolean startPrint(boolean bPreviewMode)
          Puts the Graph in a state for printing.
 
Methods inherited from class oracle.dss.dataView.ViewPrinter
adjustMargins, calcAdornmentsDimension, calcHeaderAndFooterHeights, calcMargins, changePageEdgeCurrentHPos, checkDataSourceLogPage, fetchRowBlock, getBottomMargin, getCustomHeaderAndFooterCallback, getDataview, getDefaultCursor, getFitToNumPagesTall, getFitToNumPagesWide, getFooterMargin, getFooterPainter, getGraphPrintScaleType, getGridViewPrintScaleType, getHeaderAndFooterPainter, getHeaderMargin, getHeaderPainter, getHeadersAndFootersUsingCallback, getLeftMargin, getLineWidth, getLocale, getLogicalPage, getLogicalPageInUse, getMarginAdjustment, getPageFormat, getPrintJob, getPrintScaleType, getPrintZoomFactor, getRangeType, getRightMargin, getSelectedHPos, getSequentialPageNumber, getTokenSubstitution, getTopMargin, getUnits, getViewDimension, getWaitCursor, goToFirstPage, goToLastPage, isDataviewFootnoteVisible, isDataviewSubtitleVisible, isDataviewTitleVisible, isGridlinesVisible, isPrintByColumns, isRepeatComponent, isRepeatHeaders, print, print, print, printHeaderAndFooter, renderFirstPage, renderLastPage, renderPage, resetAdornmentsSize, restoreTitlesFocus, saveAdornmentsSize, saveTitlesFocus, setBottomFormattedText, setBottomMargin, setCustomHeaderAndFooterCallback, setFitToNumPagesTall, setFitToNumPagesWide, setFooterMargin, setGraphPrintScaleType, setGridlinesVisible, setGridViewPrintScaleType, setHeaderMargin, setHeadersAndFootersUsingCallback, setLeftMargin, setLineWidth, setMarginAdjustment, setPageFormat, setPrintByColumns, setPrintJob, setPrintScaleType, setPrintZoomFactor, setRangeType, setRepeatComponent, setRepeatHeaders, setRightMargin, setSelectedHPos, setSequentialPageNumber, setTokenSubstitution, setTopFormattedText, setTopMargin, setUnits, setViewDimension, showPrintJob
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphPrinter

public GraphPrinter(Graph g)
Constructor.

Parameters:
g - The Graph that this GraphPrinter prints.
Method Detail

getViewPrinterType

public int getViewPrinterType()
Retrieves the type of ViewPrinter.

Returns:
A constant that represents the specific type of ViewPrinter.
See Also:
UIViewPrinter.GRAPH_PRINTER

startPrint

public boolean startPrint()
Puts the Graph in a state for printing. This method saves the original state of the view, then it applies printing properties to the Graph. It displays the offscreen image (which has the snapshot of the view) on the screen, so that any modifications done to the view during printing will not be seen.

Calling this method is equivalent to calling startPrint(false). It is appropriate for printing or previewing graphs, or printing tables and crosstabs. To preview a table or crosstab, call startPrint(true).

Calls to the print method belong between calls to startPrint and endPrint.

Specified by:
startPrint in class ViewPrinter
Returns:
true if the print job starts successfully, false if the data in the view is not available to this GraphPrinter.
See Also:
endPrint(), startPrint(boolean), printPage(java.awt.Graphics), ViewPrinter.print(boolean), ViewPrinter.renderPage(java.awt.Graphics)

startPrint

public boolean startPrint(boolean bPreviewMode)
Puts the Graph in a state for printing. This method saves the original state of the view, then it applies printing properties to the Graph. It displays the offscreen image (which has the snapshot of the view) on the screen, so that any modifications done to the view during printing will not be seen.

Calls to the print method belong between calls to startPrint and endPrint.

Specified by:
startPrint in interface UIViewPrinter
Specified by:
startPrint in class ViewPrinter
Parameters:
bPreviewMode - true if you are previewing the print job, false if you are actually sending the print job to a printer.
Returns:
true if the print job starts successfully, false if the data in the view is not available to this GraphPrinter.
See Also:
endPrint(), startPrint(boolean), printPage(java.awt.Graphics), ViewPrinter.print(boolean), ViewPrinter.renderPage(java.awt.Graphics)

endPrint

public void endPrint()
Sets the Graph back to its original state. This method removes the offscreen image that the startPrint method displays, and restores the active display of the Graph.

Calls to the print method belong between calls to startPrint and endPrint.

Specified by:
endPrint in interface UIViewPrinter
Specified by:
endPrint in class ViewPrinter
See Also:
startPrint(), ViewPrinter.print(boolean)

isFirstPhysicalPage

public boolean isFirstPhysicalPage()
Indicates whether the current physical page is the first physical page in the current logical page. In graph printing, each logical page is always printed on a single physical page, so this method always returns true.

Specified by:
isFirstPhysicalPage in interface UIViewPrinter
Specified by:
isFirstPhysicalPage in class ViewPrinter
Returns:
true if the current physical page is the first physical page in the current logical page, false if it is not.
See Also:
ViewPrinter.renderPage(java.awt.Graphics)

isLastPhysicalPage

public boolean isLastPhysicalPage()
Indicates whether the current physical page is the last physical page in the current logical page. In graph printing, each logical page is always printed on a single physical page, so this method always returns true.

Specified by:
isLastPhysicalPage in interface UIViewPrinter
Specified by:
isLastPhysicalPage in class ViewPrinter
Returns:
true if the current physical page is the last physical page in the current logical page, false if it is not.
See Also:
ViewPrinter.renderPage(java.awt.Graphics)

getGraph

public Graph getGraph()
Retrieves the Graph that this GraphPrinter prints.

Returns:
The Graph that this GraphPrinter prints.

setGraph

public void setGraph(Graph graph)
Specifies the Graph that this GraphPrinter should print.

Parameters:
graph - The Graph that needs to be printed.

setScaleFontSize

public void setScaleFontSize(int mask)
Specifies which text components should be resized when the graph is scaled to a different size for printing.

Specified by:
setScaleFontSize in interface UIViewPrinter
Specified by:
setScaleFontSize in class ViewPrinter
Parameters:
mask - A constant that represents the set of components to scale with the graph. The constants are listed in the See Also section.
See Also:
ViewPrinter.TEXT_COMPONENTS_ALL, ViewPrinter.TEXT_COMPONENTS_NONE

getScaleFontSize

public int getScaleFontSize()
Retrieves which text components should be resized when the Graph is scaled to a different size for printing.

Specified by:
getScaleFontSize in interface UIViewPrinter
Specified by:
getScaleFontSize in class ViewPrinter
Returns:
A constant that represents which text components should be resized when the Graph is scaled to a different size for printing. The constants are defined in the Graph class, and they start with TEXT_COMPONENTS.
See Also:
GraphConstants.TEXT_COMPONENTS_ALL, GraphConstants.TEXT_COMPONENTS_NONE

printPages

protected void printPages(java.awt.PrintJob pjob,
                          boolean currentLogPage)
Deprecated. As of 3.2.0.16, replaced by 2D printing API

Specified by:
printPages in class ViewPrinter
Parameters:
pJob - the PrintJob object
currentLogPage - true if current logical page only false if all logical pages
For internal use only. Application developers should not use this
This method loops through the entire logical page, gets the graphics object from the PrintJob calls printToGraphics(). If more than one logical page needs to be printed, it loops through all logical pages. At the beginning of printing each logical page, calls calcAdornmentsDimension() to calculate the heights of the adornments.

printPage

public boolean printPage(java.awt.Graphics g)
Prints the Graph to a Graphics object. This method is useful only when you assume responsibility for the print job.

This method renders the Graph in the Dimension that is specified by the ViewDimension attribute of this GraphPrinter.

Parameters:
g - The Graphics object to which to print the Graph. The Graphics object must be an instance of Graphics2D.
Returns:
true if the print job is successful, false if the data in the view is not available to this GraphPrinter.

printToGraphics

protected void printToGraphics(java.awt.Graphics g,
                               PaginationRecord record)
Specified by:
printToGraphics in class ViewPrinter
Parameters:
g - the Graphics object
record - The pagination record to use for printing on the Graphics object.
For internal use only. Application developers should not use this
Prints Graph onto the Graphics object using the information present in the PaginationRecord.

goToFirstPage

public boolean goToFirstPage()
Deprecated. As of 1.6.0.9, replaced by prepareFirstPage(Graphics)

The prepareFirstPage method respects the MarginAdjustment property.

Specified by:
goToFirstPage in class ViewPrinter
See Also:
ViewPrinter.setMarginAdjustment(int)

prepareFirstPage

public boolean prepareFirstPage(java.awt.Graphics g)
Prepares the first physical page in the graph for printing and makes it the current page to print. Call this method before you call renderPage to print. Call this method before you call any of the other methods for changing pages. Call this method, even if you only print one physical page. This method performs initialization for printing.

Specified by:
prepareFirstPage in interface UIViewPrinter
Specified by:
prepareFirstPage in class ViewPrinter
Parameters:
g - The Graphics object to which to print the page. The Graphics object must be an instance of Graphics2D.
Returns:
true if the call is successful, false if the first physical page has no data.
See Also:
hasNextPage(), prepareNextPage(java.awt.Graphics), ViewPrinter.renderPage(java.awt.Graphics)

hasNextPage

public boolean hasNextPage()
Indicates whether the view has a physical page after the current physical page. In a graph, each logical page is printed on a single physical page, so this method checks for another logical page. Use this method, with renderPage, when you assume responsibility for the print job.

Specified by:
hasNextPage in interface UIViewPrinter
Specified by:
hasNextPage in class ViewPrinter
Returns:
true if the view has another physical page after the current page, false if the current physical page is the last physical page.
See Also:
ViewPrinter.renderPage(java.awt.Graphics)

goToNextPage

public boolean goToNextPage()
Deprecated. As of 1.6.0.9, replaced by prepareNextPage(Graphics)

The prepareNextPage method respects the MarginAdjustment property.

Specified by:
goToNextPage in class ViewPrinter
See Also:
ViewPrinter.setMarginAdjustment(int)

prepareNextPage

public boolean prepareNextPage(java.awt.Graphics g)
Prepares the next physical page for printing and makes it the current page to print. In a graph, each logical page is printed on a single physical page, so this method changes the current logical page. Use this method when you use renderPage to print. Unless you are certain that there is a next page, you should call hasNextPage before you call this method. Also, before calling this method, call prepareFirstPage.

Specified by:
prepareNextPage in interface UIViewPrinter
Specified by:
prepareNextPage in class ViewPrinter
Parameters:
g - The Graphics object to which to print the page. The Graphics object must be an instance of Graphics2D.
Returns:
true if the call is successful, false if the next physical page has no data.
See Also:
prepareFirstPage(java.awt.Graphics), hasNextPage(), ViewPrinter.renderPage(java.awt.Graphics)

hasPrevPage

public boolean hasPrevPage()
Indicates whether the view has a physical page before the current physical page. In a graph, each logical page is printed on a single physical page, so this method checks for another logical page. Use this method, with renderPage, when you assume responsibility for the print job.

Specified by:
hasPrevPage in interface UIViewPrinter
Specified by:
hasPrevPage in class ViewPrinter
Returns:
true if the view has another physical page before the current page, false if the current physical page is the first physical page.
See Also:
ViewPrinter.renderPage(java.awt.Graphics)

goToPrevPage

public boolean goToPrevPage()
Deprecated. As of 1.6.0.9, replaced by preparePrevPage(Graphics)

The preparePrevPage method respects the MarginAdjustment property.

Specified by:
goToPrevPage in class ViewPrinter
See Also:
ViewPrinter.setMarginAdjustment(int)

preparePrevPage

public boolean preparePrevPage(java.awt.Graphics g)
Prepares the previous physical page for printing and makes it the current page to print. In a graph, each logical page is printed on a single physical page, so this method changes the current logical page. Use this method when you use renderPage to print. Unless you are certain that there is a previous page, you should call hasPrevPage before you call this method. Also, before calling this method, call prepareFirstPage.

Specified by:
preparePrevPage in interface UIViewPrinter
Specified by:
preparePrevPage in class ViewPrinter
Parameters:
g - The Graphics object to which to print the page. The Graphics object must be an instance of Graphics2D.
Returns:
true if the call is successful, false if the previous physical page has no data.
See Also:
ViewPrinter.renderPage(java.awt.Graphics), prepareFirstPage(java.awt.Graphics), hasPrevPage()

setLogicalPage

public boolean setLogicalPage(int[] hPos)
Specifies the logical page to print, when you use the printPage method to print. Call this method after you call the startPrint method for each graph that you print. *

Overrides:
setLogicalPage in class ViewPrinter
Parameters:
hPos - The hPos array that identifies the logical page to print.
Returns:
true if the logical page has been set, false if the data in the view is not available to this ViewPrinter.
See Also:
printPage(java.awt.Graphics), oracle.dss.dataView.gui.PrintDialog, DataAccess.getFirstHPos(int), DataAccess.getNextHPos(int, int[])

setDataview

protected void setDataview(Dataview dv)
Overrides:
setDataview in class ViewPrinter
For internal use only. Application developers should not use this

checkForNoData

protected boolean checkForNoData()
Overrides:
checkForNoData in class ViewPrinter
For internal use only. Application developers should not use this
check if the logical page contains some data

fetchAllData

protected void fetchAllData()
For internal use only. Application developers should not use this
Fetch all data on current logical page.

resetCurrentLogicalPage

protected void resetCurrentLogicalPage()
Specified by:
resetCurrentLogicalPage in class ViewPrinter
For internal use only. Application developers should not use this
This method should be called when the logical page in the DataSource has changed underneath the ViewPrinter, after the ViewPrinter changes it back to what it is supposed to be. This may happen if multiple views are using the same DataSource. This implementation simply fetches all data on the logical page.

Oracle Fusion Middleware Java API Reference for Oracle Data Visualization Components
11g Release 1 (11.1.1.4.0)

E12063-05

Copyright © 1997, 2011, Oracle. All rights reserved.