// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/exception/PageRenderingException.java
// public class PageRenderingException extends Exception {
//     private final int page;
// 
//     public PageRenderingException(int page, Throwable cause) {
//         super(cause);
//         this.page = page;
//     }
// 
//     public int getPage() {
//         return page;
//     }
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/PagePart.java
// public class PagePart {
// 
//     private int page;
// 
//     private Bitmap renderedBitmap;
// 
//     private RectF pageRelativeBounds;
// 
//     private boolean thumbnail;
// 
//     private int cacheOrder;
// 
//     public PagePart(int page, Bitmap renderedBitmap, RectF pageRelativeBounds, boolean thumbnail, int cacheOrder) {
//         super();
//         this.page = page;
//         this.renderedBitmap = renderedBitmap;
//         this.pageRelativeBounds = pageRelativeBounds;
//         this.thumbnail = thumbnail;
//         this.cacheOrder = cacheOrder;
//     }
// 
//     public int getCacheOrder() {
//         return cacheOrder;
//     }
// 
//     public int getPage() {
//         return page;
//     }
// 
//     public Bitmap getRenderedBitmap() {
//         return renderedBitmap;
//     }
// 
//     public RectF getPageRelativeBounds() {
//         return pageRelativeBounds;
//     }
// 
//     public boolean isThumbnail() {
//         return thumbnail;
//     }
// 
//     public void setCacheOrder(int cacheOrder) {
//         this.cacheOrder = cacheOrder;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (!(obj instanceof PagePart)) {
//             return false;
//         }
// 
//         PagePart part = (PagePart) obj;
//         return part.getPage() == page
//                 && part.getPageRelativeBounds().left == pageRelativeBounds.left
//                 && part.getPageRelativeBounds().right == pageRelativeBounds.right
//                 && part.getPageRelativeBounds().top == pageRelativeBounds.top
//                 && part.getPageRelativeBounds().bottom == pageRelativeBounds.bottom;
//     }
// 
// }


import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.github.barteksc.pdfviewer.exception.PageRenderingException;
import com.github.barteksc.pdfviewer.model.PagePart;


        pdfFile.renderPageBitmap(render, renderingTask.page, roundedRenderBounds, renderingTask.annotationRendering);

        return new PagePart(renderingTask.page, render,
                renderingTask.bounds, renderingTask.thumbnail,
                renderingTask.cacheOrder);
    }

    private void calculateBounds(int width, int height, RectF pageSliceBounds) {
        renderMatrix.reset();
        renderMatrix.postTranslate(-pageSliceBounds.left * width, -pageSliceBounds.top * height);
        renderMatrix.postScale(1 / pageSliceBounds.width(), 1 / pageSliceBounds.height());

        renderBounds.set(0, 0, width, height);
        renderMatrix.mapRect(renderBounds);
        renderBounds.round(roundedRenderBounds);
    }

    void stop() {
        running = false;
    }

    void start() {
        running = true;
    }

    private class RenderingTask {

        float width, height;


// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/exception/PageRenderingException.java
// public class PageRenderingException extends Exception {
//     private final int page;
// 
//     public PageRenderingException(int page, Throwable cause) {
//         super(cause);
//         this.page = page;
//     }
// 
//     public int getPage() {
//         return page;
//     }
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/PagePart.java
// public class PagePart {
// 
//     private int page;
// 
//     private Bitmap renderedBitmap;
// 
//     private RectF pageRelativeBounds;
// 
//     private boolean thumbnail;
// 
//     private int cacheOrder;
// 
//     public PagePart(int page, Bitmap renderedBitmap, RectF pageRelativeBounds, boolean thumbnail, int cacheOrder) {
//         super();
//         this.page = page;
//         this.renderedBitmap = renderedBitmap;
//         this.pageRelativeBounds = pageRelativeBounds;
//         this.thumbnail = thumbnail;
//         this.cacheOrder = cacheOrder;
//     }
// 
//     public int getCacheOrder() {
//         return cacheOrder;
//     }
// 
//     public int getPage() {
//         return page;
//     }
// 
//     public Bitmap getRenderedBitmap() {
//         return renderedBitmap;
//     }
// 
//     public RectF getPageRelativeBounds() {
//         return pageRelativeBounds;
//     }
// 
//     public boolean isThumbnail() {
//         return thumbnail;
//     }
// 
//     public void setCacheOrder(int cacheOrder) {
//         this.cacheOrder = cacheOrder;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (!(obj instanceof PagePart)) {
//             return false;
//         }
// 
//         PagePart part = (PagePart) obj;
//         return part.getPage() == page
//                 && part.getPageRelativeBounds().left == pageRelativeBounds.left
//                 && part.getPageRelativeBounds().right == pageRelativeBounds.right
//                 && part.getPageRelativeBounds().top == pageRelativeBounds.top
//                 && part.getPageRelativeBounds().bottom == pageRelativeBounds.bottom;
//     }
// 
// }


// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/RenderingHandler.java
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.github.barteksc.pdfviewer.exception.PageRenderingException;
import com.github.barteksc.pdfviewer.model.PagePart;


        pdfFile.renderPageBitmap(render, renderingTask.page, roundedRenderBounds, renderingTask.annotationRendering);

        return new PagePart(renderingTask.page, render,
                renderingTask.bounds, renderingTask.thumbnail,
                renderingTask.cacheOrder);
    }

    private void calculateBounds(int width, int height, RectF pageSliceBounds) {
        renderMatrix.reset();
        renderMatrix.postTranslate(-pageSliceBounds.left * width, -pageSliceBounds.top * height);
        renderMatrix.postScale(1 / pageSliceBounds.width(), 1 / pageSliceBounds.height());

        renderBounds.set(0, 0, width, height);
        renderMatrix.mapRect(renderBounds);
        renderBounds.round(roundedRenderBounds);
    }

    void stop() {
        running = false;
    }

    void start() {
        running = true;
    }

    private class RenderingTask {

        float width, height;


        RectF bounds;
