public class DocumentViewer extends JPanel implements Serializable, ComponentListener, IViewer
JComponent.AccessibleJComponent
Component.BaselineResizeBehavior
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, 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, updateUI
addAncestorListener, 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, update
add, 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, validate
action, 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, transferFocusUpCycle
public DocumentViewer()
public Dimension preferredSize()
preferredSize
in class Container
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public void setBackgroundColor(Color backgroundColor)
IViewer
setBackgroundColor
in interface IViewer
backgroundColor
- background color for the viewerpublic void loadDocument(String fileName, String password) throws IOException, FormatNotSupportedException, IncorrectPasswordException, XDocException
IViewer
loadDocument
in interface IViewer
fileName
- 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
IViewer
loadDocument
in interface IViewer
inputStream
- 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
IViewer
closeDocument
in interface IViewer
IOException
- if an I/O error occurspublic double getMinZoomVal()
IViewer
getMinZoomVal
in interface IViewer
public double getMaxZoomVal()
IViewer
getMaxZoomVal
in interface IViewer
public boolean zoomIn()
IViewer
pre-defined page magnification value
.public boolean zoomOut()
IViewer
pre-defined page magnification value
.public double[] getPredefinedZoomValues()
IViewer
IViewer.zoomIn()
and IViewer.zoomOut()
change to.getPredefinedZoomValues
in interface IViewer
public void dispose() throws IOException
dispose
in interface IViewer
IOException
public void zoomTo(Zoom zoom)
IViewer
public Zoom getZoom()
IViewer
public RotationAngle getRotationAngle()
IViewer
getRotationAngle
in interface IViewer
public int getCurrentPageNumber()
IViewer
getCurrentPageNumber
in interface IViewer
public int getPageCount()
IViewer
getPageCount
in interface IViewer
public PageLayout getPageLayout()
IViewer
getPageLayout
in interface IViewer
public void setPageLayout(PageLayout pageLayout) throws XDocException
IViewer
setPageLayout
in interface IViewer
pageLayout
- layout in which pages need to be displayedXDocException
public void rotateAllPagesClockwise()
IViewer
rotateAllPagesClockwise
in interface IViewer
public void rotateAllPagesTo(RotationAngle rotationAngle)
IViewer
rotateAllPagesTo
in interface IViewer
rotationAngle
- angle by which the contents need to be rotatedpublic void firstPage() throws XDocException
IViewer
firstPage
in interface IViewer
XDocException
- if a viewer error occurspublic int previousPage() throws XDocException
IViewer
previousPage
in interface IViewer
XDocException
- if a viewer error occurspublic int nextPage() throws XDocException
IViewer
nextPage
in interface IViewer
XDocException
- if a viewer error occurspublic void lastPage() throws XDocException
IViewer
lastPage
in interface IViewer
XDocException
- if a viewer error occurspublic void goToPageNumber(int gotoPageNum) throws XDocException
IViewer
goToPageNumber
in interface IViewer
gotoPageNum
- number of the page.XDocException
- if a viewer error occurspublic void addViewerListener(DocumentViewerListener listener)
IViewer
addViewerListener
in interface IViewer
listener
- user-class instance that needs to be addedpublic void removeViewerListener(DocumentViewerListener listener)
IViewer
removeViewerListener
in interface IViewer
listener
- listener that needs to be removedpublic DocumentViewerListener[] getViewerListeners()
IViewer
getViewerListeners
in interface IViewer
public IDocument getActiveDocument()
IViewer
getActiveDocument
in interface IViewer
public int getBorderWidth()
IViewer
getBorderWidth
in interface IViewer
public ViewerPreferences getPreferences()
IViewer
getPreferences
in interface IViewer
public boolean isDocumentLoaded()
IViewer
isDocumentLoaded
in interface IViewer
public void rotateAllPagesAntiClockwise()
IViewer
rotateAllPagesAntiClockwise
in interface IViewer
public void setBorderWidth(int borderWidth)
IViewer
setBorderWidth
in interface IViewer
borderWidth
- border width that needs to be set for the viewerpublic List<String> getSupportedFormats()
IViewer
getSupportedFormats
in interface IViewer
public void rotatePageTo(RotationAngle angle, String pageRange)
IViewer
rotatePageTo
in interface IViewer
angle
- angle by which the contents need to be rotatedpageRange
- pages whose contents need to be rotatedpublic void rotatePageTo(RotationAngle angle, int pageNum)
IViewer
rotatePageTo
in interface IViewer
angle
- angle by which the contents need to be rotatedpageNum
- number of the page whose contents need to be rotatedpublic void resetAllPageRotation()
IViewer
resetAllPageRotation
in interface IViewer
public int[] getVisiblePageNumbers()
IViewer
getVisiblePageNumbers
in interface IViewer
public Component getComponent()
IViewer
getComponent
in interface IViewer
public void refresh()
IViewer
public void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
public void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
public void setViewerPreferences(ViewerPreferences viewerPreferences)
viewerPreferences
- viewer settings that need to be set