1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
294 * offset into the text >= 0.
295 * @param e how to expand the tabs. If this value is null,
296 * tabs will be expanded as a space character.
297 * @param startOffset starting offset of the text in the document >= 0
298 * @return the offset into the text >= 0
299 */
300 public static final int getTabbedTextOffset(Segment s, FontMetrics metrics,
301 int x0, int x, TabExpander e,
302 int startOffset) {
303 return getTabbedTextOffset(s, metrics, x0, x, e, startOffset, true);
304 }
305
306 static final int getTabbedTextOffset(View view, Segment s, FontMetrics metrics,
307 int x0, int x, TabExpander e,
308 int startOffset,
309 int[] justificationData) {
310 return getTabbedTextOffset(view, s, metrics, x0, x, e, startOffset, true,
311 justificationData);
312 }
313
314 public static final int getTabbedTextOffset(Segment s,
315 FontMetrics metrics,
316 int x0, int x, TabExpander e,
317 int startOffset,
318 boolean round) {
319 return getTabbedTextOffset(null, s, metrics, x0, x, e, startOffset, round, null);
320 }
321
322 // In addition to the previous method it can extend spaces for
323 // justification.
324 //
325 // all params are the same as in the preious method except the last
326 // one:
327 // @param justificationData justificationData for the row.
328 // if null not justification is needed
329 static final int getTabbedTextOffset(View view,
330 Segment s,
331 FontMetrics metrics,
332 int x0, int x, TabExpander e,
333 int startOffset,
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
294 * offset into the text >= 0.
295 * @param e how to expand the tabs. If this value is null,
296 * tabs will be expanded as a space character.
297 * @param startOffset starting offset of the text in the document >= 0
298 * @return the offset into the text >= 0
299 */
300 public static final int getTabbedTextOffset(Segment s, FontMetrics metrics,
301 int x0, int x, TabExpander e,
302 int startOffset) {
303 return getTabbedTextOffset(s, metrics, x0, x, e, startOffset, true);
304 }
305
306 static final int getTabbedTextOffset(View view, Segment s, FontMetrics metrics,
307 int x0, int x, TabExpander e,
308 int startOffset,
309 int[] justificationData) {
310 return getTabbedTextOffset(view, s, metrics, x0, x, e, startOffset, true,
311 justificationData);
312 }
313
314 /**
315 * Determines the relative offset into the given text that
316 * best represents the given span in the view coordinate
317 * system.
318 *
319 * @param s the source of the text
320 * @param metrics the font metrics to use for the calculation
321 * @param x0 the starting view location representing the start
322 * of the given text >= 0.
323 * @param x the target view location to translate to an
324 * offset into the text >= 0.
325 * @param e how to expand the tabs. If this value is null,
326 * tabs will be expanded as a space character.
327 * @param startOffset starting offset of the text in the document >= 0
328 * @param round whether or not to round
329 * @return the offset into the text >= 0
330 */
331 public static final int getTabbedTextOffset(Segment s,
332 FontMetrics metrics,
333 int x0, int x, TabExpander e,
334 int startOffset,
335 boolean round) {
336 return getTabbedTextOffset(null, s, metrics, x0, x, e, startOffset, round, null);
337 }
338
339 // In addition to the previous method it can extend spaces for
340 // justification.
341 //
342 // all params are the same as in the preious method except the last
343 // one:
344 // @param justificationData justificationData for the row.
345 // if null not justification is needed
346 static final int getTabbedTextOffset(View view,
347 Segment s,
348 FontMetrics metrics,
349 int x0, int x, TabExpander e,
350 int startOffset,
|