221 |
if (childIndex != -1) |
if (childIndex != -1) |
222 |
{ |
{ |
223 |
View child = getView(childIndex); |
View child = getView(childIndex); |
224 |
Shape result = child.modelToView(pos, a, bias); |
Rectangle r = a.getBounds(); |
225 |
|
childAllocation(childIndex, r); |
226 |
|
Shape result = child.modelToView(pos, r, bias); |
227 |
if (result == null) |
if (result == null) |
228 |
throw new AssertionError("" + child.getClass().getName() |
throw new AssertionError("" + child.getClass().getName() |
229 |
+ ".modelToView() must not return null"); |
+ ".modelToView() must not return null"); |
230 |
return result; |
return result; |
231 |
} |
} |
232 |
else |
else |
233 |
{ |
throw new BadLocationException("No child view for the specified location", |
234 |
// FIXME: Handle the case when we have no child view for the given |
pos); |
|
// position. |
|
|
throw new AssertionError("No child views found where child views are " |
|
|
+ "expected. pos = " + pos + ", bias = " |
|
|
+ bias); |
|
|
} |
|
235 |
} |
} |
236 |
|
|
237 |
/** |
/** |
264 |
* Maps coordinates from the <code>View</code>'s space into a position |
* Maps coordinates from the <code>View</code>'s space into a position |
265 |
* in the document model. |
* in the document model. |
266 |
* |
* |
267 |
* @param x the x coordinate in the view space |
* @param x the x coordinate in the view space, x >= 0 |
268 |
* @param y the y coordinate in the view space |
* @param y the y coordinate in the view space, y >= 0 |
269 |
* @param a the allocation of this <code>View</code> |
* @param a the allocation of this <code>View</code> |
270 |
* @param b the bias to use |
* @param b the bias to use |
271 |
* |
* |
272 |
* @return the position in the document that corresponds to the screen |
* @return the position in the document that corresponds to the screen |
273 |
* coordinates <code>x, y</code> |
* coordinates <code>x, y</code> >= 0 |
274 |
*/ |
*/ |
275 |
public int viewToModel(float x, float y, Shape a, Position.Bias[] b) |
public int viewToModel(float x, float y, Shape a, Position.Bias[] b) |
276 |
{ |
{ |
277 |
Rectangle r = getInsideAllocation(a); |
if (x >= 0 && y >= 0) |
278 |
View view = getViewAtPoint((int) x, (int) y, r); |
{ |
279 |
return view.viewToModel(x, y, a, b); |
Rectangle r = getInsideAllocation(a); |
280 |
|
View view = getViewAtPoint((int) x, (int) y, r); |
281 |
|
return view.viewToModel(x, y, a, b); |
282 |
|
} |
283 |
|
return 0; |
284 |
} |
} |
285 |
|
|
286 |
/** |
/** |
287 |
* Returns the next model location that is visible in eiter north / south |
* Returns the next model location that is visible in eiter north / south |
288 |
* direction or east / west direction. This is used to determine the |
* direction or east / west direction. This is used to determine the placement |
289 |
* placement of the caret when navigating around the document with |
* of the caret when navigating around the document with the arrow keys. This |
290 |
* the arrow keys. |
* is a convenience method for {@link #getNextNorthSouthVisualPositionFrom} |
291 |
* |
* and {@link #getNextEastWestVisualPositionFrom}. |
292 |
* This is a convenience method for |
* |
293 |
* {@link #getNextNorthSouthVisualPositionFrom} and |
* @param pos |
294 |
* {@link #getNextEastWestVisualPositionFrom}. |
* the model position to start search from |
295 |
* |
* @param b |
296 |
* @param pos the model position to start search from |
* the bias for <code>pos</code> |
297 |
* @param b the bias for <code>pos</code> |
* @param a |
298 |
* @param a the allocated region for this view |
* the allocated region for this view |
299 |
* @param direction the direction from the current position, can be one of |
* @param direction |
300 |
* the following: |
* the direction from the current position, can be one of the |
301 |
* <ul> |
* following: |
302 |
* <li>{@link SwingConstants#WEST}</li> |
* <ul> |
303 |
* <li>{@link SwingConstants#EAST}</li> |
* <li>{@link SwingConstants#WEST}</li> |
304 |
* <li>{@link SwingConstants#NORTH}</li> |
* <li>{@link SwingConstants#EAST}</li> |
305 |
* <li>{@link SwingConstants#SOUTH}</li> |
* <li>{@link SwingConstants#NORTH}</li> |
306 |
* </ul> |
* <li>{@link SwingConstants#SOUTH}</li> |
307 |
* @param biasRet the bias of the return value gets stored here |
* </ul> |
308 |
* |
* @param biasRet |
309 |
|
* the bias of the return value gets stored here |
310 |
* @return the position inside the model that represents the next visual |
* @return the position inside the model that represents the next visual |
311 |
* location |
* location |
312 |
* |
* @throws BadLocationException |
313 |
* @throws BadLocationException if <code>pos</code> is not a valid location |
* if <code>pos</code> is not a valid location inside the document |
314 |
* inside the document model |
* model |
315 |
* @throws IllegalArgumentException if <code>direction</code> is invalid |
* @throws IllegalArgumentException |
316 |
|
* if <code>direction</code> is invalid |
317 |
*/ |
*/ |
318 |
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, |
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, |
319 |
int direction, Position.Bias[] biasRet) |
int direction, Position.Bias[] biasRet) |