Extension SDK 10.1.2

oracle.javatools.editor.language
Class AbstractDocumentRenderer

java.lang.Object
  extended byoracle.javatools.editor.language.AbstractDocumentRenderer
All Implemented Interfaces:
DocumentRenderer
Direct Known Subclasses:
LexerDocumentRenderer

public abstract class AbstractDocumentRenderer
extends java.lang.Object
implements DocumentRenderer

An AbstractDocumentRenderer is the base class for all DocumentRenderers provided with this editor component. It takes care of implementing common functionality.

See Also:
DocumentRenderer

Constructor Summary
AbstractDocumentRenderer(LanguageSupport support)
          Constructs a new style provider for the specified document.
 
Method Summary
protected  StyledFragmentsList allocateFragmentsList()
          Routine available to DocumentRenderer implementations to allocate a fragments list (for reuse) which is not in use.
 void calculateDamage(javax.swing.event.DocumentEvent changes, NumberRange damageRange)
          Calculates what range of the document is "damaged" or needs to be repainted based on a given insert or removal of text.
 BasicDocument getDocument()
          Convenience method for fetching the document associated with this provider.
 LineMap getLineMap()
          Convenience method for fetching the linemap of the document.
 TextBuffer getTextBuffer()
          Convenience method for fetching the text buffer associated with this provider.
 void notifyUpdate(javax.swing.event.DocumentEvent changes)
          Notifies the DocumentRenderer that the given document has been updated - this allows DocumentRenderers which cache offset information to update or invalidate their cache.
 void recycleFragmentsList(StyledFragmentsList fragmentsList)
          Recycle the previously gotten StyledFragment's to reduce memory allocations.
 StyledFragmentsList renderLines(int startLine, int endLine)
          Renders a region of text based on the line information provided.
abstract  void renderRegion(StyledFragmentsList fragmentsList, int startOffset, int endOffset)
          Renders the region of text bounded by the given offsets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDocumentRenderer

public AbstractDocumentRenderer(LanguageSupport support)
Constructs a new style provider for the specified document.

Parameters:
support - the language support
Method Detail

getDocument

public final BasicDocument getDocument()
Convenience method for fetching the document associated with this provider.

Returns:
the document for this provider

getTextBuffer

public final TextBuffer getTextBuffer()
Convenience method for fetching the text buffer associated with this provider.

Returns:
the text buffer for this provider

getLineMap

public final LineMap getLineMap()
Convenience method for fetching the linemap of the document.

Returns:
the linemap for document

renderLines

public StyledFragmentsList renderLines(int startLine,
                                       int endLine)
Renders a region of text based on the line information provided. The startLine and endLine are both inclusive, for example, with startLine of 1 and endLine of 5, renderLines will render 5 lines.

Specified by:
renderLines in interface DocumentRenderer
Parameters:
startLine - the line to start rendering from (inclusive)
endLine - the last line to render (inclusive)
Returns:
StyledFragmentsList for rendering the given region

renderRegion

public abstract void renderRegion(StyledFragmentsList fragmentsList,
                                  int startOffset,
                                  int endOffset)
Renders the region of text bounded by the given offsets. The styles generated should be added (appended) to the provided fragments list.

Parameters:
fragmentsList - the styled fragments list to added our styles to
startOffset - the starting offset to render from (inclusive)
endOffset - the ending offset to render to (exclusive)

calculateDamage

public void calculateDamage(javax.swing.event.DocumentEvent changes,
                            NumberRange damageRange)
Calculates what range of the document is "damaged" or needs to be repainted based on a given insert or removal of text. As with renderLines(), starting and ending offsets returned via damageRange are both inclusive. (This is different from endingOffsets, which are generally exclusive.) This is called only when the insert or removal does not change the line count (which would change the size of the text component and force a full repaint.)

Specified by:
calculateDamage in interface DocumentRenderer
Parameters:
changes - the document event indicating what changed
damageRange - the number range to return the damage range in

notifyUpdate

public void notifyUpdate(javax.swing.event.DocumentEvent changes)
Notifies the DocumentRenderer that the given document has been updated - this allows DocumentRenderers which cache offset information to update or invalidate their cache.

Specified by:
notifyUpdate in interface DocumentRenderer
Parameters:
changes - the document event indicating what changed

recycleFragmentsList

public final void recycleFragmentsList(StyledFragmentsList fragmentsList)
Recycle the previously gotten StyledFragment's to reduce memory allocations.

Specified by:
recycleFragmentsList in interface DocumentRenderer

allocateFragmentsList

protected final StyledFragmentsList allocateFragmentsList()
Routine available to DocumentRenderer implementations to allocate a fragments list (for reuse) which is not in use. One is created if necessary

Returns:
a fragments list for rendering

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.