Package org.exbin.bined.swing
Interface CodeAreaPainter
-
- All Known Implementing Classes:
DefaultCodeAreaPainter
@ParametersAreNonnullByDefault public interface CodeAreaPainter
Binary editor painter interface.
-
-
Method Summary
All Methods Instance Methods Abstract 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.int
getMouseCursorShape(int positionX, int positionY)
Returns type of cursor for given painter relative position.org.exbin.bined.basic.BasicCodeAreaZone
getPositionZone(int x, int y)
Returns zone type for given position.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
paintComponent(java.awt.Graphics g)
Paints the main component.void
paintCursor(java.awt.Graphics g)
Paints cursor symbol.void
paintMainArea(java.awt.Graphics g)
Paints main data section of the component.void
rebuildColors()
Calls rebuild of the colors profile.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
updateScrollBars()
Performs update of scrollbars after change in data size or position.
-
-
-
Method Detail
-
isInitialized
boolean isInitialized()
Returns true if painter was initialized.- Returns:
- true if initialized
-
attach
void attach()
Attaches painter to code area.
-
detach
void detach()
Detaches painter to code area.
-
paintComponent
void paintComponent(java.awt.Graphics g)
Paints the main component.- Parameters:
g
- graphics
-
paintMainArea
void paintMainArea(java.awt.Graphics g)
Paints main data section of the component.- Parameters:
g
- graphics
-
paintCursor
void paintCursor(java.awt.Graphics g)
Paints cursor symbol.- Parameters:
g
- graphics
-
reset
void reset()
Resets complete painter state for new painting.
-
resetFont
void resetFont()
Resets painter font state for new painting.
-
resetColors
void resetColors()
Rebuilds colors after UIManager change.
-
resetLayout
void resetLayout()
Updates painter layout state for new painting.
-
resetCaret
void resetCaret()
Resets caret state.
-
rebuildColors
void rebuildColors()
Calls rebuild of the colors profile.
-
getMouseCursorShape
int getMouseCursorShape(int positionX, int positionY)
Returns type of cursor for given painter relative position.- Parameters:
positionX
- component relative position XpositionY
- component relative position Y- Returns:
- java.awt.Cursor cursor type value
-
getPositionZone
@Nonnull org.exbin.bined.basic.BasicCodeAreaZone getPositionZone(int x, int y)
Returns zone type for given position.- Parameters:
x
- x-coordinatey
- y-coordinate- Returns:
- specific zone in component
-
mousePositionToClosestCaretPosition
@Nonnull org.exbin.bined.CodeAreaCaretPosition mousePositionToClosestCaretPosition(int positionX, int positionY, org.exbin.bined.CaretOverlapMode overflowMode)
Returns closest caret position for provided component relative mouse position.- Parameters:
positionX
- component relative position XpositionY
- component relative position YoverflowMode
- overflow mode- Returns:
- closest caret position
-
updateScrollBars
void updateScrollBars()
Performs update of scrollbars after change in data size or position.
-
computePositionScrollVisibility
@Nonnull org.exbin.bined.basic.PositionScrollVisibility computePositionScrollVisibility(org.exbin.bined.CodeAreaCaretPosition caretPosition)
Returns state of the visibility of given caret position within current scrolling window.- Parameters:
caretPosition
- caret position- Returns:
- visibility state
-
computeRevealScrollPosition
@Nonnull 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. 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.- Parameters:
caretPosition
- caret position- Returns:
- scroll position or null if caret position is already visible / scrolled to the best fit
-
computeCenterOnScrollPosition
@Nonnull 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. Attempts to center as much as possible while preserving scrolling limits.- Parameters:
caretPosition
- caret position- Returns:
- scroll position or null if desired scroll position is the same as current scroll position.
-
computeMovePosition
@Nonnull org.exbin.bined.CodeAreaCaretPosition computeMovePosition(org.exbin.bined.CodeAreaCaretPosition position, org.exbin.bined.basic.MovementDirection direction)
Computes position for movement action.- Parameters:
position
- source positiondirection
- movement direction- Returns:
- target position
-
computeScrolling
@Nonnull 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.- Parameters:
startPosition
- start positiondirection
- scrolling direction- Returns:
- target position
-
scrollPositionModified
void scrollPositionModified()
Notify scroll position was modified. This is to assist detection of scrolling from outside compare to scrolling by scrollbar controls.
-
scrollPositionChanged
void scrollPositionChanged()
Notify scroll position was changed outside of scrolling.
-
-