View Javadoc

1   /*
2    * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /* $Id: Mtd.java,v bc1d5fde7b73 2009/06/01 14:40:54 maxberger $ */
18  
19  package net.sourceforge.jeuclid.elements.presentation.table;
20  
21  import org.apache.batik.dom.AbstractDocument;
22  import org.w3c.dom.Node;
23  import org.w3c.dom.mathml.MathMLTableCellElement;
24  
25  /**
26   * This class presents a cell of a table.
27   * 
28   * @version $Revision: bc1d5fde7b73 $
29   */
30  public final class Mtd extends AbstractTableElement implements
31          MathMLTableCellElement {
32  
33      /**
34       * The XML element from this class.
35       */
36      public static final String ELEMENT = "mtd";
37  
38      /** attribute for rowspan. */
39      private static final String ATTR_ROWSPAN = "rowspan";
40  
41      /** attribute for columnspan. */
42      private static final String ATTR_COLUMNSPAN = "columnspan";
43  
44      private static final String VALUE_ONE = "1";
45  
46      private static final long serialVersionUID = 1L;
47  
48      /**
49       * Default constructor. Sets MathML Namespace.
50       * 
51       * @param qname
52       *            Qualified name.
53       * @param odoc
54       *            Owner Document.
55       */
56      public Mtd(final String qname, final AbstractDocument odoc) {
57          super(qname, odoc);
58  
59          this.setDefaultMathAttribute(Mtd.ATTR_ROWSPAN, Mtd.VALUE_ONE);
60          this.setDefaultMathAttribute(Mtd.ATTR_COLUMNSPAN, Mtd.VALUE_ONE);
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      protected Node newNode() {
66          return new Mtd(this.nodeName, this.ownerDocument);
67      }
68  
69      /**
70       * @return Rowspan
71       */
72      public String getRowspan() {
73          return this.getMathAttribute(Mtd.ATTR_ROWSPAN);
74      }
75  
76      /**
77       * @param rowspan
78       *            Rowspan
79       */
80      public void setRowspan(final String rowspan) {
81          this.setAttribute(Mtd.ATTR_ROWSPAN, rowspan);
82      }
83  
84      /**
85       * @return Columnspan
86       */
87      public String getColumnspan() {
88          return this.getMathAttribute(Mtd.ATTR_COLUMNSPAN);
89      }
90  
91      /**
92       * @param columnspan
93       *            Columnspan
94       */
95      public void setColumnspan(final String columnspan) {
96          this.setAttribute(Mtd.ATTR_COLUMNSPAN, columnspan);
97      }
98  
99      /** {@inheritDoc} */
100     public String getCellindex() {
101         return Integer.toString(this.getParent().getIndexOfMathElement(this));
102     }
103 
104     /** {@inheritDoc} */
105     public boolean getHasaligngroups() {
106         return this.getGroupalign() != null;
107     }
108 
109 }