The abstract base class from which the UI classes for Swings text
components are derived. This provides most of the functionality for
the UI classes.
create
public View create(Element elem,
int p0,
int p1)
elem
- the Element
to create a View
forp0
- the start offsetp1
- the end offset
createCaret
protected Caret createCaret()
Creates a
Caret
that should be installed into the text component.
- a caret that should be installed into the text component
createKeymap
protected Keymap createKeymap()
Creates the
Keymap
that is installed on the text component.
- the
Keymap
that is installed on the text component
damageRange
public 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.
- damageRange in interface TextUI
t
- 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 damaged
damageRange
public 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. This variant of this method
allows a
Position.Bias
object to be specified for the start
and end location of the range.
- damageRange in interface TextUI
t
- 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 location
getComponent
protected final JTextComponent getComponent()
The text component that is managed by this UI.
- the text component that is managed by this UI
getKeymapName
protected String getKeymapName()
Returns the name of the keymap for this type of TextUI.
This is implemented so that the classname of this TextUI
without the package prefix is returned. This way subclasses
don't have to override this method.
- the name of the keymap for this TextUI
getPropertyPrefix
protected abstract String getPropertyPrefix()
Returns the property prefix by which the text component's UIDefaults
are looked up.
- the property prefix by which the text component's UIDefaults
are looked up
getVisibleEditorRect
protected Rectangle getVisibleEditorRect()
Returns the allocation to give the root view.
- the allocation to give the root view
installDefaults
protected void installDefaults()
Installs UI defaults on the text components.
installKeyboardActions
protected void installKeyboardActions()
Installs the keyboard actions on the text components.
installListeners
protected void installListeners()
Install all listeners on the text component.
modelChanged
protected void modelChanged()
Indicates that the model of a text component has changed. This
triggers a rebuild of the view hierarchy.
modelToView
public Rectangle modelToView(JTextComponent t,
int pos)
throws BadLocationException
Maps a position in the document into the coordinate space of the View.
The output rectangle usually reflects the font height but has a width
of zero. A bias of
Position.Bias.Forward
is used in this method.
- modelToView in interface TextUI
t
- the text componentpos
- the position of the character in the model
- a rectangle that gives the location of the document position
inside the view coordinate space
paintBackground
protected void paintBackground(Graphics g)
Paints the background of the text component.
g
- the Graphics
context to paint to
paintSafely
protected void paintSafely(Graphics g)
This paints the text component while beeing sure that the model is not
modified while painting.
The following is performed in this order:
- If the text component is opaque, the background is painted by
calling
paintBackground(Graphics)
. - If there is a highlighter, the highlighter is painted.
- The view hierarchy is painted.
- The Caret is painter.
g
- the Graphics
context to paint to
propertyChange
protected void propertyChange(PropertyChangeEvent ev)
Receives notification whenever one of the text component's bound
properties changes. This default implementation does nothing.
It is a hook that enables subclasses to react to property changes
on the text component.
ev
- the property change event
setView
protected final void setView(View view)
Sets the root view for the text component.
view
- the View
to be set as root view
uninstallDefaults
protected void uninstallDefaults()
Uninstalls all default properties that have previously been installed by
this UI.
uninstallKeyboardActions
protected void uninstallKeyboardActions()
Uninstalls all keyboard actions that have previously been installed by
this UI.
uninstallListeners
protected void uninstallListeners()
Uninstalls all listeners that have previously been installed by
this UI.
viewToModel
public int viewToModel(JTextComponent t,
Point pt)
Maps a point in the View
coordinate space to a position
inside a document model.
- viewToModel in interface TextUI
t
- the text componentpt
- the point to be mapped
- the position inside the document model that corresponds to
pt
viewToModel
public int viewToModel(JTextComponent t,
Point pt,
Position.Bias[] biasReturn)
Maps a point in the View
coordinate space to a position
inside a document model.
- viewToModel in interface TextUI
t
- the text componentpt
- the point to be mappedbiasReturn
- filled in by the method to indicate the bias of the
return value
- the position inside the document model that corresponds to
pt
BasicTextUI.java --
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.