public ZLTextElementArea getStartArea(ZLTextPage page) { if (isEmpty()) { return null; } final ZLTextElementAreaVector vector = page.TextElementMap; final ZLTextRegion region = vector.getRegion(myLeftMostRegionSoul); if (region != null) { return region.getFirstArea(); } final ZLTextElementArea firstArea = vector.getFirstArea(); if (firstArea != null && myLeftMostRegionSoul.compareTo(firstArea) <= 0) { return firstArea; } return null; }
void expandTo(int x, int y) { if (isEmpty()) { return; } final ZLTextElementAreaVector vector = myView.myCurrentPage.TextElementMap; final ZLTextElementArea firstArea = vector.getFirstArea(); final ZLTextElementArea lastArea = vector.getLastArea(); if (firstArea != null && y < firstArea.YStart) { if (myScroller != null && myScroller.scrollsForward()) { myScroller.stop(); myScroller = null; } if (myScroller == null) { myScroller = new Scroller(false, x, y); return; } } else if (lastArea != null && y + ZLTextSelectionCursor.getHeight() / 2 + ZLTextSelectionCursor.getAccent() / 2 > lastArea.YEnd) { if (myScroller != null && !myScroller.scrollsForward()) { myScroller.stop(); myScroller = null; } if (myScroller == null) { myScroller = new Scroller(true, x, y); return; } } else { if (myScroller != null) { myScroller.stop(); myScroller = null; } } if (myScroller != null) { myScroller.setXY(x, y); } ZLTextRegion region = myView.findRegion(x, y, ZLTextView.MAX_SELECTION_DISTANCE, ZLTextRegion.AnyRegionFilter); if (region == null && myScroller != null) { region = myView.findRegion(x, y, ZLTextRegion.AnyRegionFilter); } if (region == null) { return; } final ZLTextRegion.Soul soul = region.getSoul(); if (myCursorInMovement == ZLTextSelectionCursor.Right) { if (myLeftMostRegionSoul.compareTo(soul) <= 0) { myRightMostRegionSoul = soul; } else { myRightMostRegionSoul = myLeftMostRegionSoul; myLeftMostRegionSoul = soul; myCursorInMovement = ZLTextSelectionCursor.Left; } } else { if (myRightMostRegionSoul.compareTo(soul) >= 0) { myLeftMostRegionSoul = soul; } else { myLeftMostRegionSoul = myRightMostRegionSoul; myRightMostRegionSoul = soul; myCursorInMovement = ZLTextSelectionCursor.Right; } } if (myCursorInMovement == ZLTextSelectionCursor.Right) { if (hasAPartAfterPage(myView.myCurrentPage)) { myView.scrollPage(true, ZLTextView.ScrollingMode.SCROLL_LINES, 1); myView.Application.getViewWidget().reset(); myView.preparePaintInfo(); } } else { if (hasAPartBeforePage(myView.myCurrentPage)) { myView.scrollPage(false, ZLTextView.ScrollingMode.SCROLL_LINES, 1); myView.Application.getViewWidget().reset(); myView.preparePaintInfo(); } } }