|
||||||||||
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.PagePanel
public class PagePanel
The PagePanel
class is the lowest-level class for rendering a PDFPage
as a JPanel
. At it's most basic it will simply render the page via a PagePainter
,
but when included inside a DocumentViewport
as part of a DocumentPanel
this class may also create subcomponents representing PDFAnnotation
s, as created by the
AnnotationComponentFactory
class.
Before a PagePanel is disposed of it should have setParser(null)
called on it.
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.
DocumentViewport
,
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 |
---|
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 | |
---|---|
PagePanel()
Create a new PagePanel |
Method Summary | |
---|---|
protected void |
addImpl(Component c,
Object constraints,
int index)
|
void |
addPagePanelInteractionListener(PagePanelInteractionListener listener)
Add a PagePanelInteractionListener to this PagePanel |
void |
addPagePanelListener(PagePanelListener listener)
Add a PagePanelListener to this PagePanel |
Point |
getAWTPoint(float x,
float y)
Given a location on the page in points, return the equivalent position on this PagePanel in pixels. |
Point |
getAWTPoint(Point2D f)
Given a location on the page in points, return the equivalent position on this PagePanel in pixels. |
Rectangle2D |
getClip()
Return the clip area actually used by the PagePanel. |
DocumentPanel |
getDocumentPanel()
Get the DocumentPanel this PagePanel is contained inside, or
null if this PagePanel was not created as part of a
DocumentPanel . |
float |
getDPI()
Return the resolution of the page currently being displayed. |
static Rectangle2D |
getFullPageView(PDFPage page)
Return the area of the page that is considered to be the "whole page" as far as the viewer is concerned - the ViewBox |
PDFPage |
getPage()
Return the PDFPage currently being displayed by this viewport. |
PageExtractor |
getPageExtractor()
Return the PageExtractor associated with this PagePanel. |
AffineTransform |
getPageToScreenTransform()
Return an AffineTransform that will map Page co-ordinates to Screen co-ordinates. |
Point2D |
getPDFPoint(int x,
int y)
Given a location on this panel in pixels, return the equivalent position on the current page in points. |
Point2D |
getPDFPoint(Point awt)
Given a location on this panel in pixels, return the equivalent position on the current page in points. |
Dimension |
getPreferredSize()
|
AffineTransform |
getScreenToPageTransform()
Return an AffineTransform that will map Page co-ordinates to Screen co-ordinates. |
Rectangle2D |
getView()
Returns the area of the page currently being displayed, in points with (0,0) at the bottom-left. |
DocumentViewport |
getViewport()
Get the DocumentViewport this PagePanel is contained inside, or
null if this PagePanel was not created as part of a
DocumentPanel |
void |
paintComponent(Graphics g)
|
void |
redrawAnnotation(PDFAnnotation annot)
Redraw the specified annotation on this page. |
void |
redrawCurrentPage()
Force a redraw of the current page |
void |
removePagePanelInteractionListener(PagePanelInteractionListener listener)
Remove a PagePanelInteractionListener from this PagePanel |
void |
removePagePanelListener(PagePanelListener listener)
Remove a PagePanelListener from this PagePanel |
void |
setExtractText(boolean extract)
Set whether to extract text while rendering this page to a PageExtractor |
void |
setPage(PDFPage page,
float x1,
float y1,
float x2,
float y2,
float dpi)
Redraw the page. |
void |
setPage(PDFPage page,
float x1,
float y1,
float x2,
float y2,
float dpi,
Rectangle clip)
Redraw the page. |
void |
setPage(PDFPage page,
Rectangle2D position,
float dpi)
Redraw the page. |
void |
setPage(PDFPage page,
Rectangle2D position,
float dpi,
Rectangle clip)
Redraw the page. |
void |
setParser(PDFParser parser)
Set the PDFParser object which should be used to render the pages. |
void |
setRenderingHints(RenderingHints hints)
Set the RenderingHints to be used when rendering pages
in this PagePanel. |
void |
setViewport(DocumentViewport viewport)
Set the viewport this PagePanel belongs to |
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 PagePanel()
Method Detail |
---|
public static Rectangle2D getFullPageView(PDFPage page)
ViewBox
PDFPage.getBox(java.lang.String)
,
PDF.getOption(java.lang.String)
public void addPagePanelListener(PagePanelListener listener)
PagePanelListener
to this PagePanel
public void removePagePanelListener(PagePanelListener listener)
PagePanelListener
from this PagePanel
public void addPagePanelInteractionListener(PagePanelInteractionListener listener)
PagePanelInteractionListener
to this PagePanel
public void removePagePanelInteractionListener(PagePanelInteractionListener listener)
PagePanelInteractionListener
from this PagePanel
public void setRenderingHints(RenderingHints hints)
RenderingHints
to be used when rendering pages
in this PagePanel.
hints
- the RenderingHints to use - may be nullpublic void setParser(PDFParser parser)
PDFParser
object which should be used to render the pages.
Setting this to null will end the background thread that renders this object,
and free any related resources.
parser
- the PDFParserpublic void setExtractText(boolean extract)
PageExtractor
extract
- true to extract the text, false otherwisepublic PageExtractor getPageExtractor()
PageExtractor
associated with this PagePanel.
To render and extract text in a single pass, the setExtractText(boolean)
method should be called before rendering, otherwise this method
will run the extraction process in a separate pass.
public void setPage(PDFPage page, Rectangle2D position, float dpi)
page
- the page to drawposition
- the area of the page to draw, in pointsdpi
- the resolutionpublic void setPage(PDFPage page, Rectangle2D position, float dpi, Rectangle clip)
page
- the page to drawposition
- the area of the page to draw, in pointsdpi
- the resolutionclip
- The graphics clip for this panel, in pixels. The panel will not
not render any of the page outside this rectangle.public void setPage(PDFPage page, float x1, float y1, float x2, float y2, float dpi)
page
- the page to drawx1
- the left-most X co-ordinate to draw, in points from the bottom-lefty1
- the bottom-most Y co-ordinate to draw, in points from the bottom-leftx2
- the right-most X co-ordinate to draw, in points from the bottom-lefty2
- the top-most Y co-ordinate to draw, in points from the bottom-leftdpi
- the resolutionpublic void setPage(PDFPage page, float x1, float y1, float x2, float y2, float dpi, Rectangle clip)
page
- the page to drawx1
- the left-most X co-ordinate to draw, in points from the bottom-lefty1
- the bottom-most Y co-ordinate to draw, in points from the bottom-leftx2
- the right-most X co-ordinate to draw, in points from the bottom-lefty2
- the top-most Y co-ordinate to draw, in points from the bottom-leftdpi
- the resolutionclip
- the graphics clip for this panel in pixels. The panel will not
render any of the page outside this rectangle.public void redrawCurrentPage()
public DocumentViewport getViewport()
DocumentViewport
this PagePanel is contained inside, or
null
if this PagePanel was not created as part of a
DocumentPanel
public DocumentPanel getDocumentPanel()
DocumentPanel
this PagePanel is contained inside, or
null
if this PagePanel was not created as part of a
DocumentPanel
. A shortcut for getViewport().getDocumentPanel()
public PDFPage getPage()
PDFPage
currently being displayed by this viewport.
Note this method returns the page being displayed, not the page currently
being rendered, so it's value will not immediately reflect the page passed
in to setPage()
, and will be null
if the
first page has not yet finished rendering.
public Rectangle2D getClip()
setPage
,
or it may be null
if the PagePanel elected to draw
the entire page instead.
public Rectangle2D getView()
getPage()
the return value of
this method will not immediately reflect the position passed in to
setPage()
, and will be null
if the first
page has not yet finished rendering.
public AffineTransform getPageToScreenTransform()
public AffineTransform getScreenToPageTransform()
public float getDPI()
getPage()
the return value of this method will not
immediately reflect the position passed in to setPage()
,
and will be 0 if the fist page has not yet finished rendering.
public Point2D getPDFPoint(int x, int y)
getAWTPoint(float, float)
public Point2D getPDFPoint(Point awt)
getAWTPoint(float, float)
public Point getAWTPoint(float x, float y)
getPDFPoint(int, int)
public Point getAWTPoint(Point2D f)
getPDFPoint(int, int)
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public void setViewport(DocumentViewport viewport)
protected void addImpl(Component c, Object constraints, int index)
addImpl
in class Container
public void redrawAnnotation(PDFAnnotation annot)
IllegalStateException
- if the PagePanel is not part of
a DocumentPanel
and so has no annotations.public void paintComponent(Graphics g)
paintComponent
in class JComponent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |