001 /*
002 * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: Mtd.java,v bc1d5fde7b73 2009/06/01 14:40:54 maxberger $ */
018
019 package net.sourceforge.jeuclid.elements.presentation.table;
020
021 import org.apache.batik.dom.AbstractDocument;
022 import org.w3c.dom.Node;
023 import org.w3c.dom.mathml.MathMLTableCellElement;
024
025 /**
026 * This class presents a cell of a table.
027 *
028 * @version $Revision: bc1d5fde7b73 $
029 */
030 public final class Mtd extends AbstractTableElement implements
031 MathMLTableCellElement {
032
033 /**
034 * The XML element from this class.
035 */
036 public static final String ELEMENT = "mtd";
037
038 /** attribute for rowspan. */
039 private static final String ATTR_ROWSPAN = "rowspan";
040
041 /** attribute for columnspan. */
042 private static final String ATTR_COLUMNSPAN = "columnspan";
043
044 private static final String VALUE_ONE = "1";
045
046 private static final long serialVersionUID = 1L;
047
048 /**
049 * Default constructor. Sets MathML Namespace.
050 *
051 * @param qname
052 * Qualified name.
053 * @param odoc
054 * Owner Document.
055 */
056 public Mtd(final String qname, final AbstractDocument odoc) {
057 super(qname, odoc);
058
059 this.setDefaultMathAttribute(Mtd.ATTR_ROWSPAN, Mtd.VALUE_ONE);
060 this.setDefaultMathAttribute(Mtd.ATTR_COLUMNSPAN, Mtd.VALUE_ONE);
061 }
062
063 /** {@inheritDoc} */
064 @Override
065 protected Node newNode() {
066 return new Mtd(this.nodeName, this.ownerDocument);
067 }
068
069 /**
070 * @return Rowspan
071 */
072 public String getRowspan() {
073 return this.getMathAttribute(Mtd.ATTR_ROWSPAN);
074 }
075
076 /**
077 * @param rowspan
078 * Rowspan
079 */
080 public void setRowspan(final String rowspan) {
081 this.setAttribute(Mtd.ATTR_ROWSPAN, rowspan);
082 }
083
084 /**
085 * @return Columnspan
086 */
087 public String getColumnspan() {
088 return this.getMathAttribute(Mtd.ATTR_COLUMNSPAN);
089 }
090
091 /**
092 * @param columnspan
093 * Columnspan
094 */
095 public void setColumnspan(final String columnspan) {
096 this.setAttribute(Mtd.ATTR_COLUMNSPAN, columnspan);
097 }
098
099 /** {@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 }