Class TextSelection

    • Field Detail

      • logger

        protected static final Logger logger
      • selectedCount

        public int selectedCount
      • lastMousePressedLocation

        protected Point lastMousePressedLocation
      • lastMouseLocation

        protected Point lastMouseLocation
      • topMargin

        protected int topMargin
      • bottomMargin

        protected int bottomMargin
      • enableMarginExclusion

        protected static boolean enableMarginExclusion
      • enableMarginExclusionBorder

        protected static boolean enableMarginExclusionBorder
      • topMarginExclusion

        protected Rectangle2D topMarginExclusion
      • bottomMarginExclusion

        protected Rectangle2D bottomMarginExclusion
      • pageLock

        protected Page pageLock
    • Method Detail

      • wordLineSelection

        public void wordLineSelection​(int clickCount,
                                      Point clickPoint,
                                      AbstractPageViewComponent pageViewComponent)
        Handles double and triple left mouse clicks to select a word or line of text respectively.
        Parameters:
        clickCount - number of mouse clicks to interpret for line or word selection.
        clickPoint - point that mouse was clicked.
        pageViewComponent - parent page view component
      • selectionStart

        public void selectionStart​(Point startPoint,
                                   AbstractPageViewComponent pageViewComponent,
                                   boolean isFirst)
        Selection started so we want to record the position and update the selection rectangle.
        Parameters:
        startPoint - starting selection position.
        isFirst - start of selection if true
        pageViewComponent - parent page component
      • selectionEnd

        public void selectionEnd​(Point endPoint,
                                 AbstractPageViewComponent pageViewComponent)
        Selection ended so we want to stop record the position and update the selection.
        Parameters:
        pageViewComponent - page component view
        endPoint - end point of drag
      • clearSelection

        public void clearSelection()
      • clearSelectionState

        public void clearSelectionState()
      • calculateTextSelectionExclusion

        protected void calculateTextSelectionExclusion()
      • paintSelectedText

        public static void paintSelectedText​(Graphics g,
                                             AbstractPageViewComponent pageViewComponent,
                                             DocumentViewModel documentViewModel)
                                      throws InterruptedException
        Paints any text that is selected in the page wrapped by a pageViewComponent.
        Parameters:
        g - graphics context to paint to.
        pageViewComponent - page view component to paint selected to on.
        documentViewModel - document model contains view properties such as zoom and rotation.
        Throws:
        InterruptedException - thread interrupted.
      • multiLineSelectHandler

        protected void multiLineSelectHandler​(AbstractPageViewComponent pageViewComponent,
                                              Point mouseLocation,
                                              boolean isDown,
                                              boolean isLocalDown,
                                              boolean isMovingRight)
                                       throws InterruptedException
        Entry point for multiline text selection. Contains logic for moving from once page to the next which boils down to defining a start position when a new page is entered.
        Parameters:
        pageViewComponent - page view that is being acted.
        mouseLocation - current mouse location already normalized to page space. .
        isDown - general selection trent is down, if false it's up.
        isMovingRight - general selection trent is right, if false it's left.
        isLocalDown - local movement is down.
        Throws:
        InterruptedException - thread interrupted.
      • wordSelectHandler

        protected void wordSelectHandler​(Page currentPage,
                                         Point mouseLocation)
                                  throws InterruptedException
        Utility for selecting multiple lines via rectangle like tool. The selection works based on the intersection of the rectangle and glyph bounding box. This method should only be called from within a locked page content
        Parameters:
        currentPage - page to looking for text intersection on.
        mouseLocation - location of mouse.
        Throws:
        InterruptedException - thread interrupted.
      • lineSelectHandler

        protected void lineSelectHandler​(Page currentPage,
                                         Point mouseLocation)
                                  throws InterruptedException
        Utility for selecting a LineText which is usually a sentence in the document. This is usually triggered by a triple click of the mouse
        Parameters:
        currentPage - page to select
        mouseLocation - location of mouse
        Throws:
        InterruptedException - thread interrupted.
      • setTopMargin

        public void setTopMargin​(int topMargin)
        Sets the top margin used to define an exclusion zone for text selection. For this value to be applied the system property -Dorg.icepdf.core.views.page.marginExclusion.enabled=true must be set.
        Parameters:
        topMargin - top margin height in pixels.
      • setBottomMargin

        public void setBottomMargin​(int bottomMargin)
        Sets the bottom margin used to define an exclusion zone for text selection. For this value to be applied the system property -Dorg.icepdf.core.views.page.marginExclusion.enabled=true must be set.
        Parameters:
        bottomMargin - bottom margin height in pixels.
      • convertToPageSpace

        protected Rectangle convertToPageSpace​(ArrayList<Shape> bounds,
                                               GeneralPath path)
        Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.
        Parameters:
        bounds - bounds to convert to page space
        path - path
        Returns:
        transformed bBox.