Interface DecompilerMarginProvider
- All Known Implementing Classes:
LineNumberDecompilerMarginProvider
To add a margin to the decompiler, a client must implement this interface to provide the
component that is actually added to the UI. For a reference implementation, see
LineNumberDecompilerMarginProvider
.
-
Method Summary
Modifier and TypeMethodDescriptionGet the Swing component implementing the actual margin, oftenthis
default void
setOptions
(DecompileOptions options) Set the options for the marginvoid
setProgram
(Program program, LayoutModel model, LayoutPixelIndexMap pixmap) Called whenever the program, function, or layout changes
-
Method Details
-
setProgram
Called whenever the program, function, or layout changesThe implementation should keep a reference at least to the
model
and thepixmap
for later use during painting. The model provides access to the lines of decompiler C code. Each layout corresponds to a single line of C code. For example, the first line of code is rendered by the layout at index 0. The tenth is rendered by the layout at index 9. Rarely, a line may be wrapped by the renderer, leading to a non-uniform layout. Thepixmap
can map from a pixel's vertical position to the layout index at the same position in the main panel. It accounts for scrolling an non-uniformity. It is safe to assume the layouts render contiguous lines of C code. The recommended strategy for painting is thus:- Compute the visible part of the margin needing repainting. See
JComponent.getVisibleRect()
- Compute the layout indices for the vertical bounds of that part. See
LayoutPixelIndexMap.getIndex(int)
- Iterate over the layouts within those bounds, inclusively.
- Compute the vertical position of each layout and paint something appropriate for its
corresponding line. See
LayoutPixelIndexMap.getPixel(BigInteger)
A call to this method should cause the component to be repainted.
- Parameters:
program
- the program for the current functionmodel
- the line/token modelpixmap
- a map from pixels' y coordinates to layout index, i.e, line number
- Compute the visible part of the margin needing repainting. See
-
getComponent
Component getComponent()Get the Swing component implementing the actual margin, oftenthis
- Returns:
- the component
-
setOptions
Set the options for the marginThis is called at least once when the provider is added to the margin service. See
DecompilerMarginService.addMarginProvider(DecompilerMarginProvider)
. It subsequently called whenever a decompiler option changes. To receive other options, the provider will need to listen using its own mechanism.A call to this method should cause the component to be repainted. Implementors may choose to repaint only when certain options change.
-