|
||||||||||
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.DocumentViewport
public abstract class DocumentViewport
A DocumentViewport
displays a view of a PDF inside a DocumentPanel
,
although it can also be instantiated on it's own if required. It typically will contain
one or more PagePanel
objects along with scrollbars and whatever else is required
to display the document in limited screen space.
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.
PagePanel
,
DocumentPanel
,
Serialized FormNested 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 | |
---|---|
protected static Cursor |
CURSOR_GRAB
|
protected static Cursor |
CURSOR_GRABBING
|
protected int |
mouseWheelUnit
|
static int |
ZOOM_FIT
A value that can be passed in to setZoomMode(int) to specify that the document
should be zoomed to fit the entire page in the Viewport. |
static int |
ZOOM_FITHEIGHT
A value that can be passed in to setZoomMode(int) to specify that the document
should be zoomed to ensure the height fits the height of the Viewport. |
static int |
ZOOM_FITWIDTH
A value that can be passed in to setZoomMode(int) to specify that the document
shuold be zoomed to ensure the width fits the width of the Viewport. |
static int |
ZOOM_NONE
A value that can be passed to setZoomMode(int) to specify that no re-zooming
of the page should be performed when the Viewport is resized; this is the default. |
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 | |
---|---|
DocumentViewport()
|
|
DocumentViewport(LayoutManager manager)
|
Method Summary | |
---|---|
abstract void |
addPagePanelInteractionListener(PagePanelInteractionListener listener)
Add a PagePanelInteractionListener to any PagePanel objects that have been
or will be created by this DocumentViewport |
abstract void |
addPagePanelListener(PagePanelListener listener)
Add a PagePanelListener to any PagePanel objects that have been
or will be created by this DocumentViewport |
void |
ensureVisible(PDFPage page,
double x,
double y)
Ensure the specified point on the page is visible. |
abstract Adjustable |
getAdjustable(int position)
Return the "Adjustable" object for the specified position - typically this is the horizontal or vertical JScrollBar , although this method may
return null or accept other parameters. |
protected RenderingHints |
getDefaultRenderingHints()
|
DocumentPanel |
getDocumentPanel()
Return the DocumentPanel containing this DocumentViewport. |
PDFPage |
getPage()
Return the PDFPage in use by getPagePanel() |
abstract PagePanel |
getPagePanel()
Get the currently displayed PagePanel. |
Collection |
getPagePanels()
Returns a read only Collection containing all the PagePanels currently displayed in this Viewport. |
abstract PDFPage |
getRenderingPage()
Return the page that is currently in the process of rendering. |
float |
getTargetZoom(int zoommode,
PDFPage page)
Return the appropriate zoom level when switching to the specified page. |
abstract JComponent |
getView()
Get the JComponent that directly contains the PagePanel objects, not including scrollbars or other similar items. |
abstract Dimension |
getViewportSize()
Return the size in pixels of the space available to display pages in this viewport, not including scrollbars or other decoration |
abstract float |
getZoom()
Get the current zoom level |
int |
getZoomMode()
Return the current value of the zoom-mode, as set by setZoomMode(int) . |
abstract boolean |
isDraggable()
Indicates whether the contents of this viewport can be dragged with the mouse to position them. |
boolean |
isPageVisible(PDFPage page,
double x,
double y)
Indicates whether the specified point in the specified page is visible in the viewport. |
protected boolean |
isSmoothScrolling()
Return true if this viewport is smooth scrolling |
void |
propertyChange(PropertyChangeEvent event)
The viewport implements PropertyChangeListener, and will be called whenever the PDF has been updated. |
abstract void |
removePagePanelInteractionListener(PagePanelInteractionListener listener)
Remove a PagePanelInteractionListener from any PagePanel objects
that have been created by this DocumentViewport |
abstract void |
removePagePanelListener(PagePanelListener listener)
Remove a PagePanelListener from any PagePanel objects that have been
created by this DocumentViewport |
abstract void |
setAdjustableValues(int horizontal,
int vertical)
Set the values of the adjustables returned by getAdjustable(int) . |
void |
setDocumentPanel(DocumentPanel panel)
Set the DocumentPanel that contains this DocumentViewport. |
abstract void |
setDraggable(boolean draggable)
Sets whether to allow the contents of this viewport to be dragged with the mouse. |
abstract void |
setPage(PDFPage page,
double x,
double y,
double zoom)
Set the currently displayed page. |
abstract void |
setRenderingHints(RenderingHints hints)
Set the RenderingHints that should be used when rendering the pages |
abstract void |
setZoom(float zoom)
Set the zoom level of this DocumentViewport. |
void |
setZoomMode(int mode)
Control how the document in the viewport is redrawn when the Viewport is resized. |
protected void |
smoothScroll(int x,
int y,
JScrollBar hsb,
JScrollBar vsb)
Smoothly adjust the supplied scrollbars from their current position to the specified position, or (if hsb or vsb are null) cancel any running adjustment. |
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 |
Field Detail |
---|
protected static final Cursor CURSOR_GRAB
protected static final Cursor CURSOR_GRABBING
protected int mouseWheelUnit
public static final int ZOOM_NONE
setZoomMode(int)
to specify that no re-zooming
of the page should be performed when the Viewport is resized; this is the default.
public static final int ZOOM_FIT
setZoomMode(int)
to specify that the document
should be zoomed to fit the entire page in the Viewport.
public static final int ZOOM_FITWIDTH
setZoomMode(int)
to specify that the document
shuold be zoomed to ensure the width fits the width of the Viewport.
public static final int ZOOM_FITHEIGHT
setZoomMode(int)
to specify that the document
should be zoomed to ensure the height fits the height of the Viewport.
Constructor Detail |
---|
public DocumentViewport()
public DocumentViewport(LayoutManager manager)
Method Detail |
---|
protected final RenderingHints getDefaultRenderingHints()
public abstract void setRenderingHints(RenderingHints hints)
RenderingHints
that should be used when rendering the pages
public void setZoomMode(int mode)
ZOOM_NONE
, which means no action is performed, but other
actions include ZOOM_FIT
, ZOOM_FITWIDTH
and ZOOM_FITHEIGHT
,
which will ensure that the document is always zoomed to fit completely, fit the width
or fit the height of the viewport respectively
public int getZoomMode()
setZoomMode(int)
.
The returnd value is one of ZOOM_FIT
, ZOOM_FITWIDTH
, ZOOM_FITHEIGHT
or ZOOM_NONE
(the default).
public float getTargetZoom(int zoommode, PDFPage page)
zoommode
is ZOOM_NONE
then this
just returns the value of getZoom()
, otherwise the returned zoom level
will correctly fit the page to the Viewport.
page
- the PDFPage that we are calculating the zoom for.getZoomMode()
public abstract void setPage(PDFPage page, double x, double y, double zoom)
page
- the page to displayx
- the left-most X position of the page, relative to PagePanel.getFullPageView(org.faceless.pdf2.PDFPage)
. A value of NaN means keep the current valuey
- the top-most Y position of the page, relative to PagePanel.getFullPageView(org.faceless.pdf2.PDFPage)
. A value of NaN means keep the current valuezoom
- the zoom level. A value of <= 0 or NaN means keep the current zoom. A value of one means 72dpipublic void ensureVisible(PDFPage page, double x, double y)
x
- the X position of the page in absolute PDF points (ie measured from the bottom left)y
- the Y position of the page in absolute PDF points (ie measured from the bottom left)public boolean isPageVisible(PDFPage page, double x, double y)
x
or y
is
NaN
, indicates whether any part of the page is visible.
x
- the X position of the page in pointsy
- the Y position of the page in pointspublic abstract void setZoom(float zoom)
public abstract float getZoom()
public abstract PagePanel getPagePanel()
setPage()
, the exact
implementation of this method depends on the type of viewport, but the idea is
it returns the PagePanel that is the primary focus of this viewport.
public abstract JComponent getView()
public Collection getPagePanels()
public PDFPage getPage()
getPagePanel()
public abstract PDFPage getRenderingPage()
getPage()
public abstract Dimension getViewportSize()
public abstract Adjustable getAdjustable(int position)
JScrollBar
, although this method may
return null
or accept other parameters. The adjustable is
measured in AWT space (pixels from the top left). This method may return
null if there is no adjustable.
position
- one of Adjustable.HORIZONTAL
or Adjustable.VERTICAL
public abstract void setAdjustableValues(int horizontal, int vertical)
getAdjustable(int)
.
Calling this method is preferable to setting the values of each adjustable
individually when both are to be set
horizontal
- the value for the Adjustable.HORIZONTAL
adjustable.vertical
- the value for the Adjustable.VERTICAL
adjustable.public DocumentPanel getDocumentPanel()
DocumentPanel
containing this DocumentViewport.
public void setDocumentPanel(DocumentPanel panel)
super.setDocumentPanel(panel)
public abstract void addPagePanelListener(PagePanelListener listener)
PagePanelListener
to any PagePanel
objects that have been
or will be created by this DocumentViewport
listener
- the listenerpublic abstract void removePagePanelListener(PagePanelListener listener)
PagePanelListener
from any PagePanel
objects that have been
created by this DocumentViewport
listener
- the listenerpublic abstract void addPagePanelInteractionListener(PagePanelInteractionListener listener)
PagePanelInteractionListener
to any PagePanel
objects that have been
or will be created by this DocumentViewport
listener
- the listenerpublic abstract void removePagePanelInteractionListener(PagePanelInteractionListener listener)
PagePanelInteractionListener
from any PagePanel
objects
that have been created by this DocumentViewport
listener
- the listenerpublic abstract boolean isDraggable()
public abstract void setDraggable(boolean draggable)
draggable
- if true, contents may be draggedpublic void propertyChange(PropertyChangeEvent event)
propertyChange
in interface PropertyChangeListener
protected void smoothScroll(int x, int y, JScrollBar hsb, JScrollBar vsb)
smoothScrollTime
and
smoothScrollDistance
properties on the DocumentPanel,
and both default to 500
x
- the desired position of the horizontal scrollbary
- the desired position of the vertical scrollbarhsb
- the horizontal scrollbarvsb
- the vertical scrollbarprotected boolean isSmoothScrolling()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |