Top Description Constructors Methods
javax.swing.plaf

public abstract Class TextUI

extends ComponentUI
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.basic.BasicTextUI, javax.swing.plaf.multi.MultiTextUI
Imports
java.awt.Point, .Rectangle, java.awt.geom.Point2D, .Rectangle2D, javax.swing.text.*

Text editor user interface
Author
Timothy Prinzing

Constructor Summary

AccessConstructor and Description
protected
TextUI()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract void
damageRange(JTextComponent
the text component for which this UI is installed
t
,
int
the beginning of the range >= 0
p0
,
int
the end of the range >= p0
p1
)

Causes the portion of the view responsible for the given part of the model to be repainted.

public abstract void
damageRange(JTextComponent
the text component for which this UI is installed
t
,
int
the beginning of the range >= 0
p0
,
int
the end of the range >= p0
p1
,
Position.Bias
the bias of the first character position, toward the previous character or the next character
firstBias
,
Position.Bias
the bias of the second character position, toward the previous character or the next character
secondBias
)

Causes the portion of the view responsible for the given part of the model to be repainted.

public abstract EditorKit

Returns:

the editor kit binding
getEditorKit
(JTextComponent
the text component for which this UI is installed
t
)

Fetches the binding of services that set a policy for the type of document being edited.

public abstract int

Returns:

the location within the model that best represents the next location visual position
getNextVisualPositionFrom
(JTextComponent
the text component for which this UI is installed
t
,
int
the position to convert >= 0
pos
,
Position.Bias
the bias for the position
b
,
int
the direction from the current position that can be thought of as the arrow keys typically found on a keyboard. This may be SwingConstants.WEST, SwingConstants.EAST, SwingConstants.NORTH, or SwingConstants.SOUTH
direction
,
Position.Bias[]
an array to contain the bias for the returned position
biasRet
)

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

public abstract View

Returns:

a View with the allocation of the associated text component
getRootView
(JTextComponent
the text component for which this UI is installed
t
)

Fetches a View with the allocation of the associated text component (i.e. the root of the hierarchy) that can be traversed to determine how the model is being represented spatially.

public String

Returns:

a String containing the tooltip
getToolTipText
(JTextComponent
the text component for which this UI is installed
t
,
Point
a Point specifying location for which to get a tooltip
pt
)

Deprecated since 9. replaced by getToolTipText2D(JTextComponent, Point2D)
Returns the string to be used as the tooltip at the passed in location.
public String

Returns:

a String containing the tooltip
getToolTipText2D
(JTextComponent
the text component for which this UI is installed
t
,
Point2D
a Point specifying location for which to get a tooltip
pt
)

Returns the string to be used as the tooltip at the passed in location.

public abstract Rectangle

Returns:

the coordinates as a Rectangle
modelToView
(JTextComponent
the text component for which this UI is installed
t
,
int
the local location in the model to translate >= 0
pos
)

Deprecated since 9. replaced by modelToView2D(JTextComponent, int, Position.Bias)
Converts the given location in the model to a place in the view coordinate system.
public abstract Rectangle

Returns:

the coordinates as a Rectangle
modelToView
(JTextComponent
the text component for which this UI is installed
t
,
int
the local location in the model to translate >= 0
pos
,
Position.Bias
the bias for the position
bias
)

Deprecated since 9. replaced by modelToView2D(JTextComponent, int, Position.Bias)
Converts the given location in the model to a place in the view coordinate system.
public Rectangle2D

Returns:

the coordinates as a Rectangle2D
modelToView2D
(JTextComponent
the text component for which this UI is installed
t
,
int
the local location in the model to translate >= 0
pos
,
Position.Bias
the bias for the position
bias
)

Converts the given location in the model to a place in the view coordinate system.

public abstract int

Returns:

the offset from the start of the document >= 0
viewToModel
(JTextComponent
the text component for which this UI is installed
t
,
Point
the location in the view to translate. This should be in the same coordinate system as the mouse events.
pt
)

Converts the given place in the view coordinate system to the nearest representative location in the model.
public abstract int

Returns:

the location within the model that best represents the given point in the view >= 0
viewToModel
(JTextComponent
the text component for which this UI is installed
t
,
Point
the location in the view to translate. This should be in the same coordinate system as the mouse events.
pt
,
Position.Bias[]
filled in by this method to indicate whether the point given is closer to the previous or the next character in the model
biasReturn
)

Provides a mapping from the view coordinate space to the logical coordinate space of the model.
public int

Returns:

the location within the model that best represents the given point in the view >= 0
viewToModel2D
(JTextComponent
the text component for which this UI is installed
t
,
Point2D
the location in the view to translate.
pt
,
Position.Bias[]
filled in by this method to indicate whether the point given is closer to the previous or the next character in the model
biasReturn
)

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Inherited from javax.swing.plaf.ComponentUI:
containscreateUIgetAccessibleChildgetAccessibleChildrenCountgetBaselinegetBaselineResizeBehaviorgetMaximumSizegetMinimumSizegetPreferredSizeinstallUIpaintuninstallUIupdate

Constructor Detail

TextUIback to summary
protected TextUI()

Constructor for subclasses to call.

Method Detail

damageRangeback to summary
public abstract void damageRange(JTextComponent t, int p0, int p1)

Causes the portion of the view responsible for the given part of the model to be repainted.

Parameters
t:JTextComponent

the text component for which this UI is installed

p0:int

the beginning of the range >= 0

p1:int

the end of the range >= p0

damageRangeback to summary
public abstract void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias)

Causes the portion of the view responsible for the given part of the model to be repainted.

Parameters
t:JTextComponent

the text component for which this UI is installed

p0:int

the beginning of the range >= 0

p1:int

the end of the range >= p0

firstBias:Position.Bias

the bias of the first character position, toward the previous character or the next character

secondBias:Position.Bias

the bias of the second character position, toward the previous character or the next character

getEditorKitback to summary
public abstract EditorKit getEditorKit(JTextComponent t)

Fetches the binding of services that set a policy for the type of document being edited. This contains things like the commands available, stream readers and writers, etc.

Parameters
t:JTextComponent

the text component for which this UI is installed

Returns:EditorKit

the editor kit binding

getNextVisualPositionFromback to summary
public abstract int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, 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.

Parameters
t:JTextComponent

the text component for which this UI is installed

pos:int

the position to convert >= 0

b:Position.Bias

the bias for the position

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 SwingConstants.WEST, SwingConstants.EAST, SwingConstants.NORTH, or SwingConstants.SOUTH

biasRet:Position.Bias[]

an array to contain the bias for the returned position

Returns:int

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

Exceptions
BadLocationException:
for a bad location within a document model
IllegalArgumentException:
for an invalid direction
getRootViewback to summary
public abstract View getRootView(JTextComponent t)

Fetches a View with the allocation of the associated text component (i.e. the root of the hierarchy) that can be traversed to determine how the model is being represented spatially.

Parameters
t:JTextComponent

the text component for which this UI is installed

Returns:View

a View with the allocation of the associated text component

getToolTipTextback to summary
public String getToolTipText(JTextComponent t, Point pt)

Deprecated

since 9.

replaced by getToolTipText2D(JTextComponent, Point2D)

Returns the string to be used as the tooltip at the passed in location.

Parameters
t:JTextComponent

the text component for which this UI is installed

pt:Point

a Point specifying location for which to get a tooltip

Returns:String

a String containing the tooltip

Annotations
@Deprecated
since:9
Since
1.4
See Also
javax.swing.text.JTextComponent#getToolTipText
getToolTipText2Dback to summary
public String getToolTipText2D(JTextComponent t, Point2D pt)

Returns the string to be used as the tooltip at the passed in location.

Implementation Specification

This implementation calls getToolTipText(t, new Point((int) pt.getX(), (int) pt.getY()))).

Parameters
t:JTextComponent

the text component for which this UI is installed

pt:Point2D

a Point specifying location for which to get a tooltip

Returns:String

a String containing the tooltip

Since
9
See Also
javax.swing.text.JTextComponent#getToolTipText
modelToViewback to summary
public abstract Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException

Converts the given location in the model to a place in the view coordinate system.

Parameters
t:JTextComponent

the text component for which this UI is installed

pos:int

the local location in the model to translate >= 0

Returns:Rectangle

the coordinates as a Rectangle

Annotations
@Deprecated
since:9
Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
modelToViewback to summary
public abstract Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException

Converts the given location in the model to a place in the view coordinate system.

Parameters
t:JTextComponent

the text component for which this UI is installed

pos:int

the local location in the model to translate >= 0

bias:Position.Bias

the bias for the position

Returns:Rectangle

the coordinates as a Rectangle

Annotations
@Deprecated
since:9
Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
modelToView2Dback to summary
public Rectangle2D modelToView2D(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException

Converts the given location in the model to a place in the view coordinate system.

Implementation Specification

This implementation calls modelToView(t, pos, bias).

Parameters
t:JTextComponent

the text component for which this UI is installed

pos:int

the local location in the model to translate >= 0

bias:Position.Bias

the bias for the position

Returns:Rectangle2D

the coordinates as a Rectangle2D

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
Since
9
viewToModelback to summary
public abstract int viewToModel(JTextComponent t, Point pt)

Converts the given place in the view coordinate system to the nearest representative location in the model.

Parameters
t:JTextComponent

the text component for which this UI is installed

pt:Point

the location in the view to translate. This should be in the same coordinate system as the mouse events.

Returns:int

the offset from the start of the document >= 0

Annotations
@Deprecated
since:9
viewToModelback to summary
public abstract int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters
t:JTextComponent

the text component for which this UI is installed

pt:Point

the location in the view to translate. This should be in the same coordinate system as the mouse events.

biasReturn:Position.Bias[]

filled in by this method to indicate whether the point given is closer to the previous or the next character in the model

Returns:int

the location within the model that best represents the given point in the view >= 0

Annotations
@Deprecated
since:9
viewToModel2Dback to summary
public int viewToModel2D(JTextComponent t, Point2D pt, Position.Bias[] biasReturn)

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Implementation Specification

This implementation calls viewToModel(t, new Point((int) pt.getX(), (int) pt.getY()), biasReturn).

Parameters
t:JTextComponent

the text component for which this UI is installed

pt:Point2D

the location in the view to translate.

biasReturn:Position.Bias[]

filled in by this method to indicate whether the point given is closer to the previous or the next character in the model

Returns:int

the location within the model that best represents the given point in the view >= 0

Since
9