Style Intelligence v12.0

inetsoft.report
Class PreviewPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by inetsoft.report.PreviewPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
inetsoft.report.j2d.JPreviewPane

public class PreviewPane
extends Container

The PreviewPane class can be used to preview a document before it's actually printed. The PreviewPane is very easy to use. Its main API is consisted of one method, PreviewPane.print(ReportSheet). To add preview capability to your application, simple create a PreviewPane, pack and set it to visible like any window, and call the print() method with the created report.

    PreviewPane previewer = new PreviewPane();
    previewer.print(report);
 

The PreviewPane supports user interactions through selection events. If a mouse clicks inside an element on a preview pane, a SelectionEvent is generated. The SelectionEvent is generated for the following types of elements:

Element TypeSourceItem
Table,FormTableLens Point contains cell location, (column, row)
ChartChartLens Point contains data point location, (data index, dataset index)
TextTextLensText contents
TextBoxTextLensText contents
ImageImage PainterImage
ComponentComponent PainterComponent
PainterPainterPainter

See Also:
Serialized Form

Nested Class Summary
 class PreviewPane.Constraints
          Constraints object can be used to define the layout constraints of child components.
protected  class PreviewPane.StatusScrollBar
           
protected  class PreviewPane.StatusScrollPane
           
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  inetsoft.util.Catalog catalog
           
static int PAGE_WIDTH
          Zoom flag.
protected  Container scrollpane
          Scroll pane.
protected  ReportSheet sheet
          The report object in preview.
static int TWO_PAGES
          Zoom flag.
static int WHOLE_PAGE
          Zoom flag.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PreviewPane()
          Create a previewer with specified title.
 
Method Summary
protected  PreviewPage addPage(StylePage stylepage, double w, double h)
          Add a page to the container.
 void addSelectionListener(SelectionListener l)
          Add a selection listener.
protected  void addToScrollPane(Component comp)
          Add the component to the scrollpane.
 void cancel()
          Cancel the report processing if one is under way.
protected  PreviewPage createPage(double w, double h, int resolution)
          Create a page component to hold a page.
protected  Container createScrollPane()
          Create a scrollpane to handle the scrolling.
 void fireSelectionChange(Object src, String eid, Object item, MouseEvent e, Object userObj)
          Fire a selection event.
protected  int getBlockIncrement(Adjustable adj)
          Get the block increment amount of the scrollbar.
 Adjustable getHAdjustable()
          Get the horizontal scrollbar.
 int getOrientation()
          Returns the orientation of this PageFormat.
 PreviewPage getPage(int idx)
          Get the specified preview page.
 int getPageCount()
          Get the number of pages in the preview pane.
 double getPageHeight()
          Get the page height in inches.
protected  int getPageMarginHeight()
          Get the height between page to page.
 int getPageNumber()
          Get the current page number.
 int getPageResolution()
          Deprecated. as of 5.1.
 double getPageWidth()
          Get the page width in inches.
 ReportSheet getReport()
          Get the style sheet object in this pane.
 KeyListener getScrollListener()
          Get the key listener for handling scrolling.
 Container getScrollPane()
          Get the scroll pane used by this pane.
 Enumeration getStylePages()
          Get the style pages in the preview frame.
 Adjustable getVAdjustable()
          Get the vertical scrollbar.
protected  Container getViewport()
          Return the scrollpane's viewport.
 Dimension getViewportSize()
          Get the scroller viewport size.
 double getZoom()
          Get the zoom percentage.
 void gotoPage()
          Prompt for a page number to go to.
 void gotoPage(int pn)
          Jump to the specified page.
 boolean isCancelled()
          Check if printing is canceled.
 boolean isShowRuler()
          Check if rulers are show at the pages.
protected  void pagingAction(AdjustmentEvent e)
          Called when scrollbar used to page up and down.
 void paint(Graphics g)
           
 void print(ReportSheet sheet)
          Print the report in this preview pane.
 void print(ReportSheet sheet, boolean reset)
          Print the report in this preview pane.
 void printAction(PrintJob printjob)
          Start printing to printer.
 void removeAll()
          Clean up preview pane.
protected  void removeAllPages()
          Remove all pages in the preview pane.
 void removeSelectionListener(SelectionListener l)
          Remove a selection listener.
protected  void saveReport()
          Save the current report.
 void setFocusPage(int page)
          Set the current page that has the focus.
protected  void setHorizontalRulerLines(int[] hline)
          Set the moving line on the horizontal ruler.
 void setOrientation(int orientation)
          Deprecated. as of 5.1.
protected  void setPageCount(int cnt)
          Add the number of blank pages to the preview pane.
 void setPageHeight(double height)
          Deprecated. as of 5.1.
protected  void setPageNumberDisplay(boolean pgnumDisplay)
          Controls whether the page number should be displayed as a tooltip when scrolling the vertical scrollbar
 void setPageResolution(int res)
          Deprecated. as of 5.1.
 void setPages(int rows, int cols)
          Set the multi-page dimension.
 void setPageSize(Size pagesize)
          Set the page size.
 void setPageWidth(double width)
          Deprecated. as of 5.1.
 void setShowRuler(boolean ruler)
          Set whether to show the rulers at the left and top of page.
 void setStylePages(Enumeration stylepages)
          Display the StylePages in the preview pane.
protected  void setVerticalRulerLines(int[] vline)
          Set the moving line on the vertical ruler.
 void showPageNumber(int pn)
          Set the current page number shown on the status bar.
 void showPageSize(Size psize)
          Set the page size information.
 void showStatus(String status)
          Set the status text on status bar.
protected  void syncScrollPane()
          Make sure the scrollpane reflects the current scrollbar values.
 void update(Graphics g)
           
 void writeReport(OutputStream os)
          Writes the previewed report into a .sro file.
 void zoom(double perc)
          Set the zooming percentage.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PAGE_WIDTH

public static final int PAGE_WIDTH
Zoom flag. Zoom to page width.

See Also:
Constant Field Values

WHOLE_PAGE

public static final int WHOLE_PAGE
Zoom flag. Show whole page on screen.

See Also:
Constant Field Values

TWO_PAGES

public static final int TWO_PAGES
Zoom flag. Show two pages side by side.

See Also:
Constant Field Values

sheet

protected ReportSheet sheet
The report object in preview.


scrollpane

protected Container scrollpane
Scroll pane.


catalog

protected inetsoft.util.Catalog catalog
Constructor Detail

PreviewPane

public PreviewPane()
Create a previewer with specified title.

Method Detail

printAction

public void printAction(PrintJob printjob)
Start printing to printer. This will popup the print dialog. It has the same effect as an user clicking on the 'printer' button.


removeAllPages

protected void removeAllPages()
Remove all pages in the preview pane.


removeAll

public void removeAll()
Clean up preview pane.

Overrides:
removeAll in class Container

setPageWidth

public void setPageWidth(double width)
Deprecated. as of 5.1.

Set the page width in inches.

Parameters:
width - page width.

getPageWidth

public double getPageWidth()
Get the page width in inches.

Returns:
page width.

setPageHeight

public void setPageHeight(double height)
Deprecated. as of 5.1.

Set the page height in inches.

Parameters:
height - page height.

getPageHeight

public double getPageHeight()
Get the page height in inches.

Returns:
page height.

setPageSize

public void setPageSize(Size pagesize)
Set the page size. This is equivalent to setting both page width and height.

Parameters:
pagesize - page size in inches.

setOrientation

public void setOrientation(int orientation)
Deprecated. as of 5.1.

Sets the page orientation. orientation must be one of the constants: PORTRAIT, LANDSCAPE.

Parameters:
orientation - the new orientation for the page

getOrientation

public int getOrientation()
Returns the orientation of this PageFormat.

Returns:
this PageFormat object's orientation.

setPageResolution

public void setPageResolution(int res)
Deprecated. as of 5.1.

Set the page resolution, as number of dots per inch. The default is 72.

Parameters:
res - page resolution.

getPageResolution

public int getPageResolution()
Deprecated. as of 5.1.

Get the page resolution.

Returns:
page resolution.

setShowRuler

public void setShowRuler(boolean ruler)
Set whether to show the rulers at the left and top of page.

Parameters:
ruler - true to show rulers.

isShowRuler

public boolean isShowRuler()
Check if rulers are show at the pages.

Returns:
true if rules are shown.

getScrollPane

public Container getScrollPane()
Get the scroll pane used by this pane.

Returns:
scrollpane.

getReport

public ReportSheet getReport()
Get the style sheet object in this pane.


print

public void print(ReportSheet sheet)
Print the report in this preview pane.

Parameters:
sheet - report.

cancel

public void cancel()
Cancel the report processing if one is under way.


isCancelled

public boolean isCancelled()
Check if printing is canceled.


print

public void print(ReportSheet sheet,
                  boolean reset)
Print the report in this preview pane.

Parameters:
sheet - report.
reset - true to reset the report before printing.

writeReport

public void writeReport(OutputStream os)
Writes the previewed report into a .sro file.


addPage

protected PreviewPage addPage(StylePage stylepage,
                              double w,
                              double h)
Add a page to the container.


setStylePages

public void setStylePages(Enumeration stylepages)
Display the StylePages in the preview pane.

Parameters:
stylepages - return a collection of StylePage objects.

getPageCount

public int getPageCount()
Get the number of pages in the preview pane.

Returns:
number of pages.

getPage

public PreviewPage getPage(int idx)
Get the specified preview page.

Parameters:
idx - page index.

getStylePages

public Enumeration getStylePages()
Get the style pages in the preview frame.


showPageNumber

public void showPageNumber(int pn)
Set the current page number shown on the status bar.


showPageSize

public void showPageSize(Size psize)
Set the page size information.


showStatus

public void showStatus(String status)
Set the status text on status bar.


createPage

protected PreviewPage createPage(double w,
                                 double h,
                                 int resolution)
Create a page component to hold a page.


setPageCount

protected void setPageCount(int cnt)
Add the number of blank pages to the preview pane. This is intended to be used by subclasses to populate the pages without calling print().

Parameters:
cnt - number of pages.

createScrollPane

protected Container createScrollPane()
Create a scrollpane to handle the scrolling.

Returns:
a scroll pane container.

addToScrollPane

protected void addToScrollPane(Component comp)
Add the component to the scrollpane.

Parameters:
comp - managed component.

getViewport

protected Container getViewport()
Return the scrollpane's viewport.


getBlockIncrement

protected int getBlockIncrement(Adjustable adj)
Get the block increment amount of the scrollbar.


getViewportSize

public Dimension getViewportSize()
Get the scroller viewport size.

Returns:
viewport size.

getVAdjustable

public Adjustable getVAdjustable()
Get the vertical scrollbar. Return null if no vertical scrollbar created.

Returns:
vertical scrollbar.

getHAdjustable

public Adjustable getHAdjustable()
Get the horizontal scrollbar. Return null if no horizontal scrollbar created.

Returns:
horizontal scrollbar.

syncScrollPane

protected void syncScrollPane()
Make sure the scrollpane reflects the current scrollbar values.


setPages

public void setPages(int rows,
                     int cols)
Set the multi-page dimension.

Parameters:
rows - the number of rows.
cols - the number of columns.

getZoom

public double getZoom()
Get the zoom percentage.


zoom

public void zoom(double perc)
Set the zooming percentage. 100% is 1.0.

Parameters:
perc - zooming percentage.

gotoPage

public void gotoPage()
Prompt for a page number to go to.


gotoPage

public void gotoPage(int pn)
Jump to the specified page.


getPageNumber

public int getPageNumber()
Get the current page number. Starting from 1.

Returns:
current top page number.

setFocusPage

public void setFocusPage(int page)
Set the current page that has the focus. The page may not be visible in the viewport. This is different from the PageNumber, which is the page number that is currently visible.


addSelectionListener

public void addSelectionListener(SelectionListener l)
Add a selection listener. The listener is notified if an user clicks inside a report element.


removeSelectionListener

public void removeSelectionListener(SelectionListener l)
Remove a selection listener.


setPageNumberDisplay

protected void setPageNumberDisplay(boolean pgnumDisplay)
Controls whether the page number should be displayed as a tooltip when scrolling the vertical scrollbar


fireSelectionChange

public void fireSelectionChange(Object src,
                                String eid,
                                Object item,
                                MouseEvent e,
                                Object userObj)
Fire a selection event.


getScrollListener

public KeyListener getScrollListener()
Get the key listener for handling scrolling.


saveReport

protected void saveReport()
Save the current report.


pagingAction

protected void pagingAction(AdjustmentEvent e)
Called when scrollbar used to page up and down.


setHorizontalRulerLines

protected void setHorizontalRulerLines(int[] hline)
Set the moving line on the horizontal ruler.


setVerticalRulerLines

protected void setVerticalRulerLines(int[] vline)
Set the moving line on the vertical ruler.


getPageMarginHeight

protected int getPageMarginHeight()
Get the height between page to page.


paint

public void paint(Graphics g)
Overrides:
paint in class Container

update

public void update(Graphics g)
Overrides:
update in class Container

Copyright © 1996-2014 InetSoft Technology Corp. All Rights Reserved.