KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > IPainter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jface.text;
13
14
15 /**
16  * A painter is responsible for creating, managing, updating, and removing
17  * visual decorations on an <code>ITextViewer</code>'s text widget. Examples
18  * are the highlighting of the caret line, the print margin, or the highlighting
19  * of matching peer characters such as pairs of brackets.</p>
20  * <p>
21  * Clients may implement this interface.</p>
22  * <p>
23  * Painters should be registered with a
24  * {@link org.eclipse.jface.text.PaintManager}. The paint manager tracks
25  * several classes of events issued by an <code>ITextViewer</code> and reacts
26  * by appropriately invoking the registered painters.
27  * <p>
28  * Painters are either active or inactive. Usually, painters are initially
29  * inactive and are activated by the first call to their <code>paint</code>
30  * method. Painters can be deactivated by calling <code>deactivate</code>.
31  * Inactive painter can be reactivated by calling <code>paint</code>.
32  * <p>
33  * Painters usually have to manage state information. E.g., a painter painting a
34  * caret line highlight must redraw the previous and the actual caret line in
35  * the advent of a change of the caret position. This state information must be
36  * adapted to changes of the viewer's content. In order to support this common
37  * scenario, the <code>PaintManager</code> gives a painter access to a
38  * {@link org.eclipse.jface.text.IPaintPositionManager}. The painter can use
39  * this updater to manage its state information.
40  * <p>
41  *
42  * @see org.eclipse.jface.text.PaintManager
43  * @see org.eclipse.jface.text.IPaintPositionManager
44  * @since 2.1
45  */

46 public interface IPainter {
47
48     /**
49      * Constant describing the reason of a repaint request: selection changed.
50      */

51     int SELECTION= 0;
52     /**
53      * Constant describing the reason of a repaint request: text changed.
54      */

55     int TEXT_CHANGE= 1;
56     /**
57      * Constant describing the reason of a repaint request: key pressed.
58      */

59     int KEY_STROKE= 2;
60     /**
61      * Constant describing the reason of a repaint request: mouse button pressed.
62      */

63     int MOUSE_BUTTON= 4;
64     /**
65      * Constant describing the reason of a repaint request: paint manager internal change.
66      */

67     int INTERNAL= 8;
68     /**
69      * Constant describing the reason of a repaint request: paint manager or painter configuration changed.
70      */

71     int CONFIGURATION= 16;
72
73
74     /**
75      * Disposes this painter. Prior to disposing, a painter should be deactivated. A disposed
76      * painter can not be reactivated.
77      *
78      * @see #deactivate(boolean)
79      */

80     void dispose();
81
82     /**
83      * Requests this painter to repaint because of the given reason. Based on
84      * the given reason the painter can decide whether it will repaint or not.
85      * If it repaints and is inactive, it will activate itself.
86      *
87      * @param reason the repaint reason, value is one of the constants defined
88      * in this interface
89      */

90     void paint(int reason);
91
92     /**
93      * Deactivates this painter. If the painter is inactive, this call does not
94      * have any effect. <code>redraw</code> indicates whether the painter
95      * should remove any decoration it previously applied. A deactivated painter
96      * can be reactivated by calling <code>paint</code>.
97      *
98      * @param redraw <code>true</code> if any previously applied decoration
99      * should be removed
100      * @see #paint(int)
101      */

102     void deactivate(boolean redraw);
103
104     /**
105      * Sets the paint position manager that can be used by this painter or removes any previously
106      * set paint position manager.
107      *
108      * @param manager the paint position manager or <code>null</code>
109      */

110     void setPositionManager(IPaintPositionManager manager);
111 }
112
Popular Tags