|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.faceless.pdf2.viewer2.DocumentPanel
public class DocumentPanel
A DocumentPanel
is the basic component that displays a PDF, and may be
instantiated on it's own or as part of a PDFViewer
. It contains a
DocumentViewport
and optionally one or more SidePanel
objects on the
left, and may process PDFAction
s on the PDF.
See the viewer tutorial for more detail on how to use this class and the "viewer" package.
defaultViewport | The class name of the default viewport to use if not specified in the PDF. May be SinglePageDocumentViewport , MultiPageDocumentVieport or a fully-qualified class name of another DocumentViewport |
---|---|
defaultPageMode | The default "page mode" of the PDF if not set. This may take one of the values for the "pagemode" PDF option , and would typically be "UseThumbs" or "UseOutlines". |
defaultZoom | The default zoom level of the PDF, if not set by a PDF open action. This may be the value "fit", "fitwidth", "fitheight" or a number between 12.5 and 6400 to set the zoom level. |
useNamedSidePanels | true or false (the default) - whether to show names on the side panel tabs rather than icons. |
sidePanelSize | The default (and minimum) width of the side panels displayed in this DocumentPanel. The default is 120 |
mouseWheelUnit | The number of pixels to adjust the viewport's scrollbar by when using the mouse wheel. The default is 16. |
smoothScrollTime | When smoothly scrolling a viewport's scrollbars, the number of ms to animate the scroll over. The default is 500, set to zero to disable. |
smoothScrollDistance | When smoothly scrolling a viewport's scrollbars, the maximum number of pixels to try to animate. The default is 500, set to zero to disable. |
earlyClose | When closing a DocumentPanel or changing the PDF it contains, the old PDF object remains open and will naturally have its PDF.close() method called during garbage collection. This can lead to problems on Windows platforms; As the PDF may retain a reference to the file it was read from, this prevents the file being deleted until close is called. The earlyClose parameter can be set to close the PDF file immediately the PDF is removed from the DocumentPanel or the panel closed; this will free any resources held by the PDF, and so invalidate any reference to those resources (which may be held elsewhere - for example, if the PDF had its pages moved to another document). So use with caution - by default this value is not set, but set to any non-null value to enable. |
noDirtyDocuments | Set this value to non-null to disable the dirty flag on documents. If disabled, no prompt will appear when trying to close a document that has been modified. |
respectSignatureCertification | If true, any restrictions found on a certified signature in the PDF will be honoured - for example, if the PDF being displayed has nochanges set then no changes will be allowed to the PDF through the viewer |
This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
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 |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
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 | |
---|---|
DocumentPanel()
Create a new DocumentPanel |
Method Summary | |
---|---|
void |
addActionHandler(ActionHandler actionhandler)
Add a ActionHandler to this DocumentPanel . |
void |
addAnnotationComponentFactory(AnnotationComponentFactory annotationfactory)
Add a AnnotationComponentFactory to this
DocumentPanel . |
void |
addDocumentPanelListener(DocumentPanelListener listener)
Add a DocumentPanelListener to this DocumentPanel. |
void |
addSidePanel(SidePanel panel)
Add the specified sidepanel to the DocumentPanel |
void |
addSidePanelFactory(SidePanelFactory panelfactory)
Add a SidePanelFactory to this
DocumentPanel . |
void |
addUndoableEditListener(UndoableEditListener l)
Add an UndoableEditListener to this DocumentPanel |
void |
fireUndoableEditEvent(UndoableEditEvent e)
Fire an UndoableEditEvent on this DocumentPanel. |
JSManager |
getJSManager()
Return the JSManager object for this DocumentPanel. |
PDFPage |
getPage()
Return the PDFPage currently being displayed by the DocumentViewport . |
int |
getPageNumber()
Return the pagenumber of the currently displayed page starting at 0, or -1 if no page is being displayed. |
PDFParser |
getParser()
Get the PDFParser being used to parse this PDF. |
PDF |
getPDF()
Return the PDF currently being displayed by this DocumentPanel |
SidePanel |
getSelectedSidePanel()
Return the currently selected SidePanel , or
null if no panels are displayed. |
Collection |
getSidePanels()
Return a read-only collection containing the SidePanel objects in use by this
DocumentPanel . |
PDFViewer |
getViewer()
Return the PDFViewer that contains this DocumentPanel. |
DocumentViewport |
getViewport()
Return the DocumentViewport contained by this DocumentPanel |
float |
getZoom()
Return the current zoom level. |
boolean |
hasPermission(String permission)
Indicates whether the specified type of action is allowed for this DocumentPanel. |
boolean |
isDirty()
Return the value of the dirty flag, as set by setDirty(boolean) |
void |
print(PrintService fservice,
PrintRequestAttributeSet fatts)
Display a Print dialog for printing this document, or if a PrintService is
specified, print directly to that service without displaying a dialog. |
void |
raiseDocumentPanelEvent(DocumentPanelEvent event)
Raise a DocumentPanelEvent on the DocumentPanel. |
void |
redraw(Object o)
Deprecated. DocumentPanel.redraw() is no longer required as this object now listens to PropertyChangeEvents fired by the PDF. This method is not called
anywhere and is a no-op |
void |
removeDocumentPanelListener(DocumentPanelListener listener)
Remove a DocumentPanelListener from this DocumentPanel. |
void |
removeSidePanel(SidePanel panel)
Remove the specified SidePanel from the DocumentPanel. |
void |
removeUndoableEditListener(UndoableEditListener l)
Remove an UndoableEditListener from this DocumentPanel |
boolean |
runAction(PDFAction action)
Run the specified action on the PDF. |
void |
setDirty(boolean dirty)
Set the document as being "dirty", ie that it has been modified since loading. |
void |
setJSManager(JSManager jsmanager)
Set the JSManager object for this DocumentPanel. |
void |
setPage(PDFPage page)
Set the page to display in the DocumentViewport . |
void |
setPage(PDFPage page,
float x,
float y,
float zoom)
Set the page to display in the DocumentViewport . |
void |
setPageNumber(int i)
Set the page being displayed. |
void |
setPDF(PDF pdf)
Set the PDF to be displayed by this DocumentPanel . |
void |
setPDF(PDFParser parser,
PDFPage page)
Set the PDF to be displayed by this DocumentPanel , and specify the
initial page to display and the exact PDFParser to use. |
void |
setPDF(PDF pdf,
PDFPage page)
Set the PDF to be displayed by this DocumentPanel , and specify the
initial page to display. |
void |
setPermission(String permission,
boolean enable)
Sets whether the specified permission is allowed on this DocumentPanel. |
void |
setSelectedSidePanel(SidePanel panel)
Set the currently displayed SidePanel |
void |
setSidePanelSize(int threshold,
int preferred)
Control the size of the leftmost pane. |
void |
setSignaturePermissionRestrictions(FormSignature sig)
Limit the permissions that can be set on this PDF
to ensure they don't conflict with the certification
of this signature. |
void |
setViewport(DocumentViewport viewport)
Set the DocumentViewport used by this DocumentPanel. |
void |
setZoom(float zoom)
Set the current zoom level |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DocumentPanel()
Method Detail |
---|
public void setViewport(DocumentViewport viewport)
DocumentViewport
used by this DocumentPanel.
viewport
- the Viewportpublic DocumentViewport getViewport()
DocumentViewport
contained by this DocumentPanel
public JSManager getJSManager()
public void setJSManager(JSManager jsmanager)
public PDFViewer getViewer()
PDFViewer
that contains this DocumentPanel.
Note a DocumentPanel does not have to be contained inside
a PDFViewer, in which case this method will return null
.
public void setSidePanelSize(int threshold, int preferred)
threshold
- the minimum size, below which the panel is assumed to be closedpreferred
- the default size of the leftmost pane when openedpublic void addSidePanelFactory(SidePanelFactory panelfactory)
SidePanelFactory
to this
DocumentPanel
. When a PDF is set, the panels that are
appropriate for that PDF will be created from this list of factories.
panelfactory
- the factorypublic void addAnnotationComponentFactory(AnnotationComponentFactory annotationfactory)
AnnotationComponentFactory
to this
DocumentPanel
. Any PDF's displayed by this panel will have annotations
created by these factories.
annotationfactory
- the factorypublic void addActionHandler(ActionHandler actionhandler)
ActionHandler
to this DocumentPanel
.
Any actions passed to runAction(org.faceless.pdf2.PDFAction)
will by handled by this list of handlers.
actionhandler
- the handlerpublic boolean runAction(PDFAction action)
ActionHandler
s, which should be registered
with this class via the addActionHandler()
method.
action
- the PDFAction to run.
public void addDocumentPanelListener(DocumentPanelListener listener)
DocumentPanelListener
to this DocumentPanel.
listener
- the listenerpublic void removeDocumentPanelListener(DocumentPanelListener listener)
DocumentPanelListener
from this DocumentPanel.
listener
- the listenerpublic void raiseDocumentPanelEvent(DocumentPanelEvent event)
DocumentPanelEvent
on the DocumentPanel. In general
this shouldn't be called unless you're extending one of the code
classes, i.e. by writing your own DocumentViewport
.
public Collection getSidePanels()
SidePanel
objects in use by this
DocumentPanel
.
public void removeSidePanel(SidePanel panel)
public void addSidePanel(SidePanel panel)
public void setSelectedSidePanel(SidePanel panel)
SidePanel
panel
- the SidePanel to display.public SidePanel getSelectedSidePanel()
SidePanel
, or
null
if no panels are displayed.
public void setPDF(PDF pdf)
DocumentPanel
.
A value of null
will remove the current PDF from this object
and free any resources that reference it - this should be done before this
object is disposed of.
pdf
- the PDF, or null
to remove the current PDFpublic void setPDF(PDF pdf, PDFPage page)
DocumentPanel
, and specify the
initial page to display.
pdf
- the PDF, or null
to remove the current PDFpage
- the initial page to display, or null
to not display an initial
page (exactly how this is handled depends on the Viewport).
This will be ignored if the DocumentPanel is part of a PDFViewer and the PDF has an
open action that sets the page.public void setPDF(PDFParser parser, PDFPage page)
DocumentPanel
, and specify the
initial page to display and the exact PDFParser
to use.
parser
- the PDFParser to use to retrieve the PDF frompage
- the initial page to display, or null
to not display an initial
page (exactly how this is handled depends on the Viewport).
This will be ignored if the DocumentPanel is part of a PDFViewer and the PDF has an
open action that sets the page.public PDFParser getParser()
public PDF getPDF()
DocumentPanel
public PDFPage getPage()
DocumentViewport
.
If no PDF is set or the first page is still being rendered, this method will return
null
.
public void setPageNumber(int i)
setPage(getPDF().getPage(i))
.
public int getPageNumber()
public float getZoom()
public void setZoom(float zoom)
zoom
- the zoom levelpublic void setPage(PDFPage page)
DocumentViewport
. The page is displayed
at it's top-left and at the current zoom level.
page
- the pagepublic void setPage(PDFPage page, float x, float y, float zoom)
DocumentViewport
. The page is displayed
at the co-ordinates supplied and at the specified zoom level.
page
- the pagex
- the left-most position of the page to display, in units relative to PagePanel.getFullPageView(org.faceless.pdf2.PDFPage)
y
- the top-most position of the page to display, in units relative to PagePanel.getFullPageView(org.faceless.pdf2.PDFPage)
zoom
- the zoom levelpublic void redraw(Object o)
PropertyChangeEvents
fired by the PDF. This method is not called
anywhere and is a no-op
PDFPage
or PDFAnnotation
public void setDirty(boolean dirty)
noDirtyDocuments
can be set to prevent this value
from being set.
public boolean isDirty()
setDirty(boolean)
public void addUndoableEditListener(UndoableEditListener l)
UndoableEditListener
to this DocumentPanel
public void removeUndoableEditListener(UndoableEditListener l)
UndoableEditListener
from this DocumentPanel
public void fireUndoableEditEvent(UndoableEditEvent e)
UndoableEditEvent
on this DocumentPanel. As a special
hack, passing null
to this method will truncate the list
of events
public void print(PrintService fservice, PrintRequestAttributeSet fatts) throws PrintException, PrinterException
PrintService
is
specified, print directly to that service without displaying a dialog.
fservice
- the PrintService to print to. If this value is null
a dialog will be displayed allowing the selection of a service.fatts
- the print attributes - may be set to an AttributeSet to control the
printing, or null
to use the default.
PrintException
PrinterException
public boolean hasPermission(String permission)
EncryptionHandler
, or temporarily
by a call to setPermission(java.lang.String, boolean)
. The currently used list of
permissions includes:
setPermission(java.lang.String, boolean)
,
setSignaturePermissionRestrictions(org.faceless.pdf2.FormSignature)
,
EncryptionHandler.hasRight(java.lang.String)
,
FormSignature.getCertificationType()
public void setPermission(String permission, boolean enable)
permission
- the permissionenable
- true to allow the action, false otherwisehasPermission(java.lang.String)
,
setSignaturePermissionRestrictions(org.faceless.pdf2.FormSignature)
public void setSignaturePermissionRestrictions(FormSignature sig)
set
on this PDF
to ensure they don't conflict with the certification
of this signature. This can be used to ensure that modifications to a PDF don't
invalidate an existing digital siganture that disallows them. By default this is
not the case, but setting the
respectSignatureCertification
initialization-parameter
will ensure those restrictions are respected. This method can be called with null
to make the setting of permissions unrestricted.
hasPermission(java.lang.String)
,
FormSignature.getCertificationType()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |