Source code: novaworx/textpane/SyntaxEditorKit.java
1 /*
2 Novaworx Development Environment
3 Copyright (C) 2000-2003 Mark Soderquist
4 Portions Copyright (C) 1998-2001 Slava Pestov
5 Portions Copyright (C) 1999-2000 Mike Dillon
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to:
19
20 Free Software Foundation, Inc.
21 59 Temple Place, Suite 330
22 Boston, MA 02111-1307 USA
23 */
24
25 package novaworx.textpane;
26
27 import java.awt.*;
28 import javax.swing.*;
29 import javax.swing.text.*;
30 import novaworx.syntax.*;
31 import cosmoworx.log.*;
32
33 /**
34 An implementation of <code>EditorKit</code> used for syntax highlighting.
35 It implements a view factory that maps elements to syntax highlighting
36 views.<p>
37
38 This editor kit can be plugged into text components to give them colorization features.
39
40 @author Mark Soderquist
41 @see SyntaxDocument
42 @see SyntaxView
43 */
44 public class SyntaxEditorKit extends DefaultEditorKit implements ViewFactory {
45
46 /**
47 Returns an instance of a view factory that can be used for
48 creating views from elements. This implementation returns
49 the current instance, because this class already implements
50 ViewFactory.
51 */
52 public ViewFactory getViewFactory() {
53 return this;
54 }
55
56 /**
57 Creates a new instance of the default document for this
58 editor kit. This returns a new instance of SyntaxDocument.
59 @see novaworx.textpane.SyntaxDocument
60 */
61 public Document createDefaultDocument() {
62 return new SyntaxDocument();
63 }
64
65 /**
66 Creates a view from an element that can be used for painting that
67 element. This implementation returns a new SyntaxView instance.
68 @param aoElement The element.
69 @see novaworx.textpane.SyntaxView
70 */
71 public View create( Element aoElement ) {
72 SyntaxView oView = new SyntaxView( aoElement );
73 return new SyntaxView( aoElement );
74 }
75
76 }