public class DocumentViewer extends JPanel implements Serializable, ComponentListener, IViewer
JComponent.AccessibleJComponentComponent.BaselineResizeBehaviorTOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
DocumentViewer()
Creates a new instance of the document viewer component.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addViewerListener(DocumentViewerListener listener)
Adds specified user-class instance to the list of listeners that are
notified about viewer events.
|
void |
closeDocument()
Stops the display of the documents and unloads it from memory.
|
void |
componentHidden(ComponentEvent e) |
void |
componentMoved(ComponentEvent e) |
void |
componentResized(ComponentEvent e) |
void |
componentShown(ComponentEvent e) |
void |
dispose() |
void |
finalize() |
void |
firstPage()
Navigates to the first page.
|
IDocument |
getActiveDocument()
Returns the active document.
|
int |
getBorderWidth()
Returns width of the border of the viewer.
|
Component |
getComponent()
Returns the container component.
|
int |
getCurrentPageNumber()
Returns current page number.
|
double |
getMaxZoomVal()
Returns page magnification that can be used to display documents.
|
double |
getMinZoomVal()
Returns minimum page magnification that can be used to display documents.
|
int |
getPageCount()
Returns number of pages in the document.
|
PageLayout |
getPageLayout()
Returns current page layout setting.
|
double[] |
getPredefinedZoomValues()
Returns pre-defined page magnification settings to which
IViewer.zoomIn()
and IViewer.zoomOut() change to. |
ViewerPreferences |
getPreferences()
Returns viewer settings.
|
Dimension |
getPreferredSize() |
RotationAngle |
getRotationAngle()
Returns current angle of rotation.
|
List<String> |
getSupportedFormats()
Returns the list of supported formats.
|
DocumentViewerListener[] |
getViewerListeners()
Returns list of user-class instance that are notified of viewer events.
|
int[] |
getVisiblePageNumbers()
Returns numbers of pages that are current displayed.
|
Zoom |
getZoom()
Returns current page magnification.
|
void |
goToPageNumber(int gotoPageNum)
Navigates to specified page.
|
boolean |
isDocumentLoaded()
Returns whether a document has been loaded in the viewer.
|
void |
lastPage()
Navigates to the last page.
|
void |
loadDocument(InputStream inputStream,
String password)
Loads a document from specified stream with specified stream.
|
void |
loadDocument(String fileName,
String password)
Loads specified document with specified password.
|
int |
nextPage()
Navigates to the next page.
|
Dimension |
preferredSize() |
int |
previousPage()
Navigates to the previous page.
|
void |
refresh()
Refreshes the display.
|
void |
removeViewerListener(DocumentViewerListener listener)
Removes specified user-class instance from the list of listeners that are notified viewer events.
|
void |
resetAllPageRotation()
Resets the angle of rotation of pages whose contents have been rotated.
|
void |
rotateAllPagesAntiClockwise()
Rotates displayed contents of all pages in the counter-clockwise direction.
|
void |
rotateAllPagesClockwise()
Rotates displayed contents of all pages in the clockwise direction.
|
void |
rotateAllPagesTo(RotationAngle rotationAngle)
Rotate displayed contents of all pages by specified angle.
|
void |
rotatePageTo(RotationAngle angle,
int pageNum)
Rotates contents of specified page by specified angle.
|
void |
rotatePageTo(RotationAngle angle,
String pageRange)
Rotate contents of specified pages by specified angle.
|
void |
setBackgroundColor(Color backgroundColor)
Sets specified background color for the viewer.
|
void |
setBorderWidth(int borderWidth)
Sets specified border width for the viewer.
|
void |
setPageLayout(PageLayout pageLayout)
Displays pages in specified layout.
|
void |
setViewerPreferences(ViewerPreferences viewerPreferences)
Sets specified viewer settings.
|
boolean |
zoomIn()
Changes page magnification to the next higher
pre-defined page magnification value. |
boolean |
zoomOut()
Changes page magnification to the next lower
pre-defined page magnification value. |
void |
zoomTo(Zoom zoom)
Changes the page magnification to specified value.
|
getAccessibleContext, getUI, getUIClassID, setUI, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic DocumentViewer()
public Dimension preferredSize()
preferredSize in class Containerpublic Dimension getPreferredSize()
getPreferredSize in class JComponentpublic void setBackgroundColor(Color backgroundColor)
IViewersetBackgroundColor in interface IViewerbackgroundColor - background color for the viewerpublic void loadDocument(String fileName, String password) throws IOException, FormatNotSupportedException, IncorrectPasswordException, XDocException
IViewerloadDocument in interface IViewerfileName - pathname of the filepassword - password to decrypt the documentIOException - if an I/O error occursFormatNotSupportedException - if the document format is not supportedIncorrectPasswordException - if an incorrect password was providedXDocException - if a viewer error occurspublic void loadDocument(InputStream inputStream, String password) throws IOException, FormatNotSupportedException, IncorrectPasswordException, XDocException
IViewerloadDocument in interface IViewerinputStream - stream from which the document needs to be loadedpassword - password to decrypt the documentIOException - if an I/O error occursFormatNotSupportedException - if the document format is not supportedIncorrectPasswordException - if an incorrect password was providedXDocException - if a viewer error occurspublic void closeDocument()
throws IOException
IViewercloseDocument in interface IViewerIOException - if an I/O error occurspublic double getMinZoomVal()
IViewergetMinZoomVal in interface IViewerpublic double getMaxZoomVal()
IViewergetMaxZoomVal in interface IViewerpublic boolean zoomIn()
IViewerpre-defined page magnification value.public boolean zoomOut()
IViewerpre-defined page magnification value.public double[] getPredefinedZoomValues()
IViewerIViewer.zoomIn()
and IViewer.zoomOut() change to.getPredefinedZoomValues in interface IViewerpublic void dispose()
throws IOException
dispose in interface IViewerIOExceptionpublic void zoomTo(Zoom zoom)
IViewerpublic Zoom getZoom()
IViewerpublic RotationAngle getRotationAngle()
IViewergetRotationAngle in interface IViewerpublic int getCurrentPageNumber()
IViewergetCurrentPageNumber in interface IViewerpublic int getPageCount()
IViewergetPageCount in interface IViewerpublic PageLayout getPageLayout()
IViewergetPageLayout in interface IViewerpublic void setPageLayout(PageLayout pageLayout) throws XDocException
IViewersetPageLayout in interface IViewerpageLayout - layout in which pages need to be displayedXDocExceptionpublic void rotateAllPagesClockwise()
IViewerrotateAllPagesClockwise in interface IViewerpublic void rotateAllPagesTo(RotationAngle rotationAngle)
IViewerrotateAllPagesTo in interface IViewerrotationAngle - angle by which the contents need to be rotatedpublic void firstPage()
throws XDocException
IViewerfirstPage in interface IViewerXDocException - if a viewer error occurspublic int previousPage()
throws XDocException
IViewerpreviousPage in interface IViewerXDocException - if a viewer error occurspublic int nextPage()
throws XDocException
IViewernextPage in interface IViewerXDocException - if a viewer error occurspublic void lastPage()
throws XDocException
IViewerlastPage in interface IViewerXDocException - if a viewer error occurspublic void goToPageNumber(int gotoPageNum)
throws XDocException
IViewergoToPageNumber in interface IViewergotoPageNum - number of the page.XDocException - if a viewer error occurspublic void addViewerListener(DocumentViewerListener listener)
IVieweraddViewerListener in interface IViewerlistener - user-class instance that needs to be addedpublic void removeViewerListener(DocumentViewerListener listener)
IViewerremoveViewerListener in interface IViewerlistener - listener that needs to be removedpublic DocumentViewerListener[] getViewerListeners()
IViewergetViewerListeners in interface IViewerpublic IDocument getActiveDocument()
IViewergetActiveDocument in interface IViewerpublic int getBorderWidth()
IViewergetBorderWidth in interface IViewerpublic ViewerPreferences getPreferences()
IViewergetPreferences in interface IViewerpublic boolean isDocumentLoaded()
IViewerisDocumentLoaded in interface IViewerpublic void rotateAllPagesAntiClockwise()
IViewerrotateAllPagesAntiClockwise in interface IViewerpublic void setBorderWidth(int borderWidth)
IViewersetBorderWidth in interface IViewerborderWidth - border width that needs to be set for the viewerpublic List<String> getSupportedFormats()
IViewergetSupportedFormats in interface IViewerpublic void rotatePageTo(RotationAngle angle, String pageRange)
IViewerrotatePageTo in interface IViewerangle - angle by which the contents need to be rotatedpageRange - pages whose contents need to be rotatedpublic void rotatePageTo(RotationAngle angle, int pageNum)
IViewerrotatePageTo in interface IViewerangle - angle by which the contents need to be rotatedpageNum - number of the page whose contents need to be rotatedpublic void resetAllPageRotation()
IViewerresetAllPageRotation in interface IViewerpublic int[] getVisiblePageNumbers()
IViewergetVisiblePageNumbers in interface IViewerpublic Component getComponent()
IViewergetComponent in interface IViewerpublic void refresh()
IViewerpublic void componentHidden(ComponentEvent e)
componentHidden in interface ComponentListenerpublic void componentMoved(ComponentEvent e)
componentMoved in interface ComponentListenerpublic void componentResized(ComponentEvent e)
componentResized in interface ComponentListenerpublic void componentShown(ComponentEvent e)
componentShown in interface ComponentListenerpublic void setViewerPreferences(ViewerPreferences viewerPreferences)
viewerPreferences - viewer settings that need to be set