Package org.albite.book.view

Examples of org.albite.book.view.Region


        //#if !(TinyMode || TinyModeExport || LightMode || LightModeExport)
        if (mode == MODE_TEXT_SELECTING) {
            if (regionSelectedFirst != -1 && regionSelectedLast != -1) {

                final Region r =
                        chapterBooklet.getCurrentPage().getRegionForIndex(
                        regionSelectedFirst);

                final int start = (
                        r != null
                        ? r.getPosition()
                        : chapterBooklet.getCurrentPage().getStart());

                final String text =
                        chapterBooklet.getCurrentPage().getTextForBookmark(
                        chapterBooklet.getTextBuffer(),
                        regionSelectedFirst, regionSelectedLast);

                app.setCurrentBookmarkOptions(start, text);
                app.setEntryForLookup(text);

                app.touchContextMethod();
            }

            regionSelectedFirst = -1;
            regionSelectedLast = -1;
            mode = MODE_PAGE_READING;
            currentPageCanvas.renderPage(currentScheme);
            repaint();

            return;
        }
        //#endif

        boolean holding = holdingValid &&
            (System.currentTimeMillis() - startPointerHoldingTime >
            currentHoldingTime);

        switch(mode) {
            case MODE_PAGE_READING:

                final int xCenteredAbs = Math.abs(x - (w / 2));
                final int yCenteredAbs = Math.abs(y - (h / 2));

                final int p2 = progressBarWidth / 2;

                if (orientation == ORIENTATION_0 && y > h - statusBarHeight) {
                    /*
                     * status bar area
                     */
                    if (xCenteredAbs < p2) {
                        /*
                         * progress bar
                         */
                        if (holding) {

                            /*
                             * Scroll directly
                             */
                            goToPosition(
                                    currentBook.getCurrentChapter(),
                                    ((float) (x - progressBarX))
                                    / ((float)progressBarWidth));
                        } else {

                            /*
                             * Show toc
                             */
                            app.calledOutside();
                            app.showToc();
                        }
                    } else {
                        /*
                         * Chapter or clock
                         */
                        app.calledOutside();
                        app.showBookInfo();
                    }
                    return;
                } else if (
                        //#if !(TinyMode || TinyModeExport || LightMode || LightModeExport)
                        !holding &&
                        //#endif
                        (scrollingOnX ? x - w : y - h) >
                        (orientation == ORIENTATION_0 && !scrollingOnX
                            ? -MARGIN_CLICK_TRESHOLD - statusBarHeight
                            : -MARGIN_CLICK_TRESHOLD)) {

                    /* Right Page position */

                    scheduleScrolling(SCROLL_NEXT);
                    mode = MODE_PAGE_SCROLLING;
                    return;
                } else if (
                        //#if !(TinyMode || TinyModeExport || LightMode || LightModeExport)
                        !holding &&
                        //#endif
                        (scrollingOnX ? x : y) <
                        (orientation == ORIENTATION_0 && !scrollingOnX
                            ? MARGIN_CLICK_TRESHOLD + MENU_HEIGHT
                            : MARGIN_CLICK_TRESHOLD)) {

                    /* Left Page position */

                    mode = MODE_PAGE_SCROLLING;
                    scheduleScrolling(SCROLL_PREV);
                    return;
                } else if (
                        //#if !(TinyMode || TinyModeExport || LightMode || LightModeExport)
                        !holding &&
                        //#endif
                        xCenteredAbs < centerBoxSide &&
                        yCenteredAbs < centerBoxSide) {

                    /*
                     * Somewhere in the middle.
                     */
                    //#if (TinyMode || TinyModeExport || LightMode || LightModeExport)
//#                         app.calledOutside();
//#                         app.showMenu();
                    //#else
                        if (!seenFullscreenAlert && !fullscreen) {
                            Alert fsAlert = new Alert("See here.", "You're entering into fullscreen mode. To restore the menu on the top, just tap the centre of the screen.", null, AlertType.INFO);
                            fsAlert.setTimeout(10000);
                            seenFullscreenAlert = true;
                            app.switchDisplayable(fsAlert, this);
                        }
                        setOrientation(ORIENTATION_0, !fullscreen);
                    //#endif
                    return;
                }

                //#if !(TinyMode || TinyModeExport || LightMode || LightModeExport)
                if (holding) {

                    /*
                     * find (x, y) coords from page's viewpoint,
                     * taking into account
                     * fullscreen mode / screen orientation
                     */

                    final int realx = getXonPage(x, y);
                    final int realy = getYonPage(x, y);

                    Region r =
                            chapterBooklet.getCurrentPage().getRegionAt(
                            realx, realy);

                    if (r != null) {
                        /*
                         * Get the text
                         */

                        final int start = r.getPosition();

                        final String text =
                                r.getText(chapterBooklet.getTextBuffer());

                        if (text != null) {
                            app.setCurrentBookmarkOptions(start, text);
                            app.setEntryForLookup(text);
                            app.touchContextMethod();
View Full Code Here

TOP

Related Classes of org.albite.book.view.Region

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.