PageRenderTime 81ms CodeModel.GetById 72ms app.highlight 5ms RepoModel.GetById 1ms 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
  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
 23package org.gjt.sp.jedit.textarea;
 24
 25import java.awt.Graphics2D;
 26
 27/**
 28 * Subclasses of this class can perform custom painting and tool tip
 29 * handling in the text area and gutter.
 30 *
 31 * @see TextAreaPainter#addExtension(TextAreaExtension)
 32 * @see TextAreaPainter#removeExtension(TextAreaExtension)
 33 * @see Gutter#addExtension(TextAreaExtension)
 34 * @see Gutter#removeExtension(TextAreaExtension)
 35 *
 36 * @since jEdit 4.0pre4
 37 *
 38 * @author Slava Pestov
 39 * @version $Id: TextAreaExtension.java 15570 2009-06-25 00:43:57Z ezust $
 40 */
 41public abstract class TextAreaExtension
 42{
 43	//{{{ paintScreenLineRange() method
 44	/**
 45	 * Paints a range of screen lines. The default implementation calls
 46	 * {@link #paintValidLine(Graphics2D,int,int,int,int,int)} and
 47	 * {@link #paintInvalidLine(Graphics2D,int,int)}.
 48	 * @param gfx A graphics context
 49	 * @param firstLine The first screen line
 50	 * @param lastLine The last screen line
 51	 * @param physicalLines The list of physical line numbers. Entries are
 52	 * -1 if the screen line is out of range.
 53	 * @param start An array of screen line start offsets.
 54	 * @param end An array of screen line end offsets
 55	 * @param y The y co-ordinate
 56	 * @param lineHeight The line height
 57	 * @since jEdit 4.2pre2
 58	 */
 59	public void paintScreenLineRange(Graphics2D gfx, int firstLine,
 60		int lastLine, int[] physicalLines, int[] start, int[] end,
 61		int y, int lineHeight)
 62	{
 63		for(int i = 0; i < physicalLines.length; i++)
 64		{
 65			int screenLine = i + firstLine;
 66			if(physicalLines[i] == -1)
 67				paintInvalidLine(gfx,screenLine,y);
 68			else
 69			{
 70				paintValidLine(gfx,screenLine,physicalLines[i],
 71					start[i],end[i],y);
 72			}
 73
 74			y += lineHeight;
 75		}
 76	} //}}}
 77
 78	//{{{ paintValidLine() method
 79	/**
 80	 * Called by the text area when the extension is to paint a
 81	 * screen line which has an associated physical line number in
 82	 * the buffer. Note that since one physical line may consist of
 83	 * several screen lines due to soft wrap, the start and end
 84	 * offsets of the screen line are passed in as well.
 85	 *
 86	 * @param gfx The graphics context
 87	 * @param screenLine The screen line number
 88	 * @param physicalLine The physical line number
 89	 * @param start The offset where the screen line begins, from
 90	 * the start of the buffer
 91	 * @param end The offset where the screen line ends, from the
 92	 * start of the buffer
 93	 * @param y The y co-ordinate of the top of the line's
 94	 * bounding box
 95	 * @since jEdit 4.0pre4
 96	 */
 97	public void paintValidLine(Graphics2D gfx, int screenLine,
 98		int physicalLine, int start, int end, int y) {} //}}}
 99
100	//{{{ paintInvalidLine() method
101	/**
102	 * Called by the text area when the extension is to paint a
103	 * screen line which is not part of the buffer. This can happen
104	 * if the buffer is shorter than the height of the text area,
105	 * for example.
106	 *
107	 * @param gfx The graphics context
108	 * @param screenLine The screen line number
109	 * @param y The y co-ordinate of the top of the line's
110	 * bounding box
111	 * @since jEdit 4.0pre4
112	 */
113	public void paintInvalidLine(Graphics2D gfx, int screenLine,
114		int y) {} //}}}
115
116	//{{{ getToolTipText() method
117	/**
118	 * Called by the text area when the mouse hovers over the
119	 * location specified in the mouse event.
120	 *
121	 * @param x The x co-ordinate
122	 * @param y The y co-ordinate
123	 * @since jEdit 4.0pre4
124	 */
125	public String getToolTipText(int x, int y)
126	{
127		return null;
128	} //}}}
129}