diff options
author | Sascha Brawer <brawer@dandelis.ch> | 2003-06-26 07:05:09 +0000 |
---|---|---|
committer | Sascha Brawer <brawer@dandelis.ch> | 2003-06-26 07:05:09 +0000 |
commit | 182c36fbcf7aa5c28621b2021222cbf44976b5af (patch) | |
tree | 813dd39d0b348d2dce21ede5dafd2369443b7c95 /javax | |
parent | 727429d06608c0093e4b9353682a1c5e535a947a (diff) | |
download | classpath-182c36fbcf7aa5c28621b2021222cbf44976b5af.tar.gz |
Made imports specific, reformatted, wrote JavaDoc.
modelToView: Declare to throw javax.swing.text.BadLocationException.
getToolTipText: New method.
Diffstat (limited to 'javax')
-rw-r--r-- | javax/swing/plaf/TextUI.java | 254 |
1 files changed, 233 insertions, 21 deletions
diff --git a/javax/swing/plaf/TextUI.java b/javax/swing/plaf/TextUI.java index abf5316d2..70234e62d 100644 --- a/javax/swing/plaf/TextUI.java +++ b/javax/swing/plaf/TextUI.java @@ -1,5 +1,5 @@ /* TextUI.java - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,27 +38,239 @@ exception statement from your version. */ package javax.swing.plaf; -import javax.swing.text.*; -import java.awt.*; +import java.awt.Point; +import java.awt.Rectangle; +import javax.swing.text.BadLocationException; +import javax.swing.text.EditorKit; +import javax.swing.text.JTextComponent; +import javax.swing.text.Position; +import javax.swing.text.View; -public abstract class TextUI extends ComponentUI + +/** + * An abstract base class for delegates that provide the user + * interface for text editors. + * + * @see javax.swing.text.JTextComponent + * + * @author Ronald Veldema (rveldema@cs.vu.nl) + * @author Sascha Brawer (brawer@dandelis.ch) + */ +public abstract class TextUI + extends ComponentUI { - public TextUI() - { - } - - public abstract void damageRange(JTextComponent t, int p0, int p1); - public abstract void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias); - public abstract EditorKit getEditorKit(JTextComponent t); - public abstract int getNextVisualPositionFrom(JTextComponent t, - int pos, - Position.Bias b, - int direction, - Position.Bias[] biasRet); - public abstract View getRootView(JTextComponent t); - public abstract Rectangle modelToView(JTextComponent t, int pos); - public abstract Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias); - public abstract int viewToModel(JTextComponent t, Point pt); - public abstract int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn); + /** + * Constructs a new <code>TextUI</code>. + */ + public TextUI() + { + } + + + /** + * Calculates the geometric extent of the character at the + * given offset. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param pos the zero-based index of the character into the + * document model. + * + * @return the bounding box of the character at index + * <code>pos</code>, in view coordinates. + * + * @throws BadLocationException if <code>pos</code> does not + * designate a valid position in the document model. + * + * @see javax.swing.text.View#modelToView(int, + * javax.swing.text.Position.Bias, int, + * javax.swing.text.position.Bias, java.awt.Shape) + */ + public abstract Rectangle modelToView(JTextComponent tc, int pos) + throws BadLocationException; + + + /** + * Calculates the geometric extent of the character at the + * given offset. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param pos the zero-based index of the character into the + * document model. + * + * @param bias whether to take the character before or after the + * caret position indicated by <code>pos</code>. The value + * must be either {@link + * javax.swing.text.Position.Bias#Backward} or {@link + * javax.swing.text.Position.Bias#Forward}. + * + * @return the bounding box of the character at index + * <code>pos</code>, in view coordinates. + * + * @throws BadLocationException if <code>pos</code> does not + * designate a valid position in the document model. + * + * @see javax.swing.text.View#modelToView(int, + * javax.swing.text.Position.Bias, int, + * javax.swing.text.position.Bias, java.awt.Shape) + */ + public abstract Rectangle modelToView(JTextComponent tc, int pos, + Position.Bias bias) + throws BadLocationException; + + + /** + * Finds the caret position which is closest to the specified visual + * location. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param loc the position in view coordinates. + * + * @return the caret position which is closest to <code>loc</code>. + * + * @see #viewToModel(JTextComponent, Point, Position.Bias[]) + */ + public abstract int viewToModel(JTextComponent t, Point pt); + + + /** + * Finds the caret position which is closest to the specified visual + * location. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param loc the position in view coordinates. + * + * @param outBias an array whose size must be at least one. + * After the call, <code>outBias[0]</code> will indicate + * whether <code>loc</code> is in the glyph before + * (<code>Position.Bias.Backward</code>) or after + * (<code>Position.Bias.Forward</code>) the returned + * caret position. + * + * @return the caret position which is closest to <code>loc</code>. + */ + public abstract int viewToModel(JTextComponent tc, Point loc, + Position.Bias[] outBias); + + + /** + * Calculates the caret position that is visually next to the given + * position. This is useful to determine where to move the caret + * after the user has pressed an arrow key. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param pos the current caret position, a zero-based index + * into the document model. + * + * @param bias whether to take the character before or after the + * caret position indicated by <code>pos</code>. The value + * must be either {@link + * javax.swing.text.Position.Bias#Backward} or {@link + * javax.swing.text.Position.Bias#Forward}. + * + * @param direction the visual direction. Pass + * {@link javax.swing.SwingConstants#WEST} for the left + * arrow key, {@link javax.swing.SwingConstants#EAST} + * for the right arrow key, {@link + * javax.swing.SwingConstants#NORTH} for the up arrow + * key, or {@link javax.swing.SwingConstants#SOUTH} + * for the down arrow key. + */ + public abstract int getNextVisualPositionFrom(JTextComponent tc, + int pos, + Position.Bias bias, + int direction, + Position.Bias[] outBias); + + + /** + * Repaints a range of characters. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param start the first character in the range that needs + * painting, indicated as an index into the document model. + * + * @param end the last character in the range that needs + * painting, indicated as an index into the document model. + * <code>end</code> must be greater than or equal to + * <code>start</code>. + */ + public abstract void damageRange(JTextComponent tc, int start, int end); + + + /** + * Repaints a range of characters, also specifying the bias for the + * start and end of the range. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param start the first character in the range that needs + * painting, indicated as an index into the document model. + * + * @param end the last character in the range that needs + * painting, indicated as an index into the document model. + * <code>end</code> must be greater than or equal to + * <code>start</code>. + */ + public abstract void damageRange(JTextComponent tc, + int start, int end, + Position.Bias startBias, + Position.Bias endBias); + + + /** + * Retrieves the <code>EditorKit</code> managing policies and + * persistent state. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @return the <code>EditorKit</code> used by <code>tc</code>. + */ + public abstract EditorKit getEditorKit(JTextComponent tc); + + + /** + * Retrieves the root of the view tree that visually presents + * the text. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @return the root <code>View</code> used by <code>tc</code>. + */ + public abstract View getRootView(JTextComponent tc); + + + /** + * Returns a String for presenting a tool tip at the specified + * location. + * + * @param tc the <code>JTextComponent</code> for which this + * delegate object provides the user interface. + * + * @param loc the location for which the tool tip is requested. + * + * @return the text for the tool tip, or <code>null</code> to + * display no tool tip. + * + * @since 1.4 + */ + public String getToolTipText(JTextComponent tc, Point loc) + { + return null; + } } |