| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Mi |
|
| 1.3333333333333333;1,333 |
| 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: Mi.java,v 74b8e95997bf 2010/08/11 17:45:46 max $ */ | |
| 18 | ||
| 19 | package net.sourceforge.jeuclid.elements.presentation.token; | |
| 20 | ||
| 21 | import net.sourceforge.jeuclid.elements.AbstractJEuclidElement; | |
| 22 | import net.sourceforge.jeuclid.elements.support.text.StringUtil; | |
| 23 | ||
| 24 | import org.apache.batik.dom.AbstractDocument; | |
| 25 | import org.w3c.dom.Node; | |
| 26 | ||
| 27 | ||
| 28 | /** | |
| 29 | * This class presents a mathematical identifier, like "x". | |
| 30 | * | |
| 31 | * @version $Revision: 74b8e95997bf $ | |
| 32 | */ | |
| 33 | public final class Mi extends AbstractTokenWithTextLayout { | |
| 34 | /** | |
| 35 | * The XML element from this class. | |
| 36 | */ | |
| 37 | public static final String ELEMENT = "mi"; | |
| 38 | ||
| 39 | private static final long serialVersionUID = 1L; | |
| 40 | ||
| 41 | /** | |
| 42 | * Default constructor. Sets MathML Namespace. | |
| 43 | * | |
| 44 | * @param qname | |
| 45 | * Qualified name. | |
| 46 | * @param odoc | |
| 47 | * Owner Document. | |
| 48 | 47918 | */ |
| 49 | 47918 | public Mi(final String qname, final AbstractDocument odoc) { |
| 50 | 2765 | super(qname, odoc); |
| 51 | 2765 | } |
| 52 | ||
| 53 | /** {@inheritDoc} */ | |
| 54 | 0 | @Override |
| 55 | protected Node newNode() { | |
| 56 | 0 | return new Mi(this.nodeName, this.ownerDocument); |
| 57 | } | |
| 58 | ||
| 59 | /** {@inheritDoc} */ | |
| 60 | 220976 | @Override |
| 61 | 220976 | public void changeHook() { |
| 62 | 57143 | super.changeHook(); |
| 63 | 12591 | if (StringUtil.countDisplayableCharacters(this.getText()) == 1) { |
| 64 | 2567 | this.setDefaultMathAttribute( |
| 65 | 176424 | AbstractJEuclidElement.ATTR_MATHVARIANT, "italic"); |
| 66 | } else { | |
| 67 | 10024 | this.setDefaultMathAttribute( |
| 68 | 220976 | AbstractJEuclidElement.ATTR_MATHVARIANT, "normal"); |
| 69 | } | |
| 70 | 12591 | } |
| 71 | ||
| 72 | } |