// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/LinkTapEvent.java
// public class LinkTapEvent {
//     private float originalX;
//     private float originalY;
//     private float documentX;
//     private float documentY;
//     private RectF mappedLinkRect;
//     private PdfDocument.Link link;
// 
//     public LinkTapEvent(float originalX, float originalY, float documentX, float documentY, RectF mappedLinkRect, PdfDocument.Link link) {
//         this.originalX = originalX;
//         this.originalY = originalY;
//         this.documentX = documentX;
//         this.documentY = documentY;
//         this.mappedLinkRect = mappedLinkRect;
//         this.link = link;
//     }
// 
//     public float getOriginalX() {
//         return originalX;
//     }
// 
//     public float getOriginalY() {
//         return originalY;
//     }
// 
//     public float getDocumentX() {
//         return documentX;
//     }
// 
//     public float getDocumentY() {
//         return documentY;
//     }
// 
//     public RectF getMappedLinkRect() {
//         return mappedLinkRect;
//     }
// 
//     public PdfDocument.Link getLink() {
//         return link;
//     }
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/SnapEdge.java
// public enum SnapEdge {
//     START, CENTER, END, NONE
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MAXIMUM_ZOOM = 10;
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MINIMUM_ZOOM = 1;


import android.graphics.PointF;
import android.graphics.RectF;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import com.github.barteksc.pdfviewer.model.LinkTapEvent;
import com.github.barteksc.pdfviewer.scroll.ScrollHandle;
import com.github.barteksc.pdfviewer.util.SnapEdge;
import com.shockwave.pdfium.PdfDocument;
import com.shockwave.pdfium.util.SizeF;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MAXIMUM_ZOOM;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MINIMUM_ZOOM;


    private void onBoundedFling(float velocityX, float velocityY) {
        int xOffset = (int) pdfView.getCurrentXOffset();
        int yOffset = (int) pdfView.getCurrentYOffset();

        PdfFile pdfFile = pdfView.pdfFile;

        float pageStart = -pdfFile.getPageOffset(pdfView.getCurrentPage(), pdfView.getZoom());
        float pageEnd = pageStart - pdfFile.getPageLength(pdfView.getCurrentPage(), pdfView.getZoom());
        float minX, minY, maxX, maxY;
        if (pdfView.isSwipeVertical()) {
            minX = -(pdfView.toCurrentScale(pdfFile.getMaxPageWidth()) - pdfView.getWidth());
            minY = pageEnd + pdfView.getHeight();
            maxX = 0;
            maxY = pageStart;
        } else {
            minX = pageEnd + pdfView.getWidth();
            minY = -(pdfView.toCurrentScale(pdfFile.getMaxPageHeight()) - pdfView.getHeight());
            maxX = pageStart;
            maxY = 0;
        }

        animationManager.startFlingAnimation(xOffset, yOffset, (int) (velocityX), (int) (velocityY),
                (int) minX, (int) maxX, (int) minY, (int) maxY);
    }

    @Override
    public boolean onScale(ScaleGestureDetector detector) {
        float dr = detector.getScaleFactor();
        float wantedZoom = pdfView.getZoom() * dr;

// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/LinkTapEvent.java
// public class LinkTapEvent {
//     private float originalX;
//     private float originalY;
//     private float documentX;
//     private float documentY;
//     private RectF mappedLinkRect;
//     private PdfDocument.Link link;
// 
//     public LinkTapEvent(float originalX, float originalY, float documentX, float documentY, RectF mappedLinkRect, PdfDocument.Link link) {
//         this.originalX = originalX;
//         this.originalY = originalY;
//         this.documentX = documentX;
//         this.documentY = documentY;
//         this.mappedLinkRect = mappedLinkRect;
//         this.link = link;
//     }
// 
//     public float getOriginalX() {
//         return originalX;
//     }
// 
//     public float getOriginalY() {
//         return originalY;
//     }
// 
//     public float getDocumentX() {
//         return documentX;
//     }
// 
//     public float getDocumentY() {
//         return documentY;
//     }
// 
//     public RectF getMappedLinkRect() {
//         return mappedLinkRect;
//     }
// 
//     public PdfDocument.Link getLink() {
//         return link;
//     }
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/SnapEdge.java
// public enum SnapEdge {
//     START, CENTER, END, NONE
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MAXIMUM_ZOOM = 10;
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MINIMUM_ZOOM = 1;


// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/DragPinchManager.java
import android.graphics.PointF;
import android.graphics.RectF;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import com.github.barteksc.pdfviewer.model.LinkTapEvent;
import com.github.barteksc.pdfviewer.scroll.ScrollHandle;
import com.github.barteksc.pdfviewer.util.SnapEdge;
import com.shockwave.pdfium.PdfDocument;
import com.shockwave.pdfium.util.SizeF;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MAXIMUM_ZOOM;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MINIMUM_ZOOM;


    private void onBoundedFling(float velocityX, float velocityY) {
        int xOffset = (int) pdfView.getCurrentXOffset();
        int yOffset = (int) pdfView.getCurrentYOffset();

        PdfFile pdfFile = pdfView.pdfFile;

        float pageStart = -pdfFile.getPageOffset(pdfView.getCurrentPage(), pdfView.getZoom());
        float pageEnd = pageStart - pdfFile.getPageLength(pdfView.getCurrentPage(), pdfView.getZoom());
        float minX, minY, maxX, maxY;
        if (pdfView.isSwipeVertical()) {
            minX = -(pdfView.toCurrentScale(pdfFile.getMaxPageWidth()) - pdfView.getWidth());
            minY = pageEnd + pdfView.getHeight();
            maxX = 0;
            maxY = pageStart;
        } else {
            minX = pageEnd + pdfView.getWidth();
            minY = -(pdfView.toCurrentScale(pdfFile.getMaxPageHeight()) - pdfView.getHeight());
            maxX = pageStart;
            maxY = 0;
        }

        animationManager.startFlingAnimation(xOffset, yOffset, (int) (velocityX), (int) (velocityY),
                (int) minX, (int) maxX, (int) minY, (int) maxY);
    }

    @Override
    public boolean onScale(ScaleGestureDetector detector) {
        float dr = detector.getScaleFactor();
        float wantedZoom = pdfView.getZoom() * dr;

        float minZoom = Math.min(MINIMUM_ZOOM, pdfView.getMinZoom());
