KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > TextUI


1 /*
2  * @(#)TextUI.java 1.32 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.plaf;
8
9 import javax.swing.Action JavaDoc;
10 import javax.swing.BoundedRangeModel JavaDoc;
11 import java.awt.Point JavaDoc;
12 import java.awt.Rectangle JavaDoc;
13 import java.awt.Insets JavaDoc;
14 import javax.swing.text.*;
15
16 /**
17  * Text editor user interface
18  *
19  * @author Timothy Prinzing
20  * @version 1.32 12/19/03
21  */

22 public abstract class TextUI extends ComponentUI JavaDoc
23 {
24     /**
25      * Converts the given location in the model to a place in
26      * the view coordinate system.
27      *
28      * @param pos the local location in the model to translate >= 0
29      * @return the coordinates as a rectangle
30      * @exception BadLocationException if the given position does not
31      * represent a valid location in the associated document
32      */

33     public abstract Rectangle JavaDoc modelToView(JTextComponent t, int pos) throws BadLocationException;
34
35     /**
36      * Converts the given location in the model to a place in
37      * the view coordinate system.
38      *
39      * @param pos the local location in the model to translate >= 0
40      * @return the coordinates as a rectangle
41      * @exception BadLocationException if the given position does not
42      * represent a valid location in the associated document
43      */

44     public abstract Rectangle JavaDoc modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException;
45
46     /**
47      * Converts the given place in the view coordinate system
48      * to the nearest representative location in the model.
49      *
50      * @param pt the location in the view to translate. This
51      * should be in the same coordinate system as the mouse
52      * events.
53      * @return the offset from the start of the document >= 0
54      */

55     public abstract int viewToModel(JTextComponent t, Point JavaDoc pt);
56
57     /**
58      * Provides a mapping from the view coordinate space to the logical
59      * coordinate space of the model.
60      *
61      * @param pt the location in the view to translate.
62      * This should be in the same coordinate system
63      * as the mouse events.
64      * @param biasReturn
65      * filled in by this method to indicate whether
66      * the point given is closer to the previous or the next
67      * character in the model
68      *
69      * @return the location within the model that best represents the
70      * given point in the view >= 0
71      */

72     public abstract int viewToModel(JTextComponent t, Point JavaDoc pt,
73                     Position.Bias[] biasReturn);
74
75     /**
76      * Provides a way to determine the next visually represented model
77      * location that one might place a caret. Some views may not be visible,
78      * they might not be in the same order found in the model, or they just
79      * might not allow access to some of the locations in the model.
80      *
81      * @param pos the position to convert >= 0
82      * @param a the allocated region to render into
83      * @param direction the direction from the current position that can
84      * be thought of as the arrow keys typically found on a keyboard.
85      * This may be SwingConstants.WEST, SwingConstants.EAST,
86      * SwingConstants.NORTH, or SwingConstants.SOUTH.
87      * @return the location within the model that best represents the next
88      * location visual position.
89      * @exception BadLocationException
90      * @exception IllegalArgumentException for an invalid direction
91      */

92     public abstract int getNextVisualPositionFrom(JTextComponent t,
93              int pos, Position.Bias b,
94              int direction, Position.Bias[] biasRet)
95                      throws BadLocationException;
96
97     /**
98      * Causes the portion of the view responsible for the
99      * given part of the model to be repainted.
100      *
101      * @param p0 the beginning of the range >= 0
102      * @param p1 the end of the range >= p0
103      */

104     public abstract void damageRange(JTextComponent t, int p0, int p1);
105
106     /**
107      * Causes the portion of the view responsible for the
108      * given part of the model to be repainted.
109      *
110      * @param p0 the beginning of the range >= 0
111      * @param p1 the end of the range >= p0
112      */

113     public abstract void damageRange(JTextComponent t, int p0, int p1,
114                      Position.Bias firstBias,
115                      Position.Bias secondBias);
116
117     /**
118      * Fetches the binding of services that set a policy
119      * for the type of document being edited. This contains
120      * things like the commands available, stream readers and
121      * writers, etc.
122      *
123      * @return the editor kit binding
124      */

125     public abstract EditorKit getEditorKit(JTextComponent t);
126
127     /**
128      * Fetches a View with the allocation of the associated
129      * text component (i.e. the root of the hierarchy) that
130      * can be traversed to determine how the model is being
131      * represented spatially.
132      *
133      * @return the view
134      */

135     public abstract View getRootView(JTextComponent t);
136
137     /**
138      * Returns the string to be used as the tooltip at the passed in location.
139      *
140      * @see javax.swing.text.JTextComponent#getToolTipText
141      * @since 1.4
142      */

143     public String JavaDoc getToolTipText(JTextComponent t, Point JavaDoc pt) {
144         return null;
145     }
146 }
147
Popular Tags