org.faceless.pdf2.viewer2
Class AnnotationComponentFactory

java.lang.Object
  extended by org.faceless.pdf2.viewer2.ViewerFeature
      extended by org.faceless.pdf2.viewer2.AnnotationComponentFactory
Direct Known Subclasses:
AnnotationLinkFactory, AnnotationNoteFactory, AnnotationStampFactory, AnnotationTextFactory, FormBlankSignatureWidgetFactory, FormButtonWidgetFactory, FormChoiceWidgetFactory, FormRadioButtonWidgetFactory, FormSignedSignatureWidgetFactory, FormTextWidgetFactory

public abstract class AnnotationComponentFactory
extends ViewerFeature

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 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.

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.

Since:
2.8

Constructor Summary
AnnotationComponentFactory(String name)
          Create a new AnnotationComponentFactory
 
Method Summary
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.
abstract  JComponent createComponent(PagePanel pagepanel, PDFAnnotation annot)
          Return a JComponent that will visually represent the specified PDFAnnotation.
 JComponent createEditComponent(PDFAnnotation annot, boolean readonly, boolean create)
          Return a JComponent that can be used to edit the annotation or display additional information.
 PDFAnnotation createNewAnnotation()
          Return a brand new annotation of the type that is edited with this factory.
 String getAnnotationType()
          Return the name of the type of widgets this AnnotationComponentFactory creates or edits.
abstract  boolean matches(PDFAnnotation annot)
          Return true if this AnnotationComponentFactory could create a JComponent for the specified PDFAnnotation.
protected static void paintComponent(JComponent comp, String state, Graphics g)
          This method can be called by the paintComponent method of each JComponent returned from an AnnotationComponentFactory to repaint the annotation using the content of the annotation.
 String toString()
           
 
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllFeatures, getCustomJavaScript, getName, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AnnotationComponentFactory

public AnnotationComponentFactory(String name)
Create a new AnnotationComponentFactory

Parameters:
name - the name of this ViewerFeature
Method Detail

toString

public String toString()
Overrides:
toString in class ViewerFeature

matches

public abstract boolean matches(PDFAnnotation annot)
Return true if this AnnotationComponentFactory could create a JComponent for the specified PDFAnnotation.


createComponent

public abstract JComponent createComponent(PagePanel pagepanel,
                                           PDFAnnotation annot)
Return a JComponent that will visually represent the specified PDFAnnotation.

Parameters:
pagepanel - the panel the JComponent will be added to
annot - the annotation

createEditComponent

public JComponent createEditComponent(PDFAnnotation annot,
                                      boolean readonly,
                                      boolean create)
Return a JComponent that can be used to edit the annotation or display additional information. If the annotation has no dialog that should work with it in this way, this method should return null (the default)

Parameters:
annot - the annotation
readonly - whether we are displaying or editing the annotation
create - if readonly if false, whether we are editing an existing or creating a new annotation
Since:
2.10

getAnnotationType

public String getAnnotationType()
Return the name of the type of widgets this AnnotationComponentFactory creates or edits.

Since:
2.10

createNewAnnotation

public PDFAnnotation createNewAnnotation()
Return a brand new annotation of the type that is edited with this factory. If this factory cannot be used to create a new annotation, this method can return null (the default)

Since:
2.10

paintComponent

protected static final void paintComponent(JComponent comp,
                                           String state,
                                           Graphics g)
This method can be called by the paintComponent method of each JComponent returned from an AnnotationComponentFactory to repaint the annotation using the content of the annotation.

Parameters:
comp - the component
state - the state to paint. Typically this will be "N"
g - the Graphics object
See Also:
PagePainter.paintAnnotation(org.faceless.pdf2.PDFAnnotation, java.lang.String, java.awt.Graphics2D, float[])

bindComponentLocation

public static final void bindComponentLocation(JComponent component,
                                               float[] rect)
Cause the specified JComponent to be positioned at the PDF co-ordinates specified by rect. If the page is scrolled or zoomed the component will be zoomed and resized to match.

Parameters:
component - the Component
rect - the component location in PDF space, specified as [x1, y1, x2, y2]

bindComponentLocation

public static final 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. If the page is scrolled or zoomed the component will be zoomed and resized to match.

Parameters:
component - the Component
x1 - the left-most X co-ordinate of the component in PDF space
y1 - the bottom-most Y co-ordinate of the component in PDF space
x2 - the right-most X co-ordinate of the component in PDF space
y2 - the top-most Y co-ordinate of the component in PDF space

bindComponentLocation

public static final void bindComponentLocation(JComponent component,
                                               PDFAnnotation annot)
Cause the specified JComponent to be positioned at same position as the PDFAnnotation. If the page is scrolled or zoomed the component will be zoomed and resized to match.

Parameters:
component - the Component
annot - the PDFAnnotation to bind the components position to


Copyright © 2001-2008 Big Faceless Organization