public interface BlockRenderer
BlockRenderer
interface describes the routines
needed for rendering a block or region of text from a document.
The rendering process generates a set of styled fragments which can
be used for painting or printing a document.
The given block or region should be in a language (such as Java)
which the given BlockRenderer
implementation can
render. For example, a JavaBlockRenderer
implementation
should be able to render a chunk of Java code.
Note that a given BlockRenderer
implementation may
delegate further sub-blocks of text to other BlockRenderer
implementations. For example, a JavaBlockRenderer
implementation may delegate the rendering of a chunk of SQLJ code
to a SQLJBlockRenderer
implementation. This allows
us the flexibility to combine multiple BlockRenderers
to support multiplex languages, such as JSP documents.
It is expected that implementations of this interface will be called
only for the purposes of painting or printing. As such, it is up to
the caller (such as BasicView
) to handle proper document
locking. There is no requirement for BlockRenderer
implementations to handle document locking.
When syntax highlighting styles change, any
DocumentRenderers
in use will be notified to reload
their styles through reloadStyles()
. It is the
responsibility of the DocumentRenderers
to notify
their block renderers in turn to reload their styles (if
necessary.)
Lastly, since BlockRenderer
implementations are used
primarily for rendering, they are not allowed to make modifications
to the underlying document.
DocumentRenderer
Modifier and Type | Method and Description |
---|---|
void |
renderBlock(StyledFragmentsList fragmentsList,
int blockStartOffset,
int blockEndOffset,
int clipStartOffset,
int clipEndOffset)
Renders the region of text bounded by the given offsets.
|
void renderBlock(StyledFragmentsList fragmentsList, int blockStartOffset, int blockEndOffset, int clipStartOffset, int clipEndOffset)
blockStartOffset
to
blockEndOffset
) marks the start and end of the
block for the given language. This can be used for example to
set the starting position of a language-specific Lexer
.
The second set, clipStartOffset
to
clipEndOffset
marks the clip region within which the
block should be rendered. Implementations must not add fragments
to the fragments list outside the range of these clip offsets,
otherwise, an internal exception will occur (this is different
from the clip bounds for graphics areas.)
fragmentsList
- the fragments list which rendered fragments
should be appended toblockStartOffset
- the starting offset of the language blockblockEndOffset
- the ending offset of the language blockclipStartOffset
- the starting offset of the region to renderclipEndOffset
- the ending offset of the region to render