1 19 20 package edu.umd.cs.findbugs.sourceViewer; 21 22 import javax.swing.text.AbstractDocument ; 23 import javax.swing.text.BoxView ; 24 import javax.swing.text.ComponentView ; 25 import javax.swing.text.Element ; 26 import javax.swing.text.IconView ; 27 import javax.swing.text.LabelView ; 28 import javax.swing.text.StyleConstants ; 29 import javax.swing.text.View ; 30 import javax.swing.text.ViewFactory ; 31 32 33 class NumberedViewFactory implements ViewFactory { 34 final HighlightInformation highlight; 35 public NumberedViewFactory(HighlightInformation highlight) { 36 this.highlight = highlight; 37 } 38 39 public View create(Element elem) { 40 String kind = elem.getName(); 41 if (kind != null) 43 if (kind.equals(AbstractDocument.ContentElementName)) { 44 return new LabelView (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 (elem); 57 } 58 else if (kind.equals(StyleConstants.IconElementName)) { 59 return new IconView (elem); 60 } 61 return new LabelView (elem); 63 } 64 } 65 | Popular Tags |