KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: AlternateRowsElement.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.Map JavaDoc;
11
12 import org.w3c.dom.Element JavaDoc;
13 import net.openmarkup.AttributeHandler;
14 import net.openmarkup.ElementType;
15 import org.jdesktop.jdnc.markup.Attributes;
16 import org.jdesktop.jdnc.markup.Namespace;
17 import org.jdesktop.jdnc.markup.attr.*;
18
19 /**
20  *
21  * @author Ramesh Gupta
22  */

23 public class AlternateRowsElement extends HighlighterElement {
24     public AlternateRowsElement(Element JavaDoc element, ElementType elementType) {
25         super(element, elementType);
26     }
27
28     protected void applyAttributesAfter() {
29         super.applyAttributesAfter();
30         applyAttribute(Namespace.JDNC, Attributes.ODD_ROW_BACKGROUND);
31         applyAttribute(Namespace.JDNC, Attributes.EVEN_ROW_BACKGROUND);
32     }
33
34     protected Map JavaDoc registerAttributeHandlers() {
35         Map JavaDoc handlerMap = super.registerAttributeHandlers();
36         if (handlerMap != null) {
37             handlerMap.put(Namespace.JDNC + ":" +
38                            Attributes.EVEN_ROW_BACKGROUND,
39                            evenRowBackgroundAttrHandler);
40             handlerMap.put(Namespace.JDNC + ":" + Attributes.ODD_ROW_BACKGROUND,
41                            oddRowBackgroundAttrHandler);
42         }
43         return handlerMap;
44     }
45
46     private static final AttributeHandler evenRowBackgroundAttrHandler =
47         new AttributeHandler(Namespace.JDNC, Attributes.EVEN_ROW_BACKGROUND,
48                              HighlighterAttributes.evenRowBackgroundApplier);
49     private static final AttributeHandler oddRowBackgroundAttrHandler =
50         new AttributeHandler(Namespace.JDNC, Attributes.ODD_ROW_BACKGROUND,
51                              HighlighterAttributes.oddRowBackgroundApplier);
52 }
53
Popular Tags