Eclipse Platform
2.0

org.eclipse.jface.text
Class TextPresentation

java.lang.Object
  |
  +--org.eclipse.jface.text.TextPresentation

public class TextPresentation
extends Object

Describes the presentation styles for a section of an indexed text such as a document or string. A text presentation defines a default style for the whole section and in addition style differences for individual subsections. Text presentations can be narrowed down to a particular result window. All methods are result window aware, i.e. ranges outside the result window are always ignored.

All iterators provided by a text presentation assume that they enumerate non overlapping, consequtive ranges inside the default range. Thus, all these iterators do not include the default range. The default style range must be explicitly asked for using getDefaultStyleRange.


Constructor Summary
TextPresentation()
          Creates a new empty text presentation.
 
Method Summary
 void addStyleRange(StyleRange range)
          Add the given range to the presentation.
static void applyTextPresentation(TextPresentation presentation, StyledText text)
          Applies the given presentation to the given text widget.
 void clear()
          Clears this presentation by resetting all applied changes.
 Iterator getAllStyleRangeIterator()
          Returns an iterator which enumerates all style ranges of this presentation except the default style range.
 IRegion getCoverage()
          Returns the coverage of this presentation as clipped by the presentation's result window.
 StyleRange getDefaultStyleRange()
          Returns this presentation's default style range.
 int getDenumerableRanges()
          Returns the number of style ranges in the presentation not counting the default style range.
 StyleRange getFirstStyleRange()
          Returns the style range with the smallest offset ignoring the default style range or null if the presentation is empty.
 StyleRange getLastStyleRange()
          Returns the style range with the highest offset ignoring the default style range.
 Iterator getNonDefaultStyleRangeIterator()
          Returns an iterator which enumerates all style ranged which define a style different from the presentation's default style range.
 boolean isEmpty()
          Returns whether this collection contains any style range including the default style range.
 void setDefaultStyleRange(StyleRange range)
          Set the default style range of this presentation.
 void setResultWindow(IRegion resultWindow)
          Sets the result window for this presentation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextPresentation

public TextPresentation()
Creates a new empty text presentation.

Method Detail

applyTextPresentation

public static void applyTextPresentation(TextPresentation presentation,
                                         StyledText text)
Applies the given presentation to the given text widget. Helper method.

Parameters:
presentation - the style information
Since:
2.0

setResultWindow

public void setResultWindow(IRegion resultWindow)
Sets the result window for this presentation. When dealing with this presentation all ranges which are outside the result window are ignored. For example, the size of the presentation is 0 when there is no range inside the window even if there are ranges outside the window. All methods are aware of the result window.

Parameters:
resultWindow - the result window

setDefaultStyleRange

public void setDefaultStyleRange(StyleRange range)
Set the default style range of this presentation. The default style range defines the overall area covered by this presentation and its style information.

Parameters:
range - the range decribing the default region

getDefaultStyleRange

public StyleRange getDefaultStyleRange()
Returns this presentation's default style range. The returned StyleRange is relative to the start of the result window.

Returns:
this presentation's default style range

addStyleRange

public void addStyleRange(StyleRange range)
Add the given range to the presentation. The range must be a subrange of the presentation's default range.

Parameters:
range - the range to be added

getNonDefaultStyleRangeIterator

public Iterator getNonDefaultStyleRangeIterator()
Returns an iterator which enumerates all style ranged which define a style different from the presentation's default style range. The default style range is not enumerated.

Returns:
a style range interator

getAllStyleRangeIterator

public Iterator getAllStyleRangeIterator()
Returns an iterator which enumerates all style ranges of this presentation except the default style range. The returned StyleRanges are relative to the start of the presentation's result window.

Returns:
a style range iterator

isEmpty

public boolean isEmpty()
Returns whether this collection contains any style range including the default style range.

Returns:
true if there is no style range in this presentation

getDenumerableRanges

public int getDenumerableRanges()
Returns the number of style ranges in the presentation not counting the default style range.

Returns:
the number of style ranges in the presentation excluding the default style range

getFirstStyleRange

public StyleRange getFirstStyleRange()
Returns the style range with the smallest offset ignoring the default style range or null if the presentation is empty.

Returns:
the style range with the smalled offset different from the default style range

getLastStyleRange

public StyleRange getLastStyleRange()
Returns the style range with the highest offset ignoring the default style range.

Returns:
the style range with the highest offset different from the default style range

getCoverage

public IRegion getCoverage()
Returns the coverage of this presentation as clipped by the presentation's result window.

Returns:
the coverage of this presentation

clear

public void clear()
Clears this presentation by resetting all applied changes.

Since:
2.0

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.