449 } else {
450 tabSize = getTabSize() * metrics.charWidth('m');
451 }
452 }
453
454 // --- TabExpander methods ------------------------------------------
455
456 /**
457 * Returns the next tab stop position after a given reference position.
458 * This implementation does not support things like centering so it
459 * ignores the tabOffset argument.
460 *
461 * @param x the current position >= 0
462 * @param tabOffset the position within the text stream
463 * that the tab occurred at >= 0.
464 * @return the tab stop, measured in points >= 0
465 */
466 public float nextTabStop(float x, int tabOffset) {
467 if (tabSize == 0)
468 return x;
469 float ntabs = (x - tabBase) / tabSize;
470 return tabBase + ((ntabs + 1) * tabSize);
471 }
472
473
474 // --- View methods -------------------------------------
475
476 /**
477 * Renders using the given rendering surface and area
478 * on that surface. This is implemented to stash the
479 * selection positions, selection colors, and font
480 * metrics for the nested lines to use.
481 *
482 * @param g the rendering surface to use
483 * @param a the allocated region to render into
484 *
485 * @see View#paint
486 */
487 public void paint(Graphics g, Shape a) {
488 Rectangle alloc = (Rectangle) a;
489 tabBase = alloc.x;
|
449 } else {
450 tabSize = getTabSize() * metrics.charWidth('m');
451 }
452 }
453
454 // --- TabExpander methods ------------------------------------------
455
456 /**
457 * Returns the next tab stop position after a given reference position.
458 * This implementation does not support things like centering so it
459 * ignores the tabOffset argument.
460 *
461 * @param x the current position >= 0
462 * @param tabOffset the position within the text stream
463 * that the tab occurred at >= 0.
464 * @return the tab stop, measured in points >= 0
465 */
466 public float nextTabStop(float x, int tabOffset) {
467 if (tabSize == 0)
468 return x;
469 int ntabs = (int) ((x - tabBase) / tabSize);
470 return tabBase + ((ntabs + 1) * tabSize);
471 }
472
473
474 // --- View methods -------------------------------------
475
476 /**
477 * Renders using the given rendering surface and area
478 * on that surface. This is implemented to stash the
479 * selection positions, selection colors, and font
480 * metrics for the nested lines to use.
481 *
482 * @param g the rendering surface to use
483 * @param a the allocated region to render into
484 *
485 * @see View#paint
486 */
487 public void paint(Graphics g, Shape a) {
488 Rectangle alloc = (Rectangle) a;
489 tabBase = alloc.x;
|