1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import java.util.Hashtable ; 11 import java.util.Map ; 12 13 import org.w3c.dom.Element ; 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 24 public class HighlighterElement extends ElementProxy { 25 private static final Map attrMap = new Hashtable (); 26 27 public HighlighterElement(Element 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 registerAttributeHandlers() { 40 Map 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 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 |