public abstract class BasicTextUI extends javax.swing.plaf.TextUI implements javax.swing.text.ViewFactory
| Modifier and Type | Class and Description |
|---|---|
static class |
BasicTextUI.BasicCaret
A
DefaultCaret that implements UIResource. |
static class |
BasicTextUI.BasicHighlighter
A
DefaultHighlighter that implements UIResource. |
| Constructor and Description |
|---|
BasicTextUI()
Creates a new
BasicTextUI instance. |
| Modifier and Type | Method and Description |
|---|---|
javax.swing.text.View |
create(javax.swing.text.Element elem)
Creates a
View for the specified Element. |
javax.swing.text.View |
create(javax.swing.text.Element elem,
int p0,
int p1)
Creates a
View for the specified Element. |
protected javax.swing.text.Caret |
createCaret()
Creates a
Caret that should be installed into the text component. |
protected javax.swing.text.Highlighter |
createHighlighter()
Creates a
Highlighter that should be installed into the text
component. |
protected javax.swing.text.Keymap |
createKeymap()
Creates the
Keymap that is installed on the text component. |
void |
damageRange(javax.swing.text.JTextComponent t,
int p0,
int p1)
Marks the specified range inside the text component's model as
damaged and queues a repaint request.
|
void |
damageRange(javax.swing.text.JTextComponent t,
int p0,
int p1,
javax.swing.text.Position.Bias firstBias,
javax.swing.text.Position.Bias secondBias)
Marks the specified range inside the text component's model as
damaged and queues a repaint request.
|
protected javax.swing.text.JTextComponent |
getComponent()
The text component that is managed by this UI.
|
javax.swing.text.EditorKit |
getEditorKit(javax.swing.text.JTextComponent t)
Returns the
EditorKit used for the text component that is managed
by this UI. |
protected java.lang.String |
getKeymapName()
Returns the name of the keymap for this type of TextUI.
|
java.awt.Dimension |
getMaximumSize(javax.swing.JComponent c)
Returns the maximum size for text components that use this UI.
|
java.awt.Dimension |
getMinimumSize(javax.swing.JComponent c)
Returns the minimum size for text components.
|
int |
getNextVisualPositionFrom(javax.swing.text.JTextComponent t,
int pos,
javax.swing.text.Position.Bias b,
int direction,
javax.swing.text.Position.Bias[] biasRet)
Gets the next position inside the document model that is visible on
screen, starting from
pos. |
java.awt.Dimension |
getPreferredSize(javax.swing.JComponent c)
Returns the preferred size of the text component.
|
protected abstract java.lang.String |
getPropertyPrefix()
Returns the property prefix by which the text component's UIDefaults
are looked up.
|
javax.swing.text.View |
getRootView(javax.swing.text.JTextComponent t)
Returns the root
View of a text component. |
protected java.awt.Rectangle |
getVisibleEditorRect()
Returns the allocation to give the root view.
|
protected void |
installDefaults()
Installs UI defaults on the text components.
|
protected void |
installKeyboardActions()
Installs the keyboard actions on the text components.
|
protected void |
installListeners()
Install all listeners on the text component.
|
void |
installUI(javax.swing.JComponent c)
Installs this UI on the text component.
|
protected void |
modelChanged()
Indicates that the model of a text component has changed.
|
java.awt.Rectangle |
modelToView(javax.swing.text.JTextComponent t,
int pos)
Maps a position in the document into the coordinate space of the View.
|
java.awt.Rectangle |
modelToView(javax.swing.text.JTextComponent t,
int pos,
javax.swing.text.Position.Bias bias)
Maps a position in the document into the coordinate space of the View.
|
void |
paint(java.awt.Graphics g,
javax.swing.JComponent c)
Paints the text component.
|
protected void |
paintBackground(java.awt.Graphics g)
Paints the background of the text component.
|
protected void |
paintSafely(java.awt.Graphics g)
This paints the text component while beeing sure that the model is not
modified while painting.
|
protected void |
propertyChange(java.beans.PropertyChangeEvent ev)
Receives notification whenever one of the text component's bound
properties changes.
|
protected void |
setView(javax.swing.text.View view)
Sets the root view for the text component.
|
protected void |
uninstallDefaults()
Uninstalls all default properties that have previously been installed by
this UI.
|
protected void |
uninstallKeyboardActions()
Uninstalls all keyboard actions that have previously been installed by
this UI.
|
protected void |
uninstallListeners()
Uninstalls all listeners that have previously been installed by
this UI.
|
void |
uninstallUI(javax.swing.JComponent component)
Uninstalls this TextUI from the text component.
|
void |
update(java.awt.Graphics g,
javax.swing.JComponent c)
Overridden for better control over background painting.
|
int |
viewToModel(javax.swing.text.JTextComponent t,
java.awt.Point pt)
Maps a point in the
View coordinate space to a position
inside a document model. |
int |
viewToModel(javax.swing.text.JTextComponent t,
java.awt.Point pt,
javax.swing.text.Position.Bias[] biasReturn)
Maps a point in the
View coordinate space to a position
inside a document model. |
public BasicTextUI()
BasicTextUI instance.protected javax.swing.text.Caret createCaret()
Caret that should be installed into the text component.protected javax.swing.text.Highlighter createHighlighter()
Highlighter that should be installed into the text
component.Highlighter for the text componentprotected final javax.swing.text.JTextComponent getComponent()
public void installUI(javax.swing.JComponent c)
installUI in class javax.swing.plaf.ComponentUIc - the text component on which to install the UIComponentUI.uninstallUI(javax.swing.JComponent),
JComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()protected void installDefaults()
protected void installListeners()
protected java.lang.String getKeymapName()
protected javax.swing.text.Keymap createKeymap()
Keymap that is installed on the text component.Keymap that is installed on the text componentprotected void installKeyboardActions()
public void uninstallUI(javax.swing.JComponent component)
uninstallUI in class javax.swing.plaf.ComponentUIcomponent - the text component to uninstall the UI fromComponentUI.installUI(javax.swing.JComponent),
JComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()protected void uninstallDefaults()
protected void uninstallListeners()
protected void uninstallKeyboardActions()
protected abstract java.lang.String getPropertyPrefix()
public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
getPreferredSize in class javax.swing.plaf.ComponentUIc - not used herepublic java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
getMaximumSize in class javax.swing.plaf.ComponentUIc - not used herepublic java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
getMinimumSize in class javax.swing.plaf.ComponentUIc - the component for which this delegate performs services.public final void paint(java.awt.Graphics g, javax.swing.JComponent c)
paintSafely(Graphics) in order to actually perform the
painting.paint in class javax.swing.plaf.ComponentUIg - the Graphics context to paint toc - not used hereprotected void paintSafely(java.awt.Graphics g)
paintBackground(Graphics).g - the Graphics context to paint toprotected void paintBackground(java.awt.Graphics g)
g - the Graphics context to paint topublic void update(java.awt.Graphics g, javax.swing.JComponent c)
paint(java.awt.Graphics, javax.swing.JComponent) and this delegates the background painting to
paintBackground(java.awt.Graphics).update in class javax.swing.plaf.ComponentUIg - the graphics to usec - the component to be paintedComponentUI.paint(java.awt.Graphics, javax.swing.JComponent),
JComponent.paintComponent(java.awt.Graphics)public void damageRange(javax.swing.text.JTextComponent t, int p0, int p1)
damageRange in class javax.swing.plaf.TextUIt - the text componentp0 - the start location inside the document model of the range that
is damagedp1 - the end location inside the document model of the range that
is damagedpublic void damageRange(javax.swing.text.JTextComponent t, int p0, int p1, javax.swing.text.Position.Bias firstBias, javax.swing.text.Position.Bias secondBias)
Position.Bias object to be specified for the start
and end location of the range.damageRange in class javax.swing.plaf.TextUIt - the text componentp0 - the start location inside the document model of the range that
is damagedp1 - the end location inside the document model of the range that
is damagedfirstBias - the bias for the start locationsecondBias - the bias for the end locationpublic javax.swing.text.EditorKit getEditorKit(javax.swing.text.JTextComponent t)
EditorKit used for the text component that is managed
by this UI.getEditorKit in class javax.swing.plaf.TextUIt - the text componentEditorKit used for the text component that is managed
by this UIpublic int getNextVisualPositionFrom(javax.swing.text.JTextComponent t, int pos, javax.swing.text.Position.Bias b, int direction, javax.swing.text.Position.Bias[] biasRet) throws javax.swing.text.BadLocationException
pos.getNextVisualPositionFrom in class javax.swing.plaf.TextUIt - the text componentpos - the start positionnb - the bias for posdirection - the search directionbiasRet - filled by the method to indicate the bias of the return
valuejavax.swing.text.BadLocationException - if pos does not
designate a valid position in the document model.public javax.swing.text.View getRootView(javax.swing.text.JTextComponent t)
View of a text component.getRootView in class javax.swing.plaf.TextUIt - the JTextComponent for which this
delegate object provides the user interface.View of a text componentpublic java.awt.Rectangle modelToView(javax.swing.text.JTextComponent t, int pos) throws javax.swing.text.BadLocationException
Position.Bias#Forward is used in this method.modelToView in class javax.swing.plaf.TextUIt - the text componentpos - the position of the character in the modeljavax.swing.text.BadLocationException - if pos is invalidjava.lang.IllegalArgumentException - if b is not one of the above listed
valid valuesComponentView.modelToView(int, Shape, Position.Bias)public java.awt.Rectangle modelToView(javax.swing.text.JTextComponent t, int pos, javax.swing.text.Position.Bias bias) throws javax.swing.text.BadLocationException
modelToView in class javax.swing.plaf.TextUIt - the text componentpos - the position of the character in the modelbias - either Position.Bias#Forward or
Position.Bias#Backward depending on the preferred
direction bias. If null this defaults to
Position.Bias.Forwardjavax.swing.text.BadLocationException - if pos is invalidjava.lang.IllegalArgumentException - if b is not one of the above listed
valid valuesComponentView.modelToView(int, Shape, Position.Bias)public int viewToModel(javax.swing.text.JTextComponent t, java.awt.Point pt)
View coordinate space to a position
inside a document model.viewToModel in class javax.swing.plaf.TextUIt - the text componentpt - the point to be mappedptTextUI.viewToModel(JTextComponent, Point, Position.Bias[])public int viewToModel(javax.swing.text.JTextComponent t, java.awt.Point pt, javax.swing.text.Position.Bias[] biasReturn)
View coordinate space to a position
inside a document model.viewToModel in class javax.swing.plaf.TextUIt - the text componentpt - the point to be mappedbiasReturn - filled in by the method to indicate the bias of the
return valueptpublic javax.swing.text.View create(javax.swing.text.Element elem)
View for the specified Element.create in interface javax.swing.text.ViewFactoryelem - the Element to create a View forViewFactorypublic javax.swing.text.View create(javax.swing.text.Element elem, int p0, int p1)
View for the specified Element.elem - the Element to create a View forp0 - the start offsetp1 - the end offsetViewFactoryprotected java.awt.Rectangle getVisibleEditorRect()
protected final void setView(javax.swing.text.View view)
view - the View to be set as root viewprotected void modelChanged()
protected void propertyChange(java.beans.PropertyChangeEvent ev)
ev - the property change event