Class DefaultCodeAreaPainter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void attach()
      Attaches painter to code area.
      java.util.Optional<org.exbin.bined.basic.CodeAreaScrollPosition> computeCenterOnScrollPosition​(org.exbin.bined.CodeAreaCaretPosition caretPosition)
      Returns scroll position so that provided caret position is visible in the center of the scrolled area.
      org.exbin.bined.CodeAreaCaretPosition computeMovePosition​(org.exbin.bined.CodeAreaCaretPosition position, org.exbin.bined.basic.MovementDirection direction)
      Computes position for movement action.
      org.exbin.bined.basic.PositionScrollVisibility computePositionScrollVisibility​(org.exbin.bined.CodeAreaCaretPosition caretPosition)
      Returns state of the visibility of given caret position within current scrolling window.
      java.util.Optional<org.exbin.bined.basic.CodeAreaScrollPosition> computeRevealScrollPosition​(org.exbin.bined.CodeAreaCaretPosition caretPosition)
      Returns scroll position so that provided caret position is visible in scrolled area.
      org.exbin.bined.basic.CodeAreaScrollPosition computeScrolling​(org.exbin.bined.basic.CodeAreaScrollPosition startPosition, org.exbin.bined.basic.ScrollingDirection direction)
      Computes scrolling position for given shift action.
      void detach()
      Detaches painter to code area.
      protected void drawCenteredChars​(java.awt.Graphics g, char[] drawnChars, int charOffset, int length, int cellWidth, int positionX, int positionY)
      Draws characters centering it to cells of the same width.
      protected void drawShiftedChars​(java.awt.Graphics g, char[] drawnChars, int charOffset, int length, int positionX, int positionY)  
      void fontChanged​(java.awt.Graphics g)  
      BasicCodeAreaColorsProfile getBasicColors()
      Returns basic profile for colors.
      int getBytesPerRow()  
      java.awt.Rectangle getCursorPositionRect​(long dataPosition, int codeOffset, org.exbin.bined.CodeAreaSection section)
      Returns cursor rectangle.
      protected int getCharactersPerRow()  
      int getMouseCursorShape​(int positionX, int positionY)
      Returns type of cursor for given painter relative position.
      java.awt.Color getPositionBackgroundColor​(long rowDataPosition, int byteOnRow, int charOnRow, org.exbin.bined.CodeAreaSection section)
      Returns background color for particular code.
      java.awt.Point getPositionPoint​(long dataPosition, int codeOffset, org.exbin.bined.CodeAreaSection section)
      Returns relative cursor position in code area or null if cursor is not visible.
      java.awt.Color getPositionTextColor​(long rowDataPosition, int byteOnRow, int charOnRow, org.exbin.bined.CodeAreaSection section)
      Returns background color for particular code.
      org.exbin.bined.basic.BasicCodeAreaZone getPositionZone​(int positionX, int positionY)
      Returns zone type for given position.
      int getRowHeight()  
      boolean isInitialized()
      Returns true if painter was initialized.
      org.exbin.bined.CodeAreaCaretPosition mousePositionToClosestCaretPosition​(int positionX, int positionY, org.exbin.bined.CaretOverlapMode overflowMode)
      Returns closest caret position for provided component relative mouse position.
      void paintBackground​(java.awt.Graphics g)
      Paints main area background.
      void paintComponent​(java.awt.Graphics g)
      Paints the main component.
      void paintCursor​(java.awt.Graphics g)
      Paints cursor symbol.
      void paintHeader​(java.awt.Graphics g)  
      void paintMainArea​(java.awt.Graphics g)
      Paints main data section of the component.
      void paintOutsideArea​(java.awt.Graphics g)  
      void paintRowBackground​(java.awt.Graphics g, long rowDataPosition, int rowPositionX, int rowPositionY)
      Paints row background.
      void paintRowPosition​(java.awt.Graphics g)  
      void paintRows​(java.awt.Graphics g)  
      void paintRowText​(java.awt.Graphics g, long rowDataPosition, int rowPositionX, int rowPositionY)
      Paints row text.
      void rebuildColors()
      Calls rebuild of the colors profile.
      void recomputeCharPositions()  
      void reset()
      Resets complete painter state for new painting.
      void resetCaret()
      Resets caret state.
      void resetColors()
      Rebuilds colors after UIManager change.
      void resetFont()
      Resets painter font state for new painting.
      void resetLayout()
      Updates painter layout state for new painting.
      void scrollPositionChanged()
      Notify scroll position was changed outside of scrolling.
      void scrollPositionModified()
      Notify scroll position was modified.
      void setBasicColors​(BasicCodeAreaColorsProfile colorsProfile)
      Sets basic profile for colors.
      protected void updateCache()  
      protected void updateRectToCursorPosition​(java.awt.Rectangle rect, long dataPosition, int codeOffset, org.exbin.bined.CodeAreaSection section)  
      void updateScrollBars()
      Performs update of scrollbars after change in data size or position.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • DefaultCodeAreaPainter

        public DefaultCodeAreaPainter​(CodeAreaCore codeArea)
    • Method Detail

      • reset

        public void reset()
        Description copied from interface: CodeAreaPainter
        Resets complete painter state for new painting.
        Specified by:
        reset in interface CodeAreaPainter
      • recomputeCharPositions

        public void recomputeCharPositions()
      • fontChanged

        public void fontChanged​(java.awt.Graphics g)
      • isInitialized

        public boolean isInitialized()
        Description copied from interface: CodeAreaPainter
        Returns true if painter was initialized.
        Specified by:
        isInitialized in interface CodeAreaPainter
        Returns:
        true if initialized
      • paintComponent

        public void paintComponent​(java.awt.Graphics g)
        Description copied from interface: CodeAreaPainter
        Paints the main component.
        Specified by:
        paintComponent in interface CodeAreaPainter
        Parameters:
        g - graphics
      • updateCache

        protected void updateCache()
      • paintOutsideArea

        public void paintOutsideArea​(java.awt.Graphics g)
      • paintHeader

        public void paintHeader​(java.awt.Graphics g)
      • paintRowPosition

        public void paintRowPosition​(java.awt.Graphics g)
      • paintMainArea

        public void paintMainArea​(java.awt.Graphics g)
        Description copied from interface: CodeAreaPainter
        Paints main data section of the component.
        Specified by:
        paintMainArea in interface CodeAreaPainter
        Parameters:
        g - graphics
      • paintBackground

        public void paintBackground​(java.awt.Graphics g)
        Paints main area background.
        Parameters:
        g - graphics
      • paintRows

        public void paintRows​(java.awt.Graphics g)
      • paintRowBackground

        public void paintRowBackground​(java.awt.Graphics g,
                                       long rowDataPosition,
                                       int rowPositionX,
                                       int rowPositionY)
        Paints row background.
        Parameters:
        g - graphics
        rowDataPosition - row data position
        rowPositionX - row position X
        rowPositionY - row position Y
      • getPositionBackgroundColor

        @Nullable
        public java.awt.Color getPositionBackgroundColor​(long rowDataPosition,
                                                         int byteOnRow,
                                                         int charOnRow,
                                                         org.exbin.bined.CodeAreaSection section)
        Returns background color for particular code.
        Parameters:
        rowDataPosition - row data position
        byteOnRow - byte on current row
        charOnRow - character on current row
        section - current section
        Returns:
        color or null for default color
      • computePositionScrollVisibility

        @Nonnull
        public org.exbin.bined.basic.PositionScrollVisibility computePositionScrollVisibility​(org.exbin.bined.CodeAreaCaretPosition caretPosition)
        Description copied from interface: CodeAreaPainter
        Returns state of the visibility of given caret position within current scrolling window.
        Specified by:
        computePositionScrollVisibility in interface CodeAreaPainter
        Parameters:
        caretPosition - caret position
        Returns:
        visibility state
      • computeRevealScrollPosition

        @Nonnull
        public java.util.Optional<org.exbin.bined.basic.CodeAreaScrollPosition> computeRevealScrollPosition​(org.exbin.bined.CodeAreaCaretPosition caretPosition)
        Description copied from interface: CodeAreaPainter
        Returns scroll position so that provided caret position is visible in scrolled area. Performs minimal scrolling and tries to preserve current vertical / horizontal scrolling if possible. If given position cannot be fully shown, top left corner is preferred.
        Specified by:
        computeRevealScrollPosition in interface CodeAreaPainter
        Parameters:
        caretPosition - caret position
        Returns:
        scroll position or null if caret position is already visible / scrolled to the best fit
      • computeCenterOnScrollPosition

        @Nonnull
        public java.util.Optional<org.exbin.bined.basic.CodeAreaScrollPosition> computeCenterOnScrollPosition​(org.exbin.bined.CodeAreaCaretPosition caretPosition)
        Description copied from interface: CodeAreaPainter
        Returns scroll position so that provided caret position is visible in the center of the scrolled area. Attempts to center as much as possible while preserving scrolling limits.
        Specified by:
        computeCenterOnScrollPosition in interface CodeAreaPainter
        Parameters:
        caretPosition - caret position
        Returns:
        scroll position or null if desired scroll position is the same as current scroll position.
      • paintRowText

        public void paintRowText​(java.awt.Graphics g,
                                 long rowDataPosition,
                                 int rowPositionX,
                                 int rowPositionY)
        Paints row text.
        Parameters:
        g - graphics
        rowDataPosition - row data position
        rowPositionX - row position X
        rowPositionY - row position Y
      • getPositionTextColor

        @Nullable
        public java.awt.Color getPositionTextColor​(long rowDataPosition,
                                                   int byteOnRow,
                                                   int charOnRow,
                                                   org.exbin.bined.CodeAreaSection section)
        Returns background color for particular code.
        Parameters:
        rowDataPosition - row data position
        byteOnRow - byte on current row
        charOnRow - character on current row
        section - current section
        Returns:
        color or null for default color
      • paintCursor

        public void paintCursor​(java.awt.Graphics g)
        Description copied from interface: CodeAreaPainter
        Paints cursor symbol.
        Specified by:
        paintCursor in interface CodeAreaPainter
        Parameters:
        g - graphics
      • mousePositionToClosestCaretPosition

        @Nonnull
        public org.exbin.bined.CodeAreaCaretPosition mousePositionToClosestCaretPosition​(int positionX,
                                                                                         int positionY,
                                                                                         org.exbin.bined.CaretOverlapMode overflowMode)
        Description copied from interface: CodeAreaPainter
        Returns closest caret position for provided component relative mouse position.
        Specified by:
        mousePositionToClosestCaretPosition in interface CodeAreaPainter
        Parameters:
        positionX - component relative position X
        positionY - component relative position Y
        overflowMode - overflow mode
        Returns:
        closest caret position
      • computeMovePosition

        @Nonnull
        public org.exbin.bined.CodeAreaCaretPosition computeMovePosition​(org.exbin.bined.CodeAreaCaretPosition position,
                                                                         org.exbin.bined.basic.MovementDirection direction)
        Description copied from interface: CodeAreaPainter
        Computes position for movement action.
        Specified by:
        computeMovePosition in interface CodeAreaPainter
        Parameters:
        position - source position
        direction - movement direction
        Returns:
        target position
      • computeScrolling

        @Nonnull
        public org.exbin.bined.basic.CodeAreaScrollPosition computeScrolling​(org.exbin.bined.basic.CodeAreaScrollPosition startPosition,
                                                                             org.exbin.bined.basic.ScrollingDirection direction)
        Description copied from interface: CodeAreaPainter
        Computes scrolling position for given shift action.
        Specified by:
        computeScrolling in interface CodeAreaPainter
        Parameters:
        startPosition - start position
        direction - scrolling direction
        Returns:
        target position
      • getPositionPoint

        @Nullable
        public java.awt.Point getPositionPoint​(long dataPosition,
                                               int codeOffset,
                                               org.exbin.bined.CodeAreaSection section)
        Returns relative cursor position in code area or null if cursor is not visible.
        Parameters:
        dataPosition - data position
        codeOffset - code offset
        section - section
        Returns:
        cursor position or null
      • getMouseCursorShape

        public int getMouseCursorShape​(int positionX,
                                       int positionY)
        Description copied from interface: CodeAreaPainter
        Returns type of cursor for given painter relative position.
        Specified by:
        getMouseCursorShape in interface CodeAreaPainter
        Parameters:
        positionX - component relative position X
        positionY - component relative position Y
        Returns:
        java.awt.Cursor cursor type value
      • getPositionZone

        @Nonnull
        public org.exbin.bined.basic.BasicCodeAreaZone getPositionZone​(int positionX,
                                                                       int positionY)
        Description copied from interface: CodeAreaPainter
        Returns zone type for given position.
        Specified by:
        getPositionZone in interface CodeAreaPainter
        Parameters:
        positionX - x-coordinate
        positionY - y-coordinate
        Returns:
        specific zone in component
      • drawCenteredChars

        protected void drawCenteredChars​(java.awt.Graphics g,
                                         char[] drawnChars,
                                         int charOffset,
                                         int length,
                                         int cellWidth,
                                         int positionX,
                                         int positionY)
        Draws characters centering it to cells of the same width.
        Parameters:
        g - graphics
        drawnChars - array of chars
        charOffset - index of target character in array
        length - number of characters to draw
        cellWidth - width of cell to center into
        positionX - X position of drawing area start
        positionY - Y position of drawing area start
      • drawShiftedChars

        protected void drawShiftedChars​(java.awt.Graphics g,
                                        char[] drawnChars,
                                        int charOffset,
                                        int length,
                                        int positionX,
                                        int positionY)
      • getCursorPositionRect

        @Nonnull
        public java.awt.Rectangle getCursorPositionRect​(long dataPosition,
                                                        int codeOffset,
                                                        org.exbin.bined.CodeAreaSection section)
        Returns cursor rectangle.
        Parameters:
        dataPosition - data position
        codeOffset - code offset
        section - section
        Returns:
        cursor rectangle or empty rectangle
      • updateRectToCursorPosition

        protected void updateRectToCursorPosition​(java.awt.Rectangle rect,
                                                  long dataPosition,
                                                  int codeOffset,
                                                  org.exbin.bined.CodeAreaSection section)
      • updateScrollBars

        public void updateScrollBars()
        Description copied from interface: CodeAreaPainter
        Performs update of scrollbars after change in data size or position.
        Specified by:
        updateScrollBars in interface CodeAreaPainter
      • scrollPositionModified

        public void scrollPositionModified()
        Description copied from interface: CodeAreaPainter
        Notify scroll position was modified. This is to assist detection of scrolling from outside compare to scrolling by scrollbar controls.
        Specified by:
        scrollPositionModified in interface CodeAreaPainter
      • getCharactersPerRow

        protected int getCharactersPerRow()
      • getBytesPerRow

        public int getBytesPerRow()
      • getRowHeight

        public int getRowHeight()