📄 pdfmouseevent.java
字号:
// $Id: PDFMouseEvent.java,v 1.5 2007/05/21 15:02:19 mike Exp $package org.faceless.pdf2.viewer;import java.awt.event.*;import java.awt.geom.*;import java.awt.*;import org.faceless.pdf2.*;/** * An event raised when a {@link MouseEvent} is raised on the viewport. This class * wraps a {@link MouseEvent} and includes a number of methods to extract information * about where on the page the event occurred. * * @since 2.7.8 */public final class PDFMouseEvent{ private final MouseEvent event; private final PDFPage page; private final PDFViewport viewport; private final float pagex, pagey; PDFMouseEvent(MouseEvent event, PDFViewport viewport, PDFPage page, float x, float y) { this.event = event; this.viewport = viewport; this.page = page; this.pagex = x; this.pagey = y; } /** * Get the underlying {@link MouseEvent} */ public MouseEvent getMouseEvent() { return event; } /** * Calls {@link MouseEvent#getButton} on the underlying MouseEvent */ public int getButton() { return event.getButton(); } /** * Calls {@link MouseEvent#getClickCount} on the underlying MouseEvent */ public int getClickCount() { return event.getClickCount(); } /** * Calls {@link MouseEvent#getPoint} on the underlying MouseEvent */ public Point getPoint() { return event.getPoint(); } /** * Calls {@link MouseEvent#getX} on the underlying MouseEvent */ public int getX() { return event.getX(); } /** * Calls {@link MouseEvent#getY} on the underlying MouseEvent */ public int getY() { return event.getY(); } /** * Calls {@link MouseEvent#getModifiers} on the underlying MouseEvent */ public int getModifiers() { return event.getModifiers(); } /** * Returns the point on the {@link PDFPage} of this event, in points. */ public Point2D getPagePoint() { return new Point2D.Float(pagex, pagey); } /** * Returns the X co-ordinate on the {@link PDFPage} of this event, in points. */ public float getPageX() { return pagex; } /** * Returns the Y co-ordinate on the {@link PDFPage} of this event, in points. */ public float getPageY() { return pagey; } /** * Returns the {@link PDFPage} this event occured on. */ public PDFPage getPage() { return page; } /** * Returns the {@link PDFAnnotation} this event occured on on the page, or <code>null</code> * if no annotations were under the mouse. For pages with a large number of annotations this * method can be a relatively expensive operation. */ public PDFAnnotation getAnnotation() { return viewport.getAnnotation(this); } /** * Given an annotation returned from {@link #getAnnotation}, return the location of this * mouse event relative to that annotation. * @param annot the annotation returned from {@link #getAnnotation}. */ public Point2D getAnnotationPoint(PDFAnnotation annot) { if (annot!=null && annot.getPage()==page) { float[] rect = annot.getRectangle(); return new Point2D.Float(getPageX() - rect[0], getPageY() - rect[1]); } else { throw new IllegalArgumentException(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -