1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
40 { |
40 { |
41 /** |
41 /** |
42 * Converts the given location in the model to a place in |
42 * Converts the given location in the model to a place in |
43 * the view coordinate system. |
43 * the view coordinate system. |
44 * |
44 * |
|
45 * @param t the text component for which this UI is installed |
45 * @param pos the local location in the model to translate >= 0 |
46 * @param pos the local location in the model to translate >= 0 |
46 * @return the coordinates as a rectangle |
47 * @return the coordinates as a {@code Rectangle} |
47 * @exception BadLocationException if the given position does not |
48 * @exception BadLocationException if the given position does not |
48 * represent a valid location in the associated document |
49 * represent a valid location in the associated document |
49 */ |
50 */ |
50 public abstract Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException; |
51 public abstract Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException; |
51 |
52 |
52 /** |
53 /** |
53 * Converts the given location in the model to a place in |
54 * Converts the given location in the model to a place in |
54 * the view coordinate system. |
55 * the view coordinate system. |
55 * |
56 * |
|
57 * @param t the text component for which this UI is installed |
56 * @param pos the local location in the model to translate >= 0 |
58 * @param pos the local location in the model to translate >= 0 |
57 * @return the coordinates as a rectangle |
59 * @param bias the bias for the position |
|
60 * @return the coordinates as a {@code Rectangle} |
58 * @exception BadLocationException if the given position does not |
61 * @exception BadLocationException if the given position does not |
59 * represent a valid location in the associated document |
62 * represent a valid location in the associated document |
60 */ |
63 */ |
61 public abstract Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException; |
64 public abstract Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException; |
62 |
65 |
63 /** |
66 /** |
64 * Converts the given place in the view coordinate system |
67 * Converts the given place in the view coordinate system |
65 * to the nearest representative location in the model. |
68 * to the nearest representative location in the model. |
66 * |
69 * |
|
70 * @param t the text component for which this UI is installed |
67 * @param pt the location in the view to translate. This |
71 * @param pt the location in the view to translate. This |
68 * should be in the same coordinate system as the mouse |
72 * should be in the same coordinate system as the mouse |
69 * events. |
73 * events. |
70 * @return the offset from the start of the document >= 0 |
74 * @return the offset from the start of the document >= 0 |
71 */ |
75 */ |
73 |
77 |
74 /** |
78 /** |
75 * Provides a mapping from the view coordinate space to the logical |
79 * Provides a mapping from the view coordinate space to the logical |
76 * coordinate space of the model. |
80 * coordinate space of the model. |
77 * |
81 * |
|
82 * @param t the text component for which this UI is installed |
78 * @param pt the location in the view to translate. |
83 * @param pt the location in the view to translate. |
79 * This should be in the same coordinate system |
84 * This should be in the same coordinate system |
80 * as the mouse events. |
85 * as the mouse events. |
81 * @param biasReturn |
86 * @param biasReturn |
82 * filled in by this method to indicate whether |
87 * filled in by this method to indicate whether |
115 |
120 |
116 /** |
121 /** |
117 * Causes the portion of the view responsible for the |
122 * Causes the portion of the view responsible for the |
118 * given part of the model to be repainted. |
123 * given part of the model to be repainted. |
119 * |
124 * |
|
125 * @param t the text component for which this UI is installed |
120 * @param p0 the beginning of the range >= 0 |
126 * @param p0 the beginning of the range >= 0 |
121 * @param p1 the end of the range >= p0 |
127 * @param p1 the end of the range >= p0 |
122 */ |
128 */ |
123 public abstract void damageRange(JTextComponent t, int p0, int p1); |
129 public abstract void damageRange(JTextComponent t, int p0, int p1); |
124 |
130 |
125 /** |
131 /** |
126 * Causes the portion of the view responsible for the |
132 * Causes the portion of the view responsible for the |
127 * given part of the model to be repainted. |
133 * given part of the model to be repainted. |
128 * |
134 * |
|
135 * @param t the text component for which this UI is installed |
129 * @param p0 the beginning of the range >= 0 |
136 * @param p0 the beginning of the range >= 0 |
130 * @param p1 the end of the range >= p0 |
137 * @param p1 the end of the range >= p0 |
|
138 * @param firstBias the bias of the first character position, toward the |
|
139 * previous character or the next character |
|
140 * @param secondBias the bias of the second character position, toward the |
|
141 * previous character or the next character |
131 */ |
142 */ |
132 public abstract void damageRange(JTextComponent t, int p0, int p1, |
143 public abstract void damageRange(JTextComponent t, int p0, int p1, |
133 Position.Bias firstBias, |
144 Position.Bias firstBias, |
134 Position.Bias secondBias); |
145 Position.Bias secondBias); |
135 |
146 |
137 * Fetches the binding of services that set a policy |
148 * Fetches the binding of services that set a policy |
138 * for the type of document being edited. This contains |
149 * for the type of document being edited. This contains |
139 * things like the commands available, stream readers and |
150 * things like the commands available, stream readers and |
140 * writers, etc. |
151 * writers, etc. |
141 * |
152 * |
|
153 * @param t the text component for which this UI is installed |
142 * @return the editor kit binding |
154 * @return the editor kit binding |
143 */ |
155 */ |
144 public abstract EditorKit getEditorKit(JTextComponent t); |
156 public abstract EditorKit getEditorKit(JTextComponent t); |
145 |
157 |
146 /** |
158 /** |
147 * Fetches a View with the allocation of the associated |
159 * Fetches a View with the allocation of the associated |
148 * text component (i.e. the root of the hierarchy) that |
160 * text component (i.e. the root of the hierarchy) that |
149 * can be traversed to determine how the model is being |
161 * can be traversed to determine how the model is being |
150 * represented spatially. |
162 * represented spatially. |
151 * |
163 * |
152 * @return the view |
164 * @param t the text component for which this UI is installed |
|
165 * @return a {@code View} with the allocation of the associated |
|
166 * text component |
153 */ |
167 */ |
154 public abstract View getRootView(JTextComponent t); |
168 public abstract View getRootView(JTextComponent t); |
155 |
169 |
156 /** |
170 /** |
157 * Returns the string to be used as the tooltip at the passed in location. |
171 * Returns the string to be used as the tooltip at the passed in location. |
158 * |
172 * |
|
173 * @param t the text component for which this UI is installed |
|
174 * @param pt a {@code Point} specifying location for which to get a tooltip |
|
175 * @return a {@code String} containing the tooltip |
159 * @see javax.swing.text.JTextComponent#getToolTipText |
176 * @see javax.swing.text.JTextComponent#getToolTipText |
160 * @since 1.4 |
177 * @since 1.4 |
161 */ |
178 */ |
162 public String getToolTipText(JTextComponent t, Point pt) { |
179 public String getToolTipText(JTextComponent t, Point pt) { |
163 return null; |
180 return null; |