|
||||||||||
| 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.PDFViewer
public class PDFViewer
The PDFViewer class is a simple Swing PDF viewer application.
It demonstrates the DocumentPanel class, and can be run directly
from the JAR (via the PDFTool class) like so.
java -jar bfopdf.jar filenameThe filename argument is optional, but if supplied will load the specified PDF. See the viewer tutorial for more detail on how to use this class and the "viewer" package.
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 | |
|---|---|
PDFViewer(Collection features)
Creates new PDFViewer with the specified features |
|
| Method Summary | |
|---|---|
void |
addDocumentPanelListener(DocumentPanelListener listener)
Add a DocumentPanelListener to any DocumentPanel objects
created by this PDFViewer. |
void |
closeDocumentPanel(DocumentPanel panel)
Close the specified DocumentPanel |
DocumentPanel |
getActiveDocumentPanel()
Return the active DocumentPanel |
DocumentPanel[] |
getDocumentPanels()
Return all the DocumentPanels in the viewer |
ViewerFeature |
getFeature(Class clazz)
Return the specified ViewerFeature, or null
if it doesn't exist for this viewer |
ViewerFeature |
getFeature(String feature)
Return the specified ViewerFeature, or null
if it doesn't exist for this viewer |
ViewerFeature[] |
getFeatures()
Return the list of all features set in the viewer |
JSManager |
getJSManager()
Return the JSManager object for this PDFViewer. |
KeyStoreManager |
getKeyStoreManager()
Get the KeyStoreManager in use by this PDFViewer |
JComponent |
getNamedComponent(String name)
Return a Component created by a ViewerFeature |
PropertyManager |
getPropertyManager()
Get the PropertyManager in use by this PDFViewer |
boolean |
hasFeature(String feature)
Return true if the Viewer has a certain feature enabled. |
boolean |
hasFeature(ViewerFeature feature)
Return true if the Viewer has a certain feature enabled. |
void |
loadPDF(File file)
Load a PDF into the viewer from a file. |
void |
loadPDF(File file,
EncryptionHandler handler)
Deprecated. this method has been superceded by the PDFImporter class |
void |
loadPDF(File file,
EncryptionHandler[] handlers)
Deprecated. this method has been superceded by the PDFImporter class |
void |
loadPDF(InputStream in,
EncryptionHandler[] handlers,
String title,
File file)
Deprecated. this method has been superceded by the PDFImporter class |
void |
loadPDF(PDF pdf,
String name)
Load a pre-loaded PDF into the viewer. |
static void |
main(String[] args)
The main() method can be invoked to run this class from the command line. |
static PDFViewer |
newPDFViewer()
Create a new PDFViewer object in a frame of it's own. |
static PDFViewer |
newPDFViewer(Collection features)
Create a new PDFViewer object in a frame of it's own with the specified features. |
void |
putNamedComponent(String name,
JComponent value)
Add a named component to the viewers list |
void |
removeDocumentPanelListener(DocumentPanelListener listener)
Add a DocumentPanelListener to any DocumentPanel objects
created by this PDFViewer. |
void |
setKeyStoreManager(KeyStoreManager manager)
Set the KeyStoreManager used by this PDFViewer |
JMenuItem |
setMenu(String name,
char mnemonic,
boolean documentrequired,
ActionListener listener)
Add or replace a menu item in the viewer. |
void |
setPropertyManager(PropertyManager manager)
Set the PropertyManager in use by this PDFViewer |
| 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 PDFViewer(Collection features)
features - a Collection of ViewerFeature objects that are enabledViewerFeature| Method Detail |
|---|
public JSManager getJSManager()
public final void setPropertyManager(PropertyManager manager)
PropertyManager in use by this PDFViewer
public final PropertyManager getPropertyManager()
PropertyManager in use by this PDFViewer
public KeyStoreManager getKeyStoreManager()
KeyStoreManager in use by this PDFViewer
public void setKeyStoreManager(KeyStoreManager manager)
KeyStoreManager used by this PDFViewer
public boolean hasFeature(ViewerFeature feature)
feature - the feature to look forpublic boolean hasFeature(String feature)
feature - the name of the feature to look forpublic ViewerFeature[] getFeatures()
public ViewerFeature getFeature(String feature)
ViewerFeature, or null
if it doesn't exist for this viewer
public ViewerFeature getFeature(Class clazz)
ViewerFeature, or null
if it doesn't exist for this viewer
clazz - the Class of the ViewerFeature.
public JMenuItem setMenu(String name,
char mnemonic,
boolean documentrequired,
ActionListener listener)
name - the name of the menu, if the form "File\tOpen" or "File\tQuit(999)". The tab character is used to separate
the items in the menu hierarchy, and the optional bracked value is used to control ordering in the menu.mnemonic - the mnemonic to assign to this menu - lowercase or uppercase letter, or (char)0 for no mnenonicdocumentrequired - whether this menu item should only be enabled if a document is loadedlistener - the ActionListener to run when this menu item is activated
public void putNamedComponent(String name,
JComponent value)
public JComponent getNamedComponent(String name)
ViewerFeature
public void loadPDF(File file)
Importer objects in order until it finds one that matches the file,
then will use that to load the PDF into the viewer. Prompting for passwords
etc. is left to the appropriate Importer - see the PDFImporter
class for details on the default behaviour.
file - the PDF file to load, or null to select it with a chooser
public void loadPDF(File file,
EncryptionHandler handler)
PDFImporter class
PDFImporter passed in to the
PDF Constructor.
file - the PDF Filehandler - the EncryptionHandler to use
public void loadPDF(File file,
EncryptionHandler[] handlers)
PDFImporter class
PDFImporter passed in to the
PDF Constructor.
file - the PDF Filehandlers - the list of EncryptionHandlers
public void loadPDF(InputStream in,
EncryptionHandler[] handlers,
String title,
File file)
PDFImporter class
This method is now deprecated - the correct way to load a PDF from an
InputStream is to call the Importer.getImporter(PDFViewer, InputStream, String, File)
method. For example:
PDFImporter importer = (PDFImporter)viewer.getFeature(PDFImporter.class); importer.getImporter(viewer, inputstream, title, file).start(viewer, "Loading");
in - the InputStream to load the PDF fromhandlers - the EncryptionHandlers to use to try to decrypt the PDFtitle - The name of the Window. May be null.file - If using a save dialog, the initial value to set the dialog to. May be null.
public void loadPDF(PDF pdf,
String name)
pdf - the PDF to loadname - the name of the PDF, to display in the title bar.public DocumentPanel getActiveDocumentPanel()
DocumentPanel
public DocumentPanel[] getDocumentPanels()
DocumentPanels in the viewer
public void closeDocumentPanel(DocumentPanel panel)
DocumentPanel
panel - the panel to close - usually the return value of getActiveDocumentPanel()public void addDocumentPanelListener(DocumentPanelListener listener)
DocumentPanelListener to any DocumentPanel objects
created by this PDFViewer.
public void removeDocumentPanelListener(DocumentPanelListener listener)
DocumentPanelListener to any DocumentPanel objects
created by this PDFViewer.
public static PDFViewer newPDFViewer()
public static PDFViewer newPDFViewer(Collection features)
features - a Collection of ViewerFeature objects that are to be supportedViewerFeaturepublic static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||