KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > sourceViewer > NumberedViewFactory


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307, USA
18  */

19
20 package edu.umd.cs.findbugs.sourceViewer;
21
22 import javax.swing.text.AbstractDocument JavaDoc;
23 import javax.swing.text.BoxView JavaDoc;
24 import javax.swing.text.ComponentView JavaDoc;
25 import javax.swing.text.Element JavaDoc;
26 import javax.swing.text.IconView JavaDoc;
27 import javax.swing.text.LabelView JavaDoc;
28 import javax.swing.text.StyleConstants JavaDoc;
29 import javax.swing.text.View JavaDoc;
30 import javax.swing.text.ViewFactory JavaDoc;
31
32
33 class NumberedViewFactory implements ViewFactory JavaDoc {
34     final HighlightInformation highlight;
35     public NumberedViewFactory(HighlightInformation highlight) {
36         this.highlight = highlight;
37     }
38
39     public View JavaDoc create(Element JavaDoc elem) {
40         String JavaDoc kind = elem.getName();
41        // System.out.println("Kind: " + kind);
42
if (kind != null)
43             if (kind.equals(AbstractDocument.ContentElementName)) {
44                 return new LabelView JavaDoc(elem);
45             }
46             else if (kind.equals(AbstractDocument.
47                              ParagraphElementName)) {
48                 return new NumberedParagraphView(elem, highlight);
49             }
50             else if (kind.equals(AbstractDocument.
51                      SectionElementName)) {
52                 return new NoWrapBoxView(elem, View.Y_AXIS);
53             }
54             else if (kind.equals(StyleConstants.
55                      ComponentElementName)) {
56                 return new ComponentView JavaDoc(elem);
57             }
58             else if (kind.equals(StyleConstants.IconElementName)) {
59                 return new IconView JavaDoc(elem);
60             }
61         // default to text display
62
return new LabelView JavaDoc(elem);
63     }
64 }
65
Popular Tags