Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jface.text
Class TextPresentation  view TextPresentation download TextPresentation.java

java.lang.Object
  extended byorg.eclipse.jface.text.TextPresentation

public class TextPresentation
extends java.lang.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.


Nested Class Summary
(package private)  class TextPresentation.FilterIterator
          Enumerates all the StyleRanges included in the presentation.
 
Field Summary
private  org.eclipse.swt.custom.StyleRange fDefaultRange
          The style information for the range covered by the whole presentation
private  IRegion fExtent
          The optional extent for this presentation.
private  java.util.ArrayList fRanges
          The member ranges of the presentation
private  IRegion fResultWindow
          A clipping region against which the presentation can be clipped when asked for results
 
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(org.eclipse.swt.custom.StyleRange range)
          Add the given range to the presentation.
private  void applyStyle(org.eclipse.swt.custom.StyleRange template, org.eclipse.swt.custom.StyleRange target, boolean merge)
          Applies the template's style to the target.
private  void applyStyleRange(org.eclipse.swt.custom.StyleRange range, boolean merge)
          Applies the given range to this presentation.
private  void applyStyleRanges(org.eclipse.swt.custom.StyleRange[] ranges, boolean merge)
          Applies the given ranges to this presentation.
static void applyTextPresentation(TextPresentation presentation, org.eclipse.swt.custom.StyledText text)
          Applies the given presentation to the given text widget.
private  void checkConsistency(org.eclipse.swt.custom.StyleRange range)
          Checks whether the given range is a subrange of the presentation's default style range.
 void clear()
          Clears this presentation by resetting all applied changes.
private  org.eclipse.swt.custom.StyleRange createWindowRelativeRange(IRegion window, org.eclipse.swt.custom.StyleRange range)
          Returns a style range which is relative to the specified window and appropriately clipped if necessary.
private  IRegion createWindowRelativeRegion(IRegion coverage)
          Returns the region which is relative to the specified window and appropriately clipped if necessary.
 java.util.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.
 org.eclipse.swt.custom.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.
private  int getFirstIndexAfterWindow(IRegion window)
          Returns the index of the first range which comes after the specified window and does not overlap with this window.
private  int getFirstIndexInWindow(IRegion window)
          Returns the index of the first range which overlaps with the specified window.
 org.eclipse.swt.custom.StyleRange getFirstStyleRange()
          Returns the style range with the smallest offset ignoring the default style range or null if the presentation is empty.
 org.eclipse.swt.custom.StyleRange getLastStyleRange()
          Returns the style range with the highest offset ignoring the default style range.
 java.util.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(org.eclipse.swt.custom.StyleRange range)
          Merges the given range into this presentation.
 void mergeStyleRanges(org.eclipse.swt.custom.StyleRange[] ranges)
          Merges the given ranges into this presentation.
 void replaceStyleRange(org.eclipse.swt.custom.StyleRange range)
          Replaces the given range in this presentation.
 void replaceStyleRanges(org.eclipse.swt.custom.StyleRange[] ranges)
          Replaces the given ranges in this presentation.
 void setDefaultStyleRange(org.eclipse.swt.custom.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
 

Field Detail

fDefaultRange

private org.eclipse.swt.custom.StyleRange fDefaultRange
The style information for the range covered by the whole presentation


fRanges

private java.util.ArrayList fRanges
The member ranges of the presentation


fResultWindow

private IRegion fResultWindow
A clipping region against which the presentation can be clipped when asked for results


fExtent

private IRegion fExtent
The optional extent for this presentation.

Since:
3.0
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.


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.

Since:
3.0
Method Detail

applyTextPresentation

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

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.


setDefaultStyleRange

public void setDefaultStyleRange(org.eclipse.swt.custom.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.


getDefaultStyleRange

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


addStyleRange

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


replaceStyleRange

public void replaceStyleRange(org.eclipse.swt.custom.StyleRange range)
Replaces the given range in this presentation. The range must be a subrange of the presentation's default range.

Since:
3.0

mergeStyleRange

public void mergeStyleRange(org.eclipse.swt.custom.StyleRange range)
Merges the given range into this presentation. The range must be a subrange of the presentation's default range.

Since:
3.0

applyStyleRange

private void applyStyleRange(org.eclipse.swt.custom.StyleRange range,
                             boolean merge)
Applies the given range to this presentation. The range must be a subrange of the presentation's default range.

Since:
3.0

replaceStyleRanges

public void replaceStyleRanges(org.eclipse.swt.custom.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).

Since:
3.0

mergeStyleRanges

public void mergeStyleRanges(org.eclipse.swt.custom.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).

Since:
3.0

applyStyleRanges

private void applyStyleRanges(org.eclipse.swt.custom.StyleRange[] ranges,
                              boolean merge)
Applies the given ranges to 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).

Since:
3.0

applyStyle

private void applyStyle(org.eclipse.swt.custom.StyleRange template,
                        org.eclipse.swt.custom.StyleRange target,
                        boolean merge)
Applies the template's style to the target.

Since:
3.0

checkConsistency

private void checkConsistency(org.eclipse.swt.custom.StyleRange range)
Checks whether the given range is a subrange of the presentation's default style range.


getFirstIndexInWindow

private int getFirstIndexInWindow(IRegion window)
Returns the index of the first range which overlaps with the specified window.


getFirstIndexAfterWindow

private int getFirstIndexAfterWindow(IRegion window)
Returns the index of the first range which comes after the specified window and does not overlap with this window.


createWindowRelativeRange

private org.eclipse.swt.custom.StyleRange createWindowRelativeRange(IRegion window,
                                                                    org.eclipse.swt.custom.StyleRange range)
Returns a style range which is relative to the specified window and appropriately clipped if necessary. The original style range is not modified.


createWindowRelativeRegion

private IRegion createWindowRelativeRegion(IRegion coverage)
Returns the region which is relative to the specified window and appropriately clipped if necessary.

Since:
3.0

getNonDefaultStyleRangeIterator

public java.util.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.


getAllStyleRangeIterator

public java.util.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.


isEmpty

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


getDenumerableRanges

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


getFirstStyleRange

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


getLastStyleRange

public org.eclipse.swt.custom.StyleRange getLastStyleRange()
Returns the style range with the highest offset ignoring the default style range.


getCoverage

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


getExtent

public IRegion getExtent()
Returns the extent of this presentation clipped by the presentation's result window.

Since:
3.0

clear

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

Since:
2.0