Extension SDK

oracle.javatools.editor.highlight
Class HighlightedFragmentsList

java.lang.Object
  extended byoracle.javatools.editor.highlight.HighlightedFragmentsList

public final class HighlightedFragmentsList
extends java.lang.Object

A HighlightedFragmentsList is just a list of HighlightedFragments that we can re-use without having to constantly reallocate arrays and HighlightedFragment objects. This class is similar to the StyledFragmentsList class except that it applies to HighlightedFragments.

Since this fragments list is typically used for rendering text highlights, it will take care of resolving priority levels of highlights as they are added to the list. This means highlights can be added to the list out of order (both in terms of offsets as well as priority levels), relieving the view and renderers from the responsibility of having to manually sort through the highlights.

Note, unlike the StyledFragmentsList, fragments added to this list are not required to be adjacent regions of text.


Constructor Summary
HighlightedFragmentsList()
          Constructs a new HighlightedFragmentList with an initial size of the default.
 
Method Summary
 void add(HighlightStyle highlightStyle, int startOffset, int endOffset)
          Adds the given fragment to the list, accounting for priority and offsets so that the list is always sorted in increasing offsets with higher priority highlights displacing lower priority ones.
 void addSentinel(HighlightStyle highlightStyle)
          Adds a final sentinel fragment.
 void clear()
          Discards all fragments from the list.
 HighlightedFragment get(int index)
          Get the fragment at the specified index.
 HighlightStyle getSentinel()
          Fetch the final sentinel style if any.
 void setHighlightRegistry(HighlightRegistry registry)
          Set the HighlightRegistry used by this list when building up its list of highlight fragments.
 int size()
          Returns the size of the list (number of fragments.)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighlightedFragmentsList

public HighlightedFragmentsList()
Constructs a new HighlightedFragmentList with an initial size of the default.

Method Detail

setHighlightRegistry

public void setHighlightRegistry(HighlightRegistry registry)
Set the HighlightRegistry used by this list when building up its list of highlight fragments.


addSentinel

public void addSentinel(HighlightStyle highlightStyle)
Adds a final sentinel fragment.

Parameters:
highlightStyle - the highlight style

getSentinel

public HighlightStyle getSentinel()
Fetch the final sentinel style if any.

Returns:
the final sentinel style

add

public void add(HighlightStyle highlightStyle,
                int startOffset,
                int endOffset)
Adds the given fragment to the list, accounting for priority and offsets so that the list is always sorted in increasing offsets with higher priority highlights displacing lower priority ones.

Parameters:
highlightStyle - the highlight style
startOffset - the starting offset of the highlight
endOffset - the ending offset of the highlight

clear

public void clear()
Discards all fragments from the list.


size

public int size()
Returns the size of the list (number of fragments.)

Returns:
the size of the list

get

public HighlightedFragment get(int index)
Get the fragment at the specified index.

Parameters:
index - the index of the fragment to retrieve
Returns:
the fragment at the given index.

Extension SDK

 

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