|
||||||||||
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. |
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 |
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)
Dispatch a document panel event from this panel. |
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 |
setSelectedSidePanel(SidePanel panel)
Set the currently displayed SidePanel |
void |
setSidePanelSize(int threshold,
int preferred)
Control the size of the leftmost pane. |
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)
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)
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |