org.faceless.pdf2.viewer2.feature

## Class AnnotationStampFactory

- java.lang.Object
- - org.faceless.pdf2.viewer2.ViewerFeature
  - - org.faceless.pdf2.viewer2.AnnotationComponentFactory
    - - org.faceless.pdf2.viewer2.feature.AnnotationStampFactory

-     public class AnnotationStampFactory
      extends AnnotationComponentFactory

  Create annotations that handle `AnnotationStamp` objects. Currently all that is handled is the ability to drag them if they're not readonly.
  The following initialization parameters can be specified to configure this feature.

  stampList | A comma seperated list of stamp names, to be passed in to `setStampList()`
  stampHeight | The height of each stamp in the edit dialog, as passed in to `setStampHeight(int)`

  The name of this feature is AnnotationStamp

  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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String[]` | `PREDEFINED`

    - ### Fields inherited from class org.faceless.pdf2.viewer2.AnnotationComponentFactory

      `FOCUSBORDER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AnnotationStampFactory()` Return a new AnnotationStampFactory

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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 a)` 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(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.
    `AnnotationStamp` | `getStamp(String stampname)` Get an AnnotationStamp for the specified stamp name.
    `BufferedImage` | `getStampImage(AnnotationStamp stamp, int height, PDFParser parser)` Create the image for the specified AnnotationStamp
    `void` | `initialize(PDFViewer viewer)` Called when the feature is first added to a viewer
    `boolean` | `matches(PDFAnnotation annot)` Return true if this AnnotationComponentFactory could create a `JComponent` for the specified `PDFAnnotation`.
    `void` | `setStampHeight(int stampheight)` Set the height of the stamp images in the edit component.
    `void` | `setStampList(String[] stamplist)` Set the list of stamp names to choose from.

    - ### Methods inherited from class org.faceless.pdf2.viewer2.AnnotationComponentFactory

      `addStockDetailsToEditComponent, bindComponentLocation, bindComponentLocation, bindComponentLocation, bindComponentLocation, createDeleteAction, createEditAction, createFlattenAction, createNewAnnotation, getPreferences, getViewer, isFactoryReadOnly, makeComponentInteractive, paintComponent, paintComponentAnnotations, popupPropertyMenu, postEdit, 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

    - #### PREDEFINED

          public static final String[] PREDEFINED

  - ### Constructor Detail

    - #### AnnotationStampFactory

          public AnnotationStampFactory()

      Return a new AnnotationStampFactory

  - ### Method Detail

    - #### initialize

          public void initialize(PDFViewer viewer)

      Description copied from class: `ViewerFeature`
      Called when the feature is first added to a viewer
      Overrides:
        `initialize` in class `AnnotationComponentFactory`

    - #### setStampList

          public void setStampList(String[] stamplist)

      Set the list of stamp names to choose from. This defaults to the list in `PREDEFINED`
      Since:
        2.11.19

    - #### setStampHeight

          public void setStampHeight(int stampheight)

      Set the height of the stamp images in the edit component. The default value is 40

    - #### matches

          public boolean matches(PDFAnnotation annot)

      Description copied from class: `AnnotationComponentFactory`
      Return true if this AnnotationComponentFactory could create a `JComponent` for the specified `PDFAnnotation`.
      Specified by:
        `matches` in class `AnnotationComponentFactory`

    - #### getAnnotationType

          public String getAnnotationType()

      Description copied from class: `AnnotationComponentFactory`
      Return the name of the type of widgets this AnnotationComponentFactory creates or edits.
      Overrides:
        `getAnnotationType` in class `AnnotationComponentFactory`

    - #### createComponent

          public JComponent createComponent(PagePanel pagepanel,
                                            PDFAnnotation a)

      Description copied from class: `AnnotationComponentFactory`

      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`)

      Overrides:
        `createComponent` in class `AnnotationComponentFactory`
      Parameters:
        `pagepanel` - the panel the JComponent will be added to
        `a` - the annotation
      See Also:
        `paintComponentAnnotations()`, `paintComponent()`

    - #### createNewAnnotation

          public PDFAnnotation createNewAnnotation(float x1,
                                                   float y1,
                                                   float x2,
                                                   float y2)

      Description copied from class: `AnnotationComponentFactory`
      Returns a new annotation of this factory's type with specified bounds.
      Overrides:
        `createNewAnnotation` in class `AnnotationComponentFactory`
      Parameters:
        `x1` - the lower left x coordinate
        `y1` - the lower left y coordinate
        `x2` - the top right x coordinate
        `y2` - the top right y coordinate

    - #### createEditComponent

          public JComponent createEditComponent(PDFAnnotation annot,
                                                boolean readonly,
                                                boolean create)

      Description copied from class: `AnnotationComponentFactory`
      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)
      Overrides:
        `createEditComponent` in class `AnnotationComponentFactory`
      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

    - #### copyAnnotationState

          protected void copyAnnotationState(PDFAnnotation source,
                                             PDFAnnotation target)

      Description copied from class: `AnnotationComponentFactory`
      Copies the properties of a given source annotation created by this factory to a target annotation of the same type. This is used to make a temporary copy of an annotation for editing purposes.
      Overrides:
        `copyAnnotationState` in class `AnnotationComponentFactory`
      Parameters:
        `source` - the annotation to copy properties from
        `target` - the annotation to copy properties to

    - #### getStampImage

          public BufferedImage getStampImage(AnnotationStamp stamp,
                                             int height,
                                             PDFParser parser)

      Create the image for the specified AnnotationStamp
      Parameters:
        `stamp` - the stamp to render
        `height` - the height of the stamp image
        `parser` - the PDFParser to use to convert
      Since:
        2.1.19

    - #### getStamp

          public AnnotationStamp getStamp(String stampname)

      Get an AnnotationStamp for the specified stamp name. By default this calls `new `AnnotationStamp`(stampname, 1)`, but it can be overridden to handle custom stamps if necessary.
      Since:
        2.1.19

Copyright © 2001-2015 Big Faceless Organization