public abstract class BasicTextUI extends TextUI implements 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 |
|---|---|
View |
create(Element elem)
|
View |
create(Element elem,
int p0,
int p1)
|
protected Caret |
createCaret()
Creates a
Caret that should be installed into the text component. |
protected Highlighter |
createHighlighter()
Creates a
Highlighter that should be installed into the text
component. |
protected Keymap |
createKeymap()
Creates the
Keymap that is installed on the text component. |
void |
damageRange(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(JTextComponent t,
int p0,
int p1,
Position.Bias firstBias,
Position.Bias secondBias)
Marks the specified range inside the text component's model as
damaged and queues a repaint request.
|
protected JTextComponent |
getComponent()
The text component that is managed by this UI.
|
EditorKit |
getEditorKit(JTextComponent t)
Returns the
EditorKit used for the text component that is managed
by this UI. |
protected String |
getKeymapName()
Returns the name of the keymap for this type of TextUI.
|
Dimension |
getMaximumSize(JComponent c)
Returns the maximum size for text components that use this UI.
|
Dimension |
getMinimumSize(JComponent c)
Returns the minimum size for text components.
|
int |
getNextVisualPositionFrom(JTextComponent t,
int pos,
Position.Bias b,
int direction,
Position.Bias[] biasRet)
Gets the next position inside the document model that is visible on
screen, starting from
pos. |
Dimension |
getPreferredSize(JComponent c)
Returns the preferred size of the text component.
|
protected abstract String |
getPropertyPrefix()
Returns the property prefix by which the text component's UIDefaults
are looked up.
|
View |
getRootView(JTextComponent t)
Returns the root
View of a text component. |
protected 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(JComponent c)
Installs this UI on the text component.
|
protected void |
modelChanged()
Indicates that the model of a text component has changed.
|
Rectangle |
modelToView(JTextComponent t,
int pos)
Maps a position in the document into the coordinate space of the View.
|
Rectangle |
modelToView(JTextComponent t,
int pos,
Position.Bias bias)
Maps a position in the document into the coordinate space of the View.
|
void |
paint(Graphics g,
JComponent c)
Paints the text component.
|
protected void |
paintBackground(Graphics g)
Paints the background of the text component.
|
protected void |
paintSafely(Graphics g)
This paints the text component while beeing sure that the model is not
modified while painting.
|
protected void |
propertyChange(PropertyChangeEvent ev)
Receives notification whenever one of the text component's bound
properties changes.
|
protected void |
setView(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(JComponent component)
Uninstalls this TextUI from the text component.
|
void |
update(Graphics g,
JComponent c)
Overridden for better control over background painting.
|
int |
viewToModel(JTextComponent t,
Point pt)
Maps a point in the
View coordinate space to a position
inside a document model. |
int |
viewToModel(JTextComponent t,
Point pt,
Position.Bias[] biasReturn)
Maps a point in the
View coordinate space to a position
inside a document model. |
getToolTipTextcontains, createUI, getAccessibleChild, getAccessibleChildrenCountpublic BasicTextUI()
BasicTextUI instance.protected Caret createCaret()
Caret that should be installed into the text component.protected Highlighter createHighlighter()
Highlighter that should be installed into the text
component.Highlighter for the text componentprotected final JTextComponent getComponent()
public void installUI(JComponent c)
installUI in class 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 String getKeymapName()
protected Keymap createKeymap()
Keymap that is installed on the text component.Keymap that is installed on the text componentprotected void installKeyboardActions()
public void uninstallUI(JComponent component)
uninstallUI in class 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 String getPropertyPrefix()
public Dimension getPreferredSize(JComponent c)
getPreferredSize in class ComponentUIc - not used herepublic Dimension getMaximumSize(JComponent c)
getMaximumSize in class ComponentUIc - not used herepublic Dimension getMinimumSize(JComponent c)
getMinimumSize in class ComponentUIc - the component for which this delegate performs services.public final void paint(Graphics g, JComponent c)
paintSafely(Graphics) in order to actually perform the
painting.paint in class ComponentUIg - the Graphics context to paint toc - not used hereprotected void paintSafely(Graphics g)
paintBackground(Graphics).g - the Graphics context to paint toprotected void paintBackground(Graphics g)
g - the Graphics context to paint topublic void update(Graphics g, JComponent c)
paint(java.awt.Graphics, javax.swing.JComponent) and this delegates the background painting to
paintBackground(java.awt.Graphics).update in class 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(JTextComponent t, int p0, int p1)
damageRange in class 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(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias)
Position.Bias object to be specified for the start
and end location of the range.damageRange in class 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 EditorKit getEditorKit(JTextComponent t)
EditorKit used for the text component that is managed
by this UI.getEditorKit in class TextUIt - the text componentEditorKit used for the text component that is managed
by this UIpublic int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException
pos.getNextVisualPositionFrom in class 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
valueBadLocationException - if pos does not
designate a valid position in the document model.public View getRootView(JTextComponent t)
View of a text component.getRootView in class TextUIt - the JTextComponent for which this
delegate object provides the user interface.View of a text componentpublic Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException
Position.Bias#Forward is used in this method.modelToView in class TextUIt - the text componentpos - the position of the character in the modelBadLocationException - if pos is invalidIllegalArgumentException - if b is not one of the above listed
valid valuesComponentView.modelToView(int, Shape, Position.Bias)public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException
modelToView in class 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.ForwardBadLocationException - if pos is invalidIllegalArgumentException - if b is not one of the above listed
valid valuesComponentView.modelToView(int, Shape, Position.Bias)public int viewToModel(JTextComponent t, Point pt)
View coordinate space to a position
inside a document model.viewToModel in class TextUIt - the text componentpt - the point to be mappedptTextUI.viewToModel(JTextComponent, Point, Position.Bias[])public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)
View coordinate space to a position
inside a document model.viewToModel in class TextUIt - the text componentpt - the point to be mappedbiasReturn - filled in by the method to indicate the bias of the
return valueptpublic View create(Element elem)
create in interface ViewFactoryelem - the Element to create a View forViewFactorypublic View create(Element elem, int p0, int p1)
elem - the Element to create a View forp0 - the start offsetp1 - the end offsetViewFactoryprotected Rectangle getVisibleEditorRect()
protected final void setView(View view)
view - the View to be set as root viewprotected void modelChanged()
protected void propertyChange(PropertyChangeEvent ev)
ev - the property change event