Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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, consecutive 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.
`TextPresentation(int sizeHint)` Creates a new empty text presentation.
`TextPresentation(IRegion extent, int sizeHint)` Creates a new empty text presentation with the given extent.

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.
`IRegion` | `getExtent()` Returns the extent of this presentation clipped by the presentation's result window.
`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` | `mergeStyleRange(StyleRange range)` Merges the given range into this presentation.
`void` | `mergeStyleRanges(StyleRange[] ranges)` Merges the given ranges into this presentation.
`void` | `replaceStyleRange(StyleRange range)` Replaces the given range in this presentation.
`void` | `replaceStyleRanges(StyleRange[] ranges)` Replaces the given ranges in this presentation.
`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.

### TextPresentation

    public TextPresentation(int sizeHint)

  Creates a new empty text presentation. `sizeHint` tells the expected size of this presentation.

Parameters:
  `sizeHint` - the expected size of this presentation

### TextPresentation

    public TextPresentation(IRegion extent,
                            int sizeHint)

  Creates a new empty text presentation with the given extent. `sizeHint` tells the expected size of this presentation.

Parameters:
  `extent` - the extent of the created `TextPresentation`
  `sizeHint` - the expected size of this presentation
Since:
  3.0

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
    `text` - the widget to which to apply 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 describing 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

### replaceStyleRange

    public void replaceStyleRange(StyleRange range)

  Replaces the given range in this presentation. The range must be a subrange of the presentation's default range.

  Parameters:
    `range` - the range to be added
  Since:
    3.0

### mergeStyleRange

    public void mergeStyleRange(StyleRange range)

  Merges the given range into this presentation. The range must be a subrange of the presentation's default range.

  Parameters:
    `range` - the range to be added
  Since:
    3.0

### replaceStyleRanges

    public void replaceStyleRanges(StyleRange[] ranges)

  Replaces the given ranges in this presentation. Each range must be a subrange of the presentation's default range. The ranges must be ordered by increasing offset and must not overlap (but may be adjacent).

  Parameters:
    `ranges` - the ranges to be added
  Since:
    3.0

### mergeStyleRanges

    public void mergeStyleRanges(StyleRange[] ranges)

  Merges the given ranges into this presentation. Each range must be a subrange of the presentation's default range. The ranges must be ordered by increasing offset and must not overlap (but may be adjacent).

  Parameters:
    `ranges` - the ranges to be added
  Since:
    3.0

### 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 iterator

### getAllStyleRangeIterator

    public Iterator getAllStyleRangeIterator()

  Returns an iterator which enumerates all style ranges of this presentation except the default style range. The returned `StyleRange`s 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 smallest 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

### getExtent

    public IRegion getExtent()

  Returns the extent of this presentation clipped by the presentation's result window.

  Returns:
    the clipped extent
  Since:
    3.0

### clear

    public void clear()

  Clears this presentation by resetting all applied changes.

  Since:
    2.0

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.