Eclipse Platform
Release 3.3

org.eclipse.jface.text
Class JFaceTextUtil

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

public final class JFaceTextUtil
extends Object

A collection of JFace Text functions.

This class is neither intended to be instantiated nor instantiated.

Since:
3.3

Method Summary
static int computeLineHeight(StyledText textWidget, int startLine, int endLine, int lineCount)
          Computes the line height for the given line range.
static int getBottomIndex(StyledText widget)
          Returns the last fully visible line of the widget.
static int getHiddenTopLinePixels(StyledText textWidget)
          Returns the number of hidden pixels of the first partially visible line.
static int getLineIndex(StyledText textWidget, int y)
           
static int getLinePixel(StyledText textWidget, int line)
           
static int getPartialBottomIndex(ITextViewer viewer)
          Returns the last, possibly partially, visible line in the view port.
static int getPartialBottomIndex(StyledText widget)
          Returns the index of the last (possibly only partially) visible line of the widget
static int getPartialTopIndex(ITextViewer viewer)
          Returns the line index of the first visible model line in the viewer.
static int getPartialTopIndex(StyledText widget)
          Returns the index of the first (possibly only partially) visible line of the widget
static ILineRange getVisibleModelLines(ITextViewer viewer)
          Returns the range of lines that is visible in the viewer, including any partially visible lines.
static boolean isShowingEntireContents(StyledText widget)
          Returns true if the widget displays the entire contents, i.e. it cannot be vertically scrolled.
static int modelLineToWidgetLine(ITextViewer viewer, int modelLine)
          Converts a model (i.e.
static int widgetLine2ModelLine(ITextViewer viewer, int widgetLine)
          Converts a widget line into a model (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

computeLineHeight

public static int computeLineHeight(StyledText textWidget,
                                    int startLine,
                                    int endLine,
                                    int lineCount)
Computes the line height for the given line range.

Parameters:
textWidget - the StyledText widget
startLine - the start line
endLine - the end line (exclusive)
lineCount - the line count used by the old API
Returns:
the height of all lines starting with startLine and ending above endLime

getBottomIndex

public static int getBottomIndex(StyledText widget)
Returns the last fully visible line of the widget. The exact semantics of "last fully visible line" are:

Parameters:
widget - the widget
Returns:
the last fully visible line

getPartialTopIndex

public static int getPartialTopIndex(StyledText widget)
Returns the index of the first (possibly only partially) visible line of the widget

Parameters:
widget - the widget
Returns:
the index of the first line of which a pixel is visible

getPartialBottomIndex

public static int getPartialBottomIndex(StyledText widget)
Returns the index of the last (possibly only partially) visible line of the widget

Parameters:
widget - the text widget
Returns:
the index of the last line of which a pixel is visible

getPartialTopIndex

public static int getPartialTopIndex(ITextViewer viewer)
Returns the line index of the first visible model line in the viewer. The line may be only partially visible.

Parameters:
viewer - the text viewer
Returns:
the first line of which a pixel is visible, or -1 for no line

getPartialBottomIndex

public static int getPartialBottomIndex(ITextViewer viewer)
Returns the last, possibly partially, visible line in the view port.

Parameters:
viewer - the text viewer
Returns:
the last, possibly partially, visible line in the view port

getVisibleModelLines

public static ILineRange getVisibleModelLines(ITextViewer viewer)
Returns the range of lines that is visible in the viewer, including any partially visible lines.

Parameters:
viewer - the viewer
Returns:
the range of lines that is visible in the viewer, null if no lines are visible

widgetLine2ModelLine

public static int widgetLine2ModelLine(ITextViewer viewer,
                                       int widgetLine)
Converts a widget line into a model (i.e. IDocument) line using the ITextViewerExtension5 if available, otherwise by adapting the widget line to the viewer's visible region.

Parameters:
viewer - the viewer
widgetLine - the widget line to convert.
Returns:
the model line corresponding to widgetLine or -1 to signal that there is no corresponding model line

modelLineToWidgetLine

public static int modelLineToWidgetLine(ITextViewer viewer,
                                        int modelLine)
Converts a model (i.e. IDocument) line into a widget line using the ITextViewerExtension5 if available, otherwise by adapting the model line to the viewer's visible region.

Parameters:
viewer - the viewer
modelLine - the model line to convert.
Returns:
the widget line corresponding to modelLine or -1 to signal that there is no corresponding widget line

getHiddenTopLinePixels

public static int getHiddenTopLinePixels(StyledText textWidget)
Returns the number of hidden pixels of the first partially visible line. If there is no partially visible line, zero is returned.

Parameters:
textWidget - the widget
Returns:
the number of hidden pixels of the first partial line, always >= 0

getLinePixel

public static int getLinePixel(StyledText textWidget,
                               int line)

getLineIndex

public static int getLineIndex(StyledText textWidget,
                               int y)

isShowingEntireContents

public static boolean isShowingEntireContents(StyledText widget)
Returns true if the widget displays the entire contents, i.e. it cannot be vertically scrolled.

Parameters:
widget - the widget
Returns:
true if the widget displays the entire contents, i.e. it cannot be vertically scrolled, false otherwise

Eclipse Platform
Release 3.3

Guidelines for using Eclipse APIs.

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