Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.text
Class Utilities

    java.lang.Object
      |
      +--javax.swing.text.Utilities

public class Utilities
extends java.lang.Object

A collection of methods to deal with various text related activities.

Constructor Summary
`Utilities()`

Method Summary
`static int` | `drawTabbedText(Segment s, int x, int y, java.awt.Graphics g, TabExpander e, int startOffset)` Draws the given text, expanding any tabs that are contained using the given tab expansion technique.
`static int` | `getBreakLocation(Segment s, java.awt.FontMetrics metrics, int x0, int x, TabExpander e, int startOffset)` Determine where to break the given text to fit within the the given span.
`static int` | `getNextWord(JTextComponent c, int offs)` Determines the start of the next word for the given location.
`static Element` | `getParagraphElement(JTextComponent c, int offs)` Determines the element to use for a paragraph/line.
`static int` | `getPositionAbove(JTextComponent c, int offs, int x)` Determines the position in the model that is closest to the given view location in the row above.
`static int` | `getPositionBelow(JTextComponent c, int offs, int x)` Determines the position in the model that is closest to the given view location in the row below.
`static int` | `getPreviousWord(JTextComponent c, int offs)` Determine the start of the prev word for the given location.
`static int` | `getRowEnd(JTextComponent c, int offs)` Determines the ending row model position of the row that contains the specified model position.
`static int` | `getRowStart(JTextComponent c, int offs)` Determines the starting row model position of the row that contains the specified model position.
`static int` | `getTabbedTextOffset(Segment s, java.awt.FontMetrics metrics, int x0, int x, TabExpander e, int startOffset)` Determines the relative offset into the given text that best represents the given span in the view coordinate system.
`static int` | `getTabbedTextOffset(Segment s, java.awt.FontMetrics metrics, int x0, int x, TabExpander e, int startOffset, boolean round)`
`static int` | `getTabbedTextWidth(Segment s, java.awt.FontMetrics metrics, int x, TabExpander e, int startOffset)` Determines the width of the given segment of text taking tabs into consideration.
`static int` | `getWordEnd(JTextComponent c, int offs)` Determines the end of a word for the given location.
`static int` | `getWordStart(JTextComponent c, int offs)` Determines the start of a word for the given model location.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Utilities

    public Utilities()

Method Detail

### drawTabbedText

    public static final int drawTabbedText(Segment s,
                                           int x,
                                           int y,
                                           java.awt.Graphics g,
                                           TabExpander e,
                                           int startOffset)

  Draws the given text, expanding any tabs that are contained using the given tab expansion technique. This particular implementation renders in a 1.1 style coordinate system where ints are used and 72dpi is assumed.
  Parameters:
    `s` - the source of the text
    `x` - the X origin >= 0
    `y` - the Y origin >= 0
    `g` - the graphics context
    `e` - how to expand the tabs. If this value is null, tabs will be expanded as a space character.
    `startOffset` - starting offset of the text in the document >= 0

### getTabbedTextWidth

    public static final int getTabbedTextWidth(Segment s,
                                               java.awt.FontMetrics metrics,
                                               int x,
                                               TabExpander e,
                                               int startOffset)

  Determines the width of the given segment of text taking tabs into consideration. This is implemented in a 1.1 style coordinate system where ints are used and 72dpi is assumed.
  Parameters:
    `s` - the source of the text
    `metrics` - the font metrics to use for the calculation
    `x` - the X origin >= 0
    `e` - how to expand the tabs. If this value is null, tabs will be expanded as a space character.
    `startOffset` - starting offset of the text in the document >= 0

### getTabbedTextOffset

    public static final int getTabbedTextOffset(Segment s,
                                                java.awt.FontMetrics metrics,
                                                int x0,
                                                int x,
                                                TabExpander e,
                                                int startOffset)

  Determines the relative offset into the given text that best represents the given span in the view coordinate system. This is implemented in a 1.1 style coordinate system where ints are used and 72dpi is assumed.
  Parameters:
    `s` - the source of the text
    `metrics` - the font metrics to use for the calculation
    `x0` - the starting view location representing the start of the given text >= 0.
    `x` - the target view location to translate to an offset into the text >= 0.
    `e` - how to expand the tabs. If this value is null, tabs will be expanded as a space character.
    `startOffset` - starting offset of the text in the document >= 0

### getTabbedTextOffset

    public static final int getTabbedTextOffset(Segment s,
                                                java.awt.FontMetrics metrics,
                                                int x0,
                                                int x,
                                                TabExpander e,
                                                int startOffset,
                                                boolean round)

### getBreakLocation

    public static final int getBreakLocation(Segment s,
                                             java.awt.FontMetrics metrics,
                                             int x0,
                                             int x,
                                             TabExpander e,
                                             int startOffset)

  Determine where to break the given text to fit within the the given span. This trys to find a whitespace boundry.
  Parameters:
    `s` - the source of the text
    `metrics` - the font metrics to use for the calculation
    `x0` - the starting view location representing the start of the given text.
    `x` - the target view location to translate to an offset into the text.
    `e` - how to expand the tabs. If this value is null, tabs will be expanded as a space character.
    `startOffset` - starting offset in the document of the text

### getRowStart

    public static final int getRowStart(JTextComponent c,
                                        int offs)
                                 throws BadLocationException

  Determines the starting row model position of the row that contains the specified model position. Assumes the row(s) are currently displayed in a view.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
  Returns:
    the position >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getRowEnd

    public static final int getRowEnd(JTextComponent c,
                                      int offs)
                               throws BadLocationException

  Determines the ending row model position of the row that contains the specified model position. Assumes the row(s) are currently displayed in a view.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
  Returns:
    the position >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getPositionAbove

    public static final int getPositionAbove(JTextComponent c,
                                             int offs,
                                             int x)
                                      throws BadLocationException

  Determines the position in the model that is closest to the given view location in the row above.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
    `x` - the X coordinate >= 0
  Returns:
    the model position >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getPositionBelow

    public static final int getPositionBelow(JTextComponent c,
                                             int offs,
                                             int x)
                                      throws BadLocationException

  Determines the position in the model that is closest to the given view location in the row below.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
    `x` - the X coordinate >= 0
  Returns:
    the model position >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getWordStart

    public static final int getWordStart(JTextComponent c,
                                         int offs)
                                  throws BadLocationException

  Determines the start of a word for the given model location. Uses BreakIterator.getWordInstance() to actually get the words.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getWordEnd

    public static final int getWordEnd(JTextComponent c,
                                       int offs)
                                throws BadLocationException

  Determines the end of a word for the given location. Uses BreakIterator.getWordInstance() to actually get the words.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getNextWord

    public static final int getNextWord(JTextComponent c,
                                        int offs)
                                 throws BadLocationException

  Determines the start of the next word for the given location. Uses BreakIterator.getWordInstance() to actually get the words.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getPreviousWord

    public static final int getPreviousWord(JTextComponent c,
                                            int offs)
                                     throws BadLocationException

  Determine the start of the prev word for the given location. Uses BreakIterator.getWordInstance() to actually get the words.
  Parameters:
    `c` - the editor
    `offs` - the offset in the document >= 0
  Throws:
    BadLocationException - if the offset is out of range

### getParagraphElement

    public static final Element getParagraphElement(JTextComponent c,
                                                    int offs)

  Determines the element to use for a paragraph/line.
  Parameters:
    `c` - the editor
    `offs` - the starting offset in the document >= 0
  Returns:
    the element

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.