站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

AbstractHighlightsContainer (Editor Library 2) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib2/1 1.3 2

org.netbeans.spi.editor.highlighting.support
Class AbstractHighlightsContainer

java.lang.Object
  extended by org.netbeans.spi.editor.highlighting.support.AbstractHighlightsContainer
All Implemented Interfaces:
HighlightsContainer
Direct Known Subclasses:
OffsetsBag, PositionsBag

public abstract class AbstractHighlightsContainer
extends Object
implements HighlightsContainer

The default implementation of the HighlightsContainer interface. It provides standard implementation of the methods for adding and removing HighlightsChangeListeners and allows subclasses to notify listeners by calling the fireHighlightsChange method.


Field Summary
 
Fields inherited from interface org.netbeans.spi.editor.highlighting.HighlightsContainer
ATTR_EXTENDS_EMPTY_LINE, ATTR_EXTENDS_EOL
 
Constructor Summary
protected AbstractHighlightsContainer()
          Creates a new instance of AbstractHighlightsContainer
 
Method Summary
 void addHighlightsChangeListener(HighlightsChangeListener listener)
          Adds HighlightsChangeListener to this container.
protected  void fireHighlightsChange(int changeStartOffset, int changeEndOffset)
          Notifies all registered listeners about a change in this container.
abstract  HighlightsSequence getHighlights(int startOffset, int endOffset)
          Provides the list of highlighted areas that should be used for rendering a document.
 void removeHighlightsChangeListener(HighlightsChangeListener listener)
          Removes HighlightsChangeListener to this container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHighlightsContainer

protected AbstractHighlightsContainer()
Creates a new instance of AbstractHighlightsContainer

Method Detail

getHighlights

public abstract HighlightsSequence getHighlights(int startOffset,
                                                 int endOffset)
Description copied from interface: HighlightsContainer
Provides the list of highlighted areas that should be used for rendering a document.

The returned highlighted areas (highlights) must obey the following rules:

  • The starting and ending offsets of each highlight should be within the range specified by the startOffset and endOffset parameters. Any highlights outside of this range will be clipped by the rendering infrastructure.
  • The highlights must not overlap. The infrastructure may ignore or trim any overlapping highlights.
  • The list of highlights must be sorted by their starting offsets ascendingly (i.e. the smallest offset first).

The editor infrastructure will log any problems it may encounter with provided implementations of this interface. Although the infrastructure will try to do its best to render all highlights supplied by the implementors, if the above rules are violated the results can't be garanteed.

Specified by:
getHighlights in interface HighlightsContainer
Parameters:
startOffset - The starting offset of the area which the caller attempts to repaint (or create views for). The staring offset is always >=0.
endOffset - The ending offset of the rendered area. The Integer.MAX_VALUE can be passed in if the end offset is unknown to the caller. The highlights container is then expected to return all highlights up to the end of the document.
Returns:
non-null iterator of highlights sorted by offsets.

addHighlightsChangeListener

public final void addHighlightsChangeListener(HighlightsChangeListener listener)
Adds HighlightsChangeListener to this container.

Specified by:
addHighlightsChangeListener in interface HighlightsContainer
Parameters:
listener - The listener to add.

removeHighlightsChangeListener

public final void removeHighlightsChangeListener(HighlightsChangeListener listener)
Removes HighlightsChangeListener to this container.

Specified by:
removeHighlightsChangeListener in interface HighlightsContainer
Parameters:
listener - The listener to remove.

fireHighlightsChange

protected final void fireHighlightsChange(int changeStartOffset,
                                          int changeEndOffset)
Notifies all registered listeners about a change in this container. The area of a document where highlights changed is specified by the changeStartOffset and changeEndOffset parameters.

Parameters:
changeStartOffset - The starting offset of the changed area.
changeEndOffset - The ending offset of the changed area.

org.netbeans.modules.editor.lib2/1 1.3 2

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.