Search in sources :

Example 6 with PageLink

use of org.ebookdroid.core.codec.PageLink in project LibreraReader by foobnix.

the class PageImaveView method getPageLink.

public PageLink getPageLink(float x1, float y1) {
    List<PageLink> pageLinks = getPageLinks();
    if (pageLinks == null) {
        return null;
    }
    RectF tr = new RectF();
    imageMatrix().mapRect(tr);
    float x = x1 - tr.left;
    float y = y1 - tr.top;
    float[] f = new float[9];
    imageMatrix().getValues(f);
    float scaleX = f[Matrix.MSCALE_X];
    x = x / scaleX;
    y = y / scaleX;
    RectF tapRect = new RectF(x, y, x, y);
    for (PageLink link : pageLinks) {
        if (link == null) {
            continue;
        }
        RectF wordRect = transform(link.sourceRect, 0);
        boolean intersects = RectF.intersects(wordRect, tapRect);
        if (intersects) {
            return link;
        }
    }
    return null;
}
Also used : RectF(android.graphics.RectF) PageLink(org.ebookdroid.core.codec.PageLink)

Example 7 with PageLink

use of org.ebookdroid.core.codec.PageLink in project LibreraReader by foobnix.

the class DjvuPage method getPageLinks1.

public List<PageLink> getPageLinks1() {
    TempHolder.lock.lock();
    try {
        final List<PageLink> links = getPageLinks(docHandle, pageNo);
        if (links != null) {
            final float width = getWidth();
            final float height = getHeight();
            for (final PageLink link : links) {
                normalize(link.sourceRect, width, height);
                if (link.url != null && link.url.startsWith("#")) {
                    try {
                        link.targetPage = Integer.parseInt(link.url.substring(1)) - 1;
                        link.url = null;
                    } catch (final NumberFormatException ex) {
                        ex.printStackTrace();
                    }
                }
            }
            return links;
        }
    } finally {
        TempHolder.lock.unlock();
    }
    return Collections.emptyList();
}
Also used : PageLink(org.ebookdroid.core.codec.PageLink)

Aggregations

PageLink (org.ebookdroid.core.codec.PageLink)7 RectF (android.graphics.RectF)6 Paint (android.graphics.Paint)1 TextPaint (android.text.TextPaint)1 ArrayList (java.util.ArrayList)1 TextWord (org.ebookdroid.droids.mupdf.codec.TextWord)1