PageRenderTime 90ms CodeModel.GetById 81ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 83 lines | 47 code | 8 blank | 28 comment | 4 complexity | 6da5b0aa17a2e381a30deec9fe3ef84b MD5 | raw file
 1/*
 2 * ShapedFoldPainter.java
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=0:
 5 *
 6 * Copyright (C) 2008 Shlomy Reinstein
 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
27import org.gjt.sp.jedit.buffer.JEditBuffer;
28
29// {{{ ShapedFoldPainter class
30/**
31 * Fold Painter
32 */
33public abstract class ShapedFoldPainter implements FoldPainter 
34{
35	// {{{ paintFoldEnd()
36	public void paintFoldEnd(Gutter gutter, Graphics2D gfx, int screenLine,
37			int physicalLine, int y, int lineHeight, JEditBuffer buffer)
38	{
39		gfx.setColor(gutter.getFoldColor());
40		int _y = y + lineHeight / 2;
41		int _x = 5;
42		gfx.drawLine(_x,y,_x,_y+3);
43		gfx.drawLine(_x,_y+3,_x+4,_y+3);
44		boolean nested = (physicalLine < buffer.getLineCount() - 1 &&
45			buffer.getFoldLevel(physicalLine + 1) > 0);
46		if (nested)
47			gfx.drawLine(_x,y+4,_x,y+lineHeight-1);
48	}// }}}
49
50	// {{{ paintFoldMiddle()
51	public void paintFoldMiddle(Gutter gutter, Graphics2D gfx, int screenLine,
52			int physicalLine, int y, int lineHeight, JEditBuffer buffer)
53	{
54		gfx.setColor(gutter.getFoldColor());
55		gfx.drawLine(5,y,5,y+lineHeight-1);
56	}// }}}
57
58	// {{{ paintFoldStart()
59	public void paintFoldStart(Gutter gutter, Graphics2D gfx, int screenLine,
60			int physicalLine, boolean nextLineVisible, int y, int lineHeight,
61			JEditBuffer buffer)
62	{
63		int _y = y + lineHeight / 2;
64		int _x = 5;
65		gfx.setColor(gutter.getFoldColor());
66		paintFoldShape(gfx, _y - 4, _y + 4);
67		gfx.drawLine(_x-2,_y,_x+2,_y);
68		boolean nested = (buffer.getFoldLevel(physicalLine) > 0);
69		if (nested)
70			gfx.drawLine(_x,y,_x,_y-5);
71		if (nextLineVisible)
72			gfx.drawLine(_x,_y+5,_x,y+lineHeight-1);
73		else
74		{
75			gfx.drawLine(_x,_y-2,_x,_y+2);
76			if (nested)
77				gfx.drawLine(_x,_y+4,_x,y+lineHeight-1);
78		}
79	}// }}}
80
81	protected abstract void paintFoldShape(Graphics2D gfx, int top, int bottom);
82
83} // }}}