Android Open Source - android-pdfview Page






From Project

Back to project page android-pdfview.

License

The source code is released under:

GNU General Public License

If you think the Android project android-pdfview listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.vudroid.core;
//ww  w  . j  a  v a2  s . co m
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.text.TextPaint;

class Page {
    final int index;
    RectF bounds;
    private PageTreeNode node;
    private DocumentView documentView;
    private final TextPaint textPaint = textPaint();
    private final Paint fillPaint = fillPaint();
    private final Paint strokePaint = strokePaint();

    Page(DocumentView documentView, int index) {
        this.documentView = documentView;
        this.index = index;
        node = new PageTreeNode(documentView, new RectF(0, 0, 1, 1), this, 1, null);
    }

    private float aspectRatio;

    float getPageHeight(int mainWidth, float zoom) {
        return mainWidth / getAspectRatio() * zoom;
    }

    public int getTop() {
        return Math.round(bounds.top);
    }

    public void draw(Canvas canvas) {
        if (!isVisible()) {
            return;
        }
        canvas.drawRect(bounds, fillPaint);

        canvas.drawText("Page " + (index + 1), bounds.centerX(), bounds.centerY(), textPaint);
        node.draw(canvas);
        canvas.drawLine(bounds.left, bounds.top, bounds.right, bounds.top, strokePaint);
        canvas.drawLine(bounds.left, bounds.bottom, bounds.right, bounds.bottom, strokePaint);
    }

    private Paint strokePaint() {
        final Paint strokePaint = new Paint();
        strokePaint.setColor(Color.BLACK);
        strokePaint.setStyle(Paint.Style.STROKE);
        strokePaint.setStrokeWidth(2);
        return strokePaint;
    }

    private Paint fillPaint() {
        final Paint fillPaint = new Paint();
        fillPaint.setColor(Color.GRAY);
        fillPaint.setStyle(Paint.Style.FILL);
        return fillPaint;
    }

    private TextPaint textPaint() {
        final TextPaint paint = new TextPaint();
        paint.setColor(Color.BLACK);
        paint.setAntiAlias(true);
        paint.setTextSize(24);
        paint.setTextAlign(Paint.Align.CENTER);
        return paint;
    }

    public float getAspectRatio() {
        return aspectRatio;
    }

    public void setAspectRatio(float aspectRatio) {
        if (this.aspectRatio != aspectRatio) {
            this.aspectRatio = aspectRatio;
            documentView.invalidatePageSizes();
        }
    }

    public boolean isVisible() {
        return RectF.intersects(documentView.getViewRect(), bounds);
    }

    public void setAspectRatio(int width, int height) {
        setAspectRatio(width * 1.0f / height);
    }

    void setBounds(RectF pageBounds) {
        bounds = pageBounds;
        node.invalidateNodeBounds();
    }

    public void updateVisibility() {
        node.updateVisibility();
    }

    public void invalidate() {
        node.invalidate();
    }
}




Java Source Code List

com.joanzapata.PDFViewActivity.java
com.joanzapata.pdfview.AnimationManager.java
com.joanzapata.pdfview.CacheManager.java
com.joanzapata.pdfview.DecodingAsyncTask.java
com.joanzapata.pdfview.DragPinchManager.java
com.joanzapata.pdfview.PDFView.java
com.joanzapata.pdfview.RenderingAsyncTask.java
com.joanzapata.pdfview.SpiralLoopManager.java
com.joanzapata.pdfview.exception.FileNotFoundException.java
com.joanzapata.pdfview.listener.OnDrawListener.java
com.joanzapata.pdfview.listener.OnLoadCompleteListener.java
com.joanzapata.pdfview.listener.OnPageChangeListener.java
com.joanzapata.pdfview.model.PagePart.java
com.joanzapata.pdfview.util.ArrayUtils.java
com.joanzapata.pdfview.util.Constants.java
com.joanzapata.pdfview.util.DragPinchListener.java
com.joanzapata.pdfview.util.FileUtils.java
com.joanzapata.pdfview.util.NumberUtils.java
org.vudroid.core.DecodeServiceBase.java
org.vudroid.core.DecodeService.java
org.vudroid.core.DocumentView.java
org.vudroid.core.PageTreeNode.java
org.vudroid.core.Page.java
org.vudroid.core.VuDroidLibraryLoader.java
org.vudroid.core.codec.CodecContext.java
org.vudroid.core.codec.CodecDocument.java
org.vudroid.core.codec.CodecPage.java
org.vudroid.core.events.BringUpZoomControlsEvent.java
org.vudroid.core.events.BringUpZoomControlsListener.java
org.vudroid.core.events.CurrentPageListener.java
org.vudroid.core.events.DecodingProgressListener.java
org.vudroid.core.events.EventDispatcher.java
org.vudroid.core.events.Event.java
org.vudroid.core.events.SafeEvent.java
org.vudroid.core.events.ZoomChangedEvent.java
org.vudroid.core.events.ZoomListener.java
org.vudroid.core.models.CurrentPageModel.java
org.vudroid.core.models.DecodingProgressModel.java
org.vudroid.core.models.ZoomModel.java
org.vudroid.core.multitouch.MultiTouchZoomImpl.java
org.vudroid.core.multitouch.MultiTouchZoom.java
org.vudroid.core.utils.MD5StringUtil.java
org.vudroid.core.utils.PathFromUri.java
org.vudroid.pdfdroid.codec.PdfContext.java
org.vudroid.pdfdroid.codec.PdfDocument.java
org.vudroid.pdfdroid.codec.PdfPage.java