APIdia Launch Partner
Top Description Constructors Methods
javax.swing.text

public Class Utilities

extends Object
Class Inheritance
Imports
java.awt.Component, .Rectangle, .Graphics, .FontMetrics, .Shape, .Graphics2D, java.awt.font.TextAttribute, java.awt.geom.Rectangle2D, java.text.*, javax.swing.JComponent, .SwingConstants, javax.swing.text.ParagraphView.Row, sun.swing.SwingUtilities2

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

Constructor Summary

AccessConstructor and Description
public
Utilities()

Constructs a Utilities.

Method Summary

Modifier and TypeMethod and Description
pack-priv static int

Returns:

the new insertion position
drawComposedText
(View
View hosting text
view
,
AttributeSet
the attributes containing the composed text
attr
,
Graphics
the graphics context
g
,
int
the X origin
x
,
int
the Y origin
y
,
int
starting offset in the composed text to be rendered
p0
,
int
ending offset in the composed text to be rendered
p1
)

Draws the given composed text passed from an input method.

pack-priv static float
drawComposedText(View view, AttributeSet attr, Graphics g, float x, float y, int p0, int p1)

pack-priv static float
drawComposedText(View view, AttributeSet attr, Graphics g, float x, float y, int p0, int p1, boolean useFPAPI)

public static final int

Returns:

the X location at the end of the rendered text
drawTabbedText
(Segment
the source of the text
s
,
int
the X origin >= 0
x
,
int
the Y origin >= 0
y
,
Graphics
the graphics context
g
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
)

Draws the given text, expanding any tabs that are contained using the given tab expansion technique.

public static final float

Returns:

the X location at the end of the rendered text
drawTabbedText
(Segment
the source of the text
s
,
float
the X origin >= 0
x
,
float
the Y origin >= 0
y
,
Graphics2D
the graphics context
g
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
)

Draws the given text, expanding any tabs that are contained using the given tab expansion technique.

pack-priv static final int

Returns:

the X location at the end of the rendered text
drawTabbedText
(View
View requesting rendering, may be null.
view
,
Segment
the source of the text
s
,
int
the X origin >= 0
x
,
int
the Y origin >= 0
y
,
Graphics
the graphics context
g
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
)

Draws the given text, expanding any tabs that are contained using the given tab expansion technique.

pack-priv static final int
drawTabbedText(View view, Segment s, int x, int y, Graphics g, TabExpander e, int startOffset, int[] justificationData)

pack-priv static final float
drawTabbedText(View view, Segment s, float x, float y, Graphics g, TabExpander e, int startOffset, int[] justificationData, boolean useFPAPI)

public static final int

Returns:

the offset into the given text
getBreakLocation
(Segment
the source of the text
s
,
FontMetrics
the font metrics to use for the calculation
metrics
,
int
the starting view location representing the start of the given text.
x0
,
int
the target view location to translate to an offset into the text.
x
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset in the document of the text
startOffset
)

Determine where to break the given text to fit within the given span.

pack-priv static final int
getBreakLocation(Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset, boolean useFPIAPI)

public static final int

Returns:

the offset into the given text
getBreakLocation
(Segment
the source of the text
s
,
FontMetrics
the font metrics to use for the calculation
metrics
,
float
the starting view location representing the start of the given text.
x0
,
float
the target view location to translate to an offset into the text.
x
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset in the document of the text
startOffset
)

Determine where to break the given text to fit within the given span.

pack-priv static JComponent
getJComponent(View view)

If view's container is a JComponent it is returned, after casting.

pack-priv static int

Returns:

the location within the model that best represents the next location visual position
getNextVisualPositionFrom
(View
View to query
v
,
int
the position to convert >= 0
pos
,
Position.Bias b, Shape
the allocated region to render into
alloc
,
int
the direction from the current position that can be thought of as the arrow keys typically found on a keyboard; this may be one of the following:
  • SwingConstants.WEST
  • SwingConstants.EAST
  • SwingConstants.NORTH
  • SwingConstants.SOUTH
direction
,
Position.Bias[]
an array contain the bias that was checked
biasRet
)

Provides a way to determine the next visually represented model location that one might place a caret.

public static final int

Returns:

the location in the model of the word start >= 0
getNextWord
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
)

Determines the start of the next word for the given location.

pack-priv static int
getNextWordInParagraph(JTextComponent c, Element line, int offs, boolean first)

Finds the next word in the given elements text.

public static final Element

Returns:

the element
getParagraphElement
(JTextComponent
the editor
c
,
int
the starting offset in the document >= 0
offs
)

Determines the element to use for a paragraph/line.

public static final int

Returns:

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.
getPositionAbove
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
,
int
the X coordinate >= 0
x
)
Deprecated since 9. replaced by getPositionAbove(JTextComponent, int, float)

Determines the position in the model that is closest to the given view location in the row above.

pack-priv static final int
getPositionAbove(JTextComponent c, int offs, float x, boolean useFPAPI)

public static final int

Returns:

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.
getPositionAbove
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
,
float
the X coordinate >= 0
x
)

Determines the position in the model that is closest to the given view location in the row above.

public static final int

Returns:

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.
getPositionBelow
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
,
int
the X coordinate >= 0
x
)
Deprecated since 9. replaced by getPositionBelow(JTextComponent, int, float)

Determines the position in the model that is closest to the given view location in the row below.

pack-priv static final int
getPositionBelow(JTextComponent c, int offs, float x, boolean useFPAPI)

public static final int

Returns:

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.
getPositionBelow
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
,
float
the X coordinate >= 0
x
)

Determines the position in the model that is closest to the given view location in the row below.

public static final int

Returns:

the location in the model of the word start >= 0
getPreviousWord
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
)

Determine the start of the prev word for the given location.

pack-priv static int
getPrevWordInParagraph(JTextComponent c, Element line, int offs)

Finds the previous word in the given elements text.

public static final int

Returns:

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.
getRowEnd
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
)

Determines the ending row model position of the row that contains the specified model position.

public static final int

Returns:

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.
getRowStart
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
)

Determines the starting row model position of the row that contains the specified model position.

public static final int

Returns:

the offset into the text >= 0
getTabbedTextOffset
(Segment
the source of the text
s
,
FontMetrics
the font metrics to use for the calculation
metrics
,
int
the starting view location representing the start of the given text >= 0.
x0
,
int
the target view location to translate to an offset into the text >= 0.
x
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
)

Determines the relative offset into the given text that best represents the given span in the view coordinate system.

pack-priv static final int
getTabbedTextOffset(View view, Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset, int[] justificationData)

pack-priv static final int
getTabbedTextOffset(View view, Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset, int[] justificationData)

public static final int

Returns:

the offset into the text >= 0
getTabbedTextOffset
(Segment
the source of the text
s
,
FontMetrics
the font metrics to use for the calculation
metrics
,
int
the starting view location representing the start of the given text >= 0.
x0
,
int
the target view location to translate to an offset into the text >= 0.
x
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
,
boolean
whether or not to round
round
)

Determines the relative offset into the given text that best represents the given span in the view coordinate system.

public static final int

Returns:

the offset into the text >= 0
getTabbedTextOffset
(Segment
the source of the text
s
,
FontMetrics
the font metrics to use for the calculation
metrics
,
float
the starting view location representing the start of the given text >= 0.
x0
,
float
the target view location to translate to an offset into the text >= 0.
x
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
,
boolean
whether or not to round
round
)

Determines the relative offset into the given text that best represents the given span in the view coordinate system.

pack-priv static final int
getTabbedTextOffset(View view, Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset, boolean round, int[] justificationData, boolean useFPAPI)

public static final int

Returns:

the width of the text
getTabbedTextWidth
(Segment
the source of the text
s
,
FontMetrics
the font metrics to use for the calculation
metrics
,
int
the X origin >= 0
x
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
)

Determines the width of the given segment of text taking tabs into consideration.

public static final float

Returns:

the width of the text
getTabbedTextWidth
(Segment
the source of the text
s
,
FontMetrics
the font metrics to use for the calculation
metrics
,
float
the X origin >= 0
x
,
TabExpander
how to expand the tabs. If this value is null, tabs will be expanded as a space character.
e
,
int
starting offset of the text in the document >= 0
startOffset
)

Determines the width of the given segment of text taking tabs into consideration.

pack-priv static final int
getTabbedTextWidth(View view, Segment s, FontMetrics metrics, int x, TabExpander e, int startOffset, int[] justificationData)

pack-priv static final float
getTabbedTextWidth(View view, Segment s, FontMetrics metrics, float x, TabExpander e, int startOffset, int[] justificationData)

pack-priv static final float
getTabbedTextWidth(View view, Segment s, FontMetrics metrics, float x, TabExpander e, int startOffset, int[] justificationData, boolean useFPAPI)

public static final int

Returns:

the location in the model of the word end >= 0
getWordEnd
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
)

Determines the end of a word for the given location.

public static final int

Returns:

the location in the model of the word start >= 0
getWordStart
(JTextComponent
the editor
c
,
int
the offset in the document >= 0
offs
)

Determines the start of a word for the given model location.

pack-priv static boolean
pack-priv static boolean
pack-priv static boolean
pack-priv static boolean
pack-priv static void
paintComposedText(Graphics g, Rectangle alloc, GlyphView v)

Paints the composed text in a GlyphView

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Utilitiesback to summary
public Utilities()

Constructs a Utilities.

Method Detail

drawComposedTextback to summary
pack-priv static int drawComposedText(View view, AttributeSet attr, Graphics g, int x, int y, int p0, int p1) throws BadLocationException

Draws the given composed text passed from an input method.

Parameters
view:View

View hosting text

attr:AttributeSet

the attributes containing the composed text

g:Graphics

the graphics context

x:int

the X origin

y:int

the Y origin

p0:int

starting offset in the composed text to be rendered

p1:int

ending offset in the composed text to be rendered

Returns:int

the new insertion position

drawComposedTextback to summary
pack-priv static float drawComposedText(View view, AttributeSet attr, Graphics g, float x, float y, int p0, int p1) throws BadLocationException
drawComposedTextback to summary
pack-priv static float drawComposedText(View view, AttributeSet attr, Graphics g, float x, float y, int p0, int p1, boolean useFPAPI) throws BadLocationException
drawTabbedTextback to summary
public static final int drawTabbedText(Segment s, int x, int y, 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:Segment

the source of the text

x:int

the X origin >= 0

y:int

the Y origin >= 0

g:Graphics

the graphics context

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

Returns:int

the X location at the end of the rendered text

Annotations
@Deprecated
since:9
drawTabbedTextback to summary
public static final float drawTabbedText(Segment s, float x, float y, Graphics2D g, TabExpander e, int startOffset)

Draws the given text, expanding any tabs that are contained using the given tab expansion technique.

Parameters
s:Segment

the source of the text

x:float

the X origin >= 0

y:float

the Y origin >= 0

g:Graphics2D

the graphics context

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

Returns:float

the X location at the end of the rendered text

Since
9
drawTabbedTextback to summary
pack-priv static final int drawTabbedText(View view, Segment s, int x, int y, 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
view:View

View requesting rendering, may be null.

s:Segment

the source of the text

x:int

the X origin >= 0

y:int

the Y origin >= 0

g:Graphics

the graphics context

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

Returns:int

the X location at the end of the rendered text

drawTabbedTextback to summary
pack-priv static final int drawTabbedText(View view, Segment s, int x, int y, Graphics g, TabExpander e, int startOffset, int[] justificationData)
drawTabbedTextback to summary
pack-priv static final float drawTabbedText(View view, Segment s, float x, float y, Graphics g, TabExpander e, int startOffset, int[] justificationData, boolean useFPAPI)
getBreakLocationback to summary
public static final int getBreakLocation(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset)

Determine where to break the given text to fit within the given span. This tries to find a word boundary.

Parameters
s:Segment

the source of the text

metrics:FontMetrics

the font metrics to use for the calculation

x0:int

the starting view location representing the start of the given text.

x:int

the target view location to translate to an offset into the text.

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset in the document of the text

Returns:int

the offset into the given text

Annotations
@Deprecated
since:9
getBreakLocationback to summary
pack-priv static final int getBreakLocation(Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset, boolean useFPIAPI)
getBreakLocationback to summary
public static final int getBreakLocation(Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset)

Determine where to break the given text to fit within the given span. This tries to find a word boundary.

Parameters
s:Segment

the source of the text

metrics:FontMetrics

the font metrics to use for the calculation

x0:float

the starting view location representing the start of the given text.

x:float

the target view location to translate to an offset into the text.

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset in the document of the text

Returns:int

the offset into the given text

Since
9
getJComponentback to summary
pack-priv static JComponent getJComponent(View view)

If view's container is a JComponent it is returned, after casting.

getNextVisualPositionFromback to summary
pack-priv static int getNextVisualPositionFrom(View v, int pos, Position.Bias b, Shape alloc, int direction, Position.Bias[] biasRet) throws BadLocationException

Provides a way to determine the next visually represented model location that one might place a caret. Some views may not be visible, they might not be in the same order found in the model, or they just might not allow access to some of the locations in the model.

This implementation assumes the views are laid out in a logical manner. That is, that the view at index x + 1 is visually after the View at index x, and that the View at index x - 1 is visually before the View at x. There is support for reversing this behavior only if the passed in View is an instance of CompositeView. The CompositeView must then override the flipEastAndWestAtEnds method.

Parameters
v:View

View to query

pos:int

the position to convert >= 0

alloc:Shape

the allocated region to render into

direction:int

the direction from the current position that can be thought of as the arrow keys typically found on a keyboard; this may be one of the following:

  • SwingConstants.WEST
  • SwingConstants.EAST
  • SwingConstants.NORTH
  • SwingConstants.SOUTH
biasRet:Position.Bias[]

an array contain the bias that was checked

Returns:int

the location within the model that best represents the next location visual position

Exceptions
IllegalArgumentException:
if direction is invalid
getNextWordback to summary
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:JTextComponent

the editor

offs:int

the offset in the document >= 0

Returns:int

the location in the model of the word start >= 0

Exceptions
BadLocationException:
if the offset is out of range
getNextWordInParagraphback to summary
pack-priv static int getNextWordInParagraph(JTextComponent c, Element line, int offs, boolean first) throws BadLocationException

Finds the next word in the given elements text. The first parameter allows searching multiple paragraphs where even the first offset is desired. Returns the offset of the next word, or BreakIterator.DONE if there are no more words in the element.

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

Determines the element to use for a paragraph/line.

Parameters
c:JTextComponent

the editor

offs:int

the starting offset in the document >= 0

Returns:Element

the element

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

Deprecated

since 9.

replaced by getPositionAbove(JTextComponent, int, float)

Determines the position in the model that is closest to the given view location in the row above. The component given must have a size to compute the result. If the component doesn't have a size a value of -1 will be returned.

Parameters
c:JTextComponent

the editor

offs:int

the offset in the document >= 0

x:int

the X coordinate >= 0

Returns:int

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.

Annotations
@Deprecated
since:9
Exceptions
BadLocationException:
if the offset is out of range
getPositionAboveback to summary
pack-priv static final int getPositionAbove(JTextComponent c, int offs, float x, boolean useFPAPI) throws BadLocationException
Annotations
@SuppressWarnings:deprecation
getPositionAboveback to summary
public static final int getPositionAbove(JTextComponent c, int offs, float x) throws BadLocationException

Determines the position in the model that is closest to the given view location in the row above. The component given must have a size to compute the result. If the component doesn't have a size a value of -1 will be returned.

Parameters
c:JTextComponent

the editor

offs:int

the offset in the document >= 0

x:float

the X coordinate >= 0

Returns:int

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.

Exceptions
BadLocationException:
if the offset is out of range
Since
9
getPositionBelowback to summary
public static final int getPositionBelow(JTextComponent c, int offs, int x) throws BadLocationException

Deprecated

since 9.

replaced by getPositionBelow(JTextComponent, int, float)

Determines the position in the model that is closest to the given view location in the row below. The component given must have a size to compute the result. If the component doesn't have a size a value of -1 will be returned.

Parameters
c:JTextComponent

the editor

offs:int

the offset in the document >= 0

x:int

the X coordinate >= 0

Returns:int

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.

Annotations
@Deprecated
since:9
Exceptions
BadLocationException:
if the offset is out of range
getPositionBelowback to summary
pack-priv static final int getPositionBelow(JTextComponent c, int offs, float x, boolean useFPAPI) throws BadLocationException
Annotations
@SuppressWarnings:deprecation
getPositionBelowback to summary
public static final int getPositionBelow(JTextComponent c, int offs, float x) throws BadLocationException

Determines the position in the model that is closest to the given view location in the row below. The component given must have a size to compute the result. If the component doesn't have a size a value of -1 will be returned.

Parameters
c:JTextComponent

the editor

offs:int

the offset in the document >= 0

x:float

the X coordinate >= 0

Returns:int

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.

Exceptions
BadLocationException:
if the offset is out of range
Since
9
getPreviousWordback to summary
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:JTextComponent

the editor

offs:int

the offset in the document >= 0

Returns:int

the location in the model of the word start >= 0

Exceptions
BadLocationException:
if the offset is out of range
getPrevWordInParagraphback to summary
pack-priv static int getPrevWordInParagraph(JTextComponent c, Element line, int offs) throws BadLocationException

Finds the previous word in the given elements text. The first parameter allows searching multiple paragraphs where even the first offset is desired. Returns the offset of the next word, or BreakIterator.DONE if there are no more words in the element.

getRowEndback to summary
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. The component given must have a size to compute the result. If the component doesn't have a size a value of -1 will be returned.

Parameters
c:JTextComponent

the editor

offs:int

the offset in the document >= 0

Returns:int

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.

Annotations
@SuppressWarnings:deprecation
Exceptions
BadLocationException:
if the offset is out of range
getRowStartback to summary
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. The component given must have a size to compute the result. If the component doesn't have a size a value of -1 will be returned.

Parameters
c:JTextComponent

the editor

offs:int

the offset in the document >= 0

Returns:int

the position >= 0 if the request can be computed, otherwise a value of -1 will be returned.

Annotations
@SuppressWarnings:deprecation
Exceptions
BadLocationException:
if the offset is out of range
getTabbedTextOffsetback to summary
public static final int getTabbedTextOffset(Segment s, 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:Segment

the source of the text

metrics:FontMetrics

the font metrics to use for the calculation

x0:int

the starting view location representing the start of the given text >= 0.

x:int

the target view location to translate to an offset into the text >= 0.

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

Returns:int

the offset into the text >= 0

Annotations
@Deprecated
since:9
getTabbedTextOffsetback to summary
pack-priv static final int getTabbedTextOffset(View view, Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset, int[] justificationData)
getTabbedTextOffsetback to summary
pack-priv static final int getTabbedTextOffset(View view, Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset, int[] justificationData)
getTabbedTextOffsetback to summary
public static final int getTabbedTextOffset(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset, boolean round)

Determines the relative offset into the given text that best represents the given span in the view coordinate system.

Parameters
s:Segment

the source of the text

metrics:FontMetrics

the font metrics to use for the calculation

x0:int

the starting view location representing the start of the given text >= 0.

x:int

the target view location to translate to an offset into the text >= 0.

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

round:boolean

whether or not to round

Returns:int

the offset into the text >= 0

Annotations
@Deprecated
since:9
getTabbedTextOffsetback to summary
public static final int getTabbedTextOffset(Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset, boolean round)

Determines the relative offset into the given text that best represents the given span in the view coordinate system.

Parameters
s:Segment

the source of the text

metrics:FontMetrics

the font metrics to use for the calculation

x0:float

the starting view location representing the start of the given text >= 0.

x:float

the target view location to translate to an offset into the text >= 0.

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

round:boolean

whether or not to round

Returns:int

the offset into the text >= 0

Since
9
getTabbedTextOffsetback to summary
pack-priv static final int getTabbedTextOffset(View view, Segment s, FontMetrics metrics, float x0, float x, TabExpander e, int startOffset, boolean round, int[] justificationData, boolean useFPAPI)
getTabbedTextWidthback to summary
public static final int getTabbedTextWidth(Segment s, 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:Segment

the source of the text

metrics:FontMetrics

the font metrics to use for the calculation

x:int

the X origin >= 0

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

Returns:int

the width of the text

Annotations
@Deprecated
since:9
getTabbedTextWidthback to summary
public static final float getTabbedTextWidth(Segment s, FontMetrics metrics, float x, TabExpander e, int startOffset)

Determines the width of the given segment of text taking tabs into consideration.

Parameters
s:Segment

the source of the text

metrics:FontMetrics

the font metrics to use for the calculation

x:float

the X origin >= 0

e:TabExpander

how to expand the tabs. If this value is null, tabs will be expanded as a space character.

startOffset:int

starting offset of the text in the document >= 0

Returns:float

the width of the text

Since
9
getTabbedTextWidthback to summary
pack-priv static final int getTabbedTextWidth(View view, Segment s, FontMetrics metrics, int x, TabExpander e, int startOffset, int[] justificationData)
getTabbedTextWidthback to summary
pack-priv static final float getTabbedTextWidth(View view, Segment s, FontMetrics metrics, float x, TabExpander e, int startOffset, int[] justificationData)
getTabbedTextWidthback to summary
pack-priv static final float getTabbedTextWidth(View view, Segment s, FontMetrics metrics, float x, TabExpander e, int startOffset, int[] justificationData, boolean useFPAPI)
getWordEndback to summary
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:JTextComponent

the editor

offs:int

the offset in the document >= 0

Returns:int

the location in the model of the word end >= 0

Exceptions
BadLocationException:
if the offset is out of range
getWordStartback to summary
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:JTextComponent

the editor

offs:int

the offset in the document >= 0

Returns:int

the location in the model of the word start >= 0

Exceptions
BadLocationException:
if the offset is out of range
isComposedTextAttributeDefinedback to summary
pack-priv static boolean isComposedTextAttributeDefined(AttributeSet as)
isComposedTextElementback to summary
pack-priv static boolean isComposedTextElement(Document doc, int offset)
isComposedTextElementback to summary
pack-priv static boolean isComposedTextElement(Element elem)
isLeftToRightback to summary
pack-priv static boolean isLeftToRight(Component c)
paintComposedTextback to summary
pack-priv static void paintComposedText(Graphics g, Rectangle alloc, GlyphView v)

Paints the composed text in a GlyphView