⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaulteventhandler.java

📁 Java生成PDF Java生成PDF Java生成PDF
💻 JAVA
字号:
// $Id: DefaultEventHandler.java,v 1.9 2007/05/21 15:02:19 mike Exp $package org.faceless.pdf2.viewer;import java.awt.*;import java.util.*;import java.awt.geom.*;import java.awt.event.*;import org.faceless.pdf2.*;import org.faceless.pdf2.Event;/** * <p> * This class represents the default event handler used by the viewer. It handles * only the most basic operations - clicking on hyperlinks, mouseover and mouseout * actions on Widgets and so on, but can be used as a base or extended. * </p> * @since 2.7.8 */public class DefaultEventHandler extends EventHandler{    private PDFAnnotation lastannot;    public DefaultEventHandler() {        super(TYPE_MOUSE | TYPE_MOUSEMOTION);    }    public void mousePressed(PDFMouseEvent event) {        PDFAnnotation annot = event.getAnnotation();        if (annot!=null && annot instanceof WidgetAnnotation) {            getViewport().runAction(((WidgetAnnotation)annot).getAction(Event.MOUSEDOWN));        }    }    public void mouseReleased(PDFMouseEvent event) {        PDFAnnotation annot = event.getAnnotation();        if (annot!=null && annot instanceof WidgetAnnotation) {            getViewport().runAction(((WidgetAnnotation)annot).getAction(Event.MOUSEUP));        }    }    public void mouseMoved(PDFMouseEvent event) {        PDFAnnotation annot = event.getAnnotation();        // If the mouse has moved off or on to an annotation, run the actions and change the cursor.        if (lastannot!=annot) {            PDFViewport viewport = getViewport();            viewport.setCursor(Cursor.getDefaultCursor());            if (lastannot instanceof WidgetAnnotation) {                viewport.runAction(((WidgetAnnotation)lastannot).getAction(Event.MOUSEOUT));            }            if (annot!=null) {                viewport.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));                if (annot instanceof WidgetAnnotation) {                    viewport.runAction(((WidgetAnnotation)annot).getAction(Event.MOUSEOVER));                }            }            lastannot = annot;        }    }    public void mouseClicked(PDFMouseEvent event) {        PDFAnnotation annot = event.getAnnotation();        if (annot!=null) {            Point2D annotpoint = event.getAnnotationPoint(annot);            if (annot instanceof AnnotationLink) {                getViewport().runAction(((AnnotationLink)annot).getAction());            } else if (annot instanceof WidgetAnnotation) {                getViewport().runAction(((WidgetAnnotation)annot).getAction(Event.MOUSEUP));            }        }    }}

⌨️ 快捷键说明

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