annotationstampfactory.java

来自「Java生成PDF Java生成PDF Java生成PDF」· Java 代码 · 共 65 行

JAVA
65
字号
// $Id: AnnotationStampFactory.java,v 1.4 2007/09/12 10:04:59 mike Exp $package org.faceless.pdf2.viewer2.feature;import org.faceless.pdf2.viewer2.*;import org.faceless.pdf2.*;import javax.swing.*;import java.awt.geom.*;import javax.swing.event.*;import java.awt.event.*;import java.awt.*;import java.util.*;/** * Create annotations that handle {@link AnnotationStamp} objects. * Currently all that is handled is the ability to drag them if they're not readonly. * The name of this feature is "AnnotationStamp". * <p><i>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.</i></p> * @since 2.8 */public class AnnotationStampFactory extends AnnotationComponentFactory{    private static AnnotationStampFactory instance;    /**     * Return the AnnotationStampFactory     */    public static AnnotationStampFactory getInstance() {        if (instance==null) instance = new AnnotationStampFactory();        return instance;    }    private AnnotationStampFactory() {        super("AnnotationStamp");    }    public boolean matches(PDFAnnotation annot) {        return annot instanceof AnnotationStamp;    }    public JComponent createComponent(final PagePanel pagepanel, PDFAnnotation a) {        final AnnotationStamp annot = (AnnotationStamp)a;        final JComponent comp = new JPanel() {            public void paintComponent(Graphics g) {                 AnnotationComponentFactory.paintComponent(this, "N", g);            }        };        if (!annot.isReadOnly()) {            comp.addMouseListener(new MouseListener() {                public void mouseEntered(MouseEvent event) { comp.setCursor(new Cursor(Cursor.HAND_CURSOR)); }                public void mouseExited(MouseEvent event) { comp.setCursor(Cursor.getDefaultCursor()); }                public void mousePressed(MouseEvent event) {}                public void mouseReleased(MouseEvent event) {}                public void mouseClicked(MouseEvent event) {}            });            AnnotationDragListener listener = new AnnotationDragListener(pagepanel, comp, annot);            comp.addMouseListener(listener);            comp.addMouseMotionListener(listener);        }        return comp;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?