PageRenderTime 48ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/textarea/TextAreaExtension.java

#
Java | 129 lines | 30 code | 7 blank | 92 comment | 3 complexity | 0823a5c0a857b734e89523a369bca36d MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * TextAreaExtension.java - Custom painter and tool tip handler
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2002 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit.textarea;
  23. import java.awt.Graphics2D;
  24. /**
  25. * Subclasses of this class can perform custom painting and tool tip
  26. * handling in the text area and gutter.
  27. *
  28. * @see TextAreaPainter#addExtension(TextAreaExtension)
  29. * @see TextAreaPainter#removeExtension(TextAreaExtension)
  30. * @see Gutter#addExtension(TextAreaExtension)
  31. * @see Gutter#removeExtension(TextAreaExtension)
  32. *
  33. * @since jEdit 4.0pre4
  34. *
  35. * @author Slava Pestov
  36. * @version $Id: TextAreaExtension.java 15570 2009-06-25 00:43:57Z ezust $
  37. */
  38. public abstract class TextAreaExtension
  39. {
  40. //{{{ paintScreenLineRange() method
  41. /**
  42. * Paints a range of screen lines. The default implementation calls
  43. * {@link #paintValidLine(Graphics2D,int,int,int,int,int)} and
  44. * {@link #paintInvalidLine(Graphics2D,int,int)}.
  45. * @param gfx A graphics context
  46. * @param firstLine The first screen line
  47. * @param lastLine The last screen line
  48. * @param physicalLines The list of physical line numbers. Entries are
  49. * -1 if the screen line is out of range.
  50. * @param start An array of screen line start offsets.
  51. * @param end An array of screen line end offsets
  52. * @param y The y co-ordinate
  53. * @param lineHeight The line height
  54. * @since jEdit 4.2pre2
  55. */
  56. public void paintScreenLineRange(Graphics2D gfx, int firstLine,
  57. int lastLine, int[] physicalLines, int[] start, int[] end,
  58. int y, int lineHeight)
  59. {
  60. for(int i = 0; i < physicalLines.length; i++)
  61. {
  62. int screenLine = i + firstLine;
  63. if(physicalLines[i] == -1)
  64. paintInvalidLine(gfx,screenLine,y);
  65. else
  66. {
  67. paintValidLine(gfx,screenLine,physicalLines[i],
  68. start[i],end[i],y);
  69. }
  70. y += lineHeight;
  71. }
  72. } //}}}
  73. //{{{ paintValidLine() method
  74. /**
  75. * Called by the text area when the extension is to paint a
  76. * screen line which has an associated physical line number in
  77. * the buffer. Note that since one physical line may consist of
  78. * several screen lines due to soft wrap, the start and end
  79. * offsets of the screen line are passed in as well.
  80. *
  81. * @param gfx The graphics context
  82. * @param screenLine The screen line number
  83. * @param physicalLine The physical line number
  84. * @param start The offset where the screen line begins, from
  85. * the start of the buffer
  86. * @param end The offset where the screen line ends, from the
  87. * start of the buffer
  88. * @param y The y co-ordinate of the top of the line's
  89. * bounding box
  90. * @since jEdit 4.0pre4
  91. */
  92. public void paintValidLine(Graphics2D gfx, int screenLine,
  93. int physicalLine, int start, int end, int y) {} //}}}
  94. //{{{ paintInvalidLine() method
  95. /**
  96. * Called by the text area when the extension is to paint a
  97. * screen line which is not part of the buffer. This can happen
  98. * if the buffer is shorter than the height of the text area,
  99. * for example.
  100. *
  101. * @param gfx The graphics context
  102. * @param screenLine The screen line number
  103. * @param y The y co-ordinate of the top of the line's
  104. * bounding box
  105. * @since jEdit 4.0pre4
  106. */
  107. public void paintInvalidLine(Graphics2D gfx, int screenLine,
  108. int y) {} //}}}
  109. //{{{ getToolTipText() method
  110. /**
  111. * Called by the text area when the mouse hovers over the
  112. * location specified in the mouse event.
  113. *
  114. * @param x The x co-ordinate
  115. * @param y The y co-ordinate
  116. * @since jEdit 4.0pre4
  117. */
  118. public String getToolTipText(int x, int y)
  119. {
  120. return null;
  121. } //}}}
  122. }