|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.viewer2.ViewerFeature
org.faceless.pdf2.viewer2.AnnotationComponentFactory
public abstract class AnnotationComponentFactory
A type of ViewerFeature that creates a JComponent
to represent a
PDFAnnotation
on the page. Typically AnnotationComponentFactories
are singleton objects, as they do not need to be tied to a specific viewer.
For viewing components, all that needs to be overridden are the
matches()
and possibly createComponent()
methods. If you want to use this factory to edit and/or create new annotations,
it's necessary to override the
createEditComponent()
,
getAnnotationType()
and
createNewAnnotation()
methods as well.
delete | If set to false, the "delete" option will not be available when an annotation is right-clicked |
---|---|
edit | If set to false, the "edit" option will not be available when an annotation is right-clicked |
flatten | If set to false, the "flatten" option will not be available when an annotation is right-clicked |
AnnotationStamp
objects only, you could insert this code for an application:
System.setProperty("org.faceless.pdf2.viewer2.AnnotationComponentFactory.flatten", "false"); System.setProperty("org.faceless.pdf2.viewer2.feature.AnnotationStampFactory.delete", "false");or add the following parameters for an applet.
<param name="AnnotationComponentFactory.flatten" value="false" /> <param name="feature.AnnotationStampFactory.delete" value="false" />
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.
Field Summary | |
---|---|
static Border |
FOCUSBORDER
|
Constructor Summary | |
---|---|
AnnotationComponentFactory(String name)
Create a new AnnotationComponentFactory |
Method Summary | |
---|---|
protected void |
addStockDetailsToEditComponent(PDFAnnotation annot,
JComponent editorpane)
Convenience method that can be used by factories to add universal details about the annotation (date, author etc) to the EditComponent in a standardized way (assuming that the editorpane is using a GridBagLayout). |
static void |
bindComponentLocation(JComponent component,
float[] rect)
Cause the specified JComponent to be positioned at the PDF co-ordinates specified by rect . |
static void |
bindComponentLocation(JComponent component,
float x1,
float y1,
float x2,
float y2)
Cause the specified JComponent to be positioned at the specified PDF co-ordinates. |
static void |
bindComponentLocation(JComponent component,
PDFAnnotation annot)
Cause the specified JComponent to be positioned at same position as the PDFAnnotation. |
static void |
bindComponentLocation(JComponent component,
Rectangle2D rect)
Cause the specified JComponent to be positioned at the PDF co-ordinates specified by rect . |
protected void |
copyAnnotationState(PDFAnnotation source,
PDFAnnotation target)
Copies the properties of a given source annotation created by this factory to a target annotation of the same type. |
JComponent |
createComponent(PagePanel pagepanel,
PDFAnnotation annot)
Return a JComponent that will visually represent the specified PDFAnnotation. |
protected Action |
createDeleteAction(PDFAnnotation annot,
Component comp)
|
protected Action |
createEditAction(PDFAnnotation annot,
Component comp)
|
JComponent |
createEditComponent(PDFAnnotation annot,
boolean readonly,
boolean create)
Return a JComponent that can be used to edit the annotation or display additional information. |
protected Action |
createFlattenAction(PDFAnnotation annot,
Component comp)
|
PDFAnnotation |
createNewAnnotation()
Return a brand new annotation of the type that is edited with this factory. |
PDFAnnotation |
createNewAnnotation(float x1,
float y1,
float x2,
float y2)
Returns a new annotation of this factory's type with specified bounds. |
String |
getAnnotationType()
Return the name of the type of widgets this AnnotationComponentFactory creates or edits. |
Preferences |
getPreferences()
Return the Preferences object used by the viewer (may be null ) |
PDFViewer |
getViewer()
Return the Viewer this Factory is a part of |
void |
initialize(PDFViewer viewer)
Called when the feature is first added to a viewer |
void |
makeComponentDraggable(JComponent comp,
PDFAnnotation annot,
boolean resizable)
Given an Annotation component created by a subclass of this factory, add appropriate handlers to it to make it draggable and/or resizable. |
abstract boolean |
matches(PDFAnnotation annot)
Return true if this AnnotationComponentFactory could create a JComponent
for the specified PDFAnnotation . |
static void |
paintComponent(JComponent comp,
ComponentUI ui,
Graphics g)
A convenient static method which can be called to paint the content of a Component with the standard PDF-centric way (painting its appearance streams). |
protected void |
paintComponentAnnotations(JComponent c,
Graphics g)
Paint any visible annotations that should be drawn on top of the annotation. |
protected void |
popupPropertyMenu(PDFAnnotation annot,
Component comp,
Point where)
Display the Property menu for this annotation. |
void |
postEdit(PDFAnnotation annot,
PagePanel pagepanel,
String action)
Called after an annotation is added or edited - by default, a no-op |
String |
toString()
|
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature |
---|
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final transient Border FOCUSBORDER
Constructor Detail |
---|
public AnnotationComponentFactory(String name)
name
- the name of this ViewerFeatureMethod Detail |
---|
public void initialize(PDFViewer viewer)
ViewerFeature
initialize
in class ViewerFeature
public Preferences getPreferences()
null
)
public PDFViewer getViewer()
public String toString()
toString
in class ViewerFeature
public abstract boolean matches(PDFAnnotation annot)
JComponent
for the specified PDFAnnotation
.
public JComponent createComponent(PagePanel pagepanel, PDFAnnotation annot)
Return a JComponent that will visually represent the specified PDFAnnotation. The default implementation returns a JPanel that will display the annotation appearance - it's usually best to call super.createComponent() then add any required listeners in the subclasses.
By default this method returns a JCompoment whose paintComponent()
method is overridden to call paintComponent(this, this.ui, g)
followed by
paintComponentAnnotations(this, g)
- typically, the main reason to override this
method is when a different type of object is required (eg. a JTextField
)
pagepanel
- the panel the JComponent will be added toannot
- the annotationpaintComponentAnnotations()
,
paintComponent()
protected void paintComponentAnnotations(JComponent c, Graphics g)
PDFAnnotation
- these annotations
are simply graphical additions to the AWT component. A good example is
digital signature fields, which should display a tick, cross or question-mark
depending on the current verified status of the signature. The default implementation
is a no-op.
paintComponent()
,
createComponent()
public JComponent createEditComponent(PDFAnnotation annot, boolean readonly, boolean create)
annot
- the annotationreadonly
- whether we are displaying or editing the annotationcreate
- if readonly if false, whether we are editing an existing or creating a new annotationprotected void addStockDetailsToEditComponent(PDFAnnotation annot, JComponent editorpane)
editorpane
is using a GridBagLayout).
public void postEdit(PDFAnnotation annot, PagePanel pagepanel, String action)
annot
- the annotationpagepanel
- the PagePanel the Annotation was added onaction
- one of "create", "edit", "flatten" or "delete"public String getAnnotationType()
public PDFAnnotation createNewAnnotation()
null
(the default)
public PDFAnnotation createNewAnnotation(float x1, float y1, float x2, float y2)
x1
- the lower left x coordinatey1
- the lower left y coordinatex2
- the top right x coordinatey2
- the top right y coordinatepublic static final void paintComponent(JComponent comp, ComponentUI ui, Graphics g)
paintComponent()
method of the
JComponent
returned from createComponent
to do the actual painting.
comp
- the JComponent we're paintingui
- the ui
field of that componentg
- the Graphics object we're painting topaintComponentAnnotations()
,
createComponent()
public static final void bindComponentLocation(JComponent component, Rectangle2D rect)
rect
.
If the page is scrolled or zoomed the component will be zoomed and resized to match.
component
- the Componentrect
- the component location in PDF spacepublic static final void bindComponentLocation(JComponent component, float[] rect)
rect
.
If the page is scrolled or zoomed the component will be zoomed and resized to match.
component
- the Componentrect
- the component location in PDF space, specified as [x1, y1, x2, y2]public static final void bindComponentLocation(JComponent component, float x1, float y1, float x2, float y2)
component
- the Componentx1
- the left-most X co-ordinate of the component in PDF spacey1
- the bottom-most Y co-ordinate of the component in PDF spacex2
- the right-most X co-ordinate of the component in PDF spacey2
- the top-most Y co-ordinate of the component in PDF spacepublic static final void bindComponentLocation(JComponent component, PDFAnnotation annot)
component
- the Componentannot
- the PDFAnnotation to bind the components position topublic void makeComponentDraggable(JComponent comp, PDFAnnotation annot, boolean resizable)
comp
- the JComponentannot
- the PDFAnnotationresizable
- whether the Component should be resizable as opposed to just draggableprotected void copyAnnotationState(PDFAnnotation source, PDFAnnotation target)
source
- the annotation to copy properties fromtarget
- the annotation to copy properties toprotected void popupPropertyMenu(PDFAnnotation annot, Component comp, Point where)
AnnotationComponentFactory
when the component is right-clicked, and it
should display the edit and delete actions.
protected Action createEditAction(PDFAnnotation annot, Component comp)
protected Action createDeleteAction(PDFAnnotation annot, Component comp)
protected Action createFlattenAction(PDFAnnotation annot, Component comp)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |