KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdnc > markup > elem > HighlighterElement


1 /*
2  * $Id: HighlighterElement.java,v 1.1.1.1 2004/06/16 01:43:40 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.jdnc.markup.elem;
9
10 import java.util.Hashtable JavaDoc;
11 import java.util.Map JavaDoc;
12
13 import org.w3c.dom.Element JavaDoc;
14 import net.openmarkup.AttributeHandler;
15 import net.openmarkup.ElementType;
16 import org.jdesktop.jdnc.markup.Attributes;
17 import org.jdesktop.jdnc.markup.Namespace;
18 import org.jdesktop.jdnc.markup.attr.*;
19
20 /**
21  *
22  * @author Ramesh Gupta
23  */

24 public class HighlighterElement extends ElementProxy {
25     private static final Map JavaDoc attrMap = new Hashtable JavaDoc();
26
27     public HighlighterElement(Element JavaDoc element, ElementType elementType) {
28         super(element, elementType);
29     }
30
31     protected void applyAttributesAfter() {
32         super.applyAttributesAfter();
33         applyAttribute(Namespace.JDNC, Attributes.BACKGROUND);
34         applyAttribute(Namespace.JDNC, Attributes.FOREGROUND);
35         applyAttribute(Namespace.JDNC, Attributes.SELECTED_BACKGROUND);
36         applyAttribute(Namespace.JDNC, Attributes.SELECTED_FOREGROUND);
37     }
38
39     protected Map JavaDoc registerAttributeHandlers() {
40         Map JavaDoc handlerMap = super.registerAttributeHandlers();
41         if (handlerMap != null) {
42             handlerMap.put(Namespace.JDNC + ":" + Attributes.BACKGROUND,
43                            backgroundAttrHandler);
44             handlerMap.put(Namespace.JDNC + ":" + Attributes.FOREGROUND,
45                            foregroundAttrHandler);
46         }
47         return handlerMap;
48     }
49
50     protected Map JavaDoc getAttributeHandlerMap() {
51         return attrMap;
52     }
53
54     private static final AttributeHandler backgroundAttrHandler =
55         new AttributeHandler(Namespace.JDNC, Attributes.BACKGROUND, HighlighterAttributes.backgroundApplier);
56
57     private static final AttributeHandler foregroundAttrHandler =
58         new AttributeHandler(Namespace.JDNC, Attributes.FOREGROUND, HighlighterAttributes.foregroundApplier);
59
60     private static final AttributeHandler selectedBackgroundAttrHandler =
61         new AttributeHandler(Namespace.JDNC, Attributes.SELECTED_BACKGROUND, HighlighterAttributes.selectedBackgroundApplier);
62
63     private static final AttributeHandler selectedForegroundAttrHandler =
64         new AttributeHandler(Namespace.JDNC, Attributes.SELECTED_FOREGROUND, HighlighterAttributes.selectedForegroundApplier);
65
66 }
67
Popular Tags