Coverage Report - net.sourceforge.jeuclid.elements.presentation.script.AbstractScriptElement
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractScriptElement
71%
10/14
100%
2/2
1,333
 
 1  
 /*
 2  
  * Copyright 2007 - 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: AbstractScriptElement.java,v bc1d5fde7b73 2009/06/01 14:40:54 maxberger $ */
 18  
 
 19  
 package net.sourceforge.jeuclid.elements.presentation.script;
 20  
 
 21  
 import net.sourceforge.jeuclid.Constants;
 22  
 import net.sourceforge.jeuclid.LayoutContext;
 23  
 import net.sourceforge.jeuclid.context.InlineLayoutContext;
 24  
 import net.sourceforge.jeuclid.context.RelativeScriptlevelLayoutContext;
 25  
 import net.sourceforge.jeuclid.elements.AbstractJEuclidElement;
 26  
 
 27  
 import org.apache.batik.dom.AbstractDocument;
 28  
 
 29  
 /**
 30  
  * Base class for msub, msup, msubsup, and mmultiscripts.
 31  
  * 
 32  
  * @version $Revision: bc1d5fde7b73 $
 33  
  */
 34  
 public abstract class AbstractScriptElement extends AbstractJEuclidElement {
 35  
 
 36  
     /** attribute for subscriptshift. */
 37  
     public static final String ATTR_SUBSCRIPTSHIFT = "subscriptshift";
 38  
 
 39  
     /** attribute for superscriptshift. */
 40  
     public static final String ATTR_SUPERSCRIPTSHIFT = "superscriptshift";
 41  
 
 42  
     /**
 43  
      * Default constructor. Sets MathML Namespace.
 44  
      * 
 45  
      * @param qname
 46  
      *            Qualified name.
 47  
      * @param odoc
 48  
      *            Owner Document.
 49  
      */
 50  
     public AbstractScriptElement(final String qname, final AbstractDocument odoc) {
 51  8569
         super(qname, odoc);
 52  
 
 53  8569
         this.setDefaultMathAttribute(AbstractScriptElement.ATTR_SUBSCRIPTSHIFT,
 54  
                 Constants.ZERO);
 55  8569
         this.setDefaultMathAttribute(
 56  
                 AbstractScriptElement.ATTR_SUPERSCRIPTSHIFT, Constants.ZERO);
 57  8569
     }
 58  
 
 59  
     /**
 60  
      * @return attribute subscriptshift.
 61  
      */
 62  
     public String getSubscriptshift() {
 63  2299
         return this.getMathAttribute(AbstractScriptElement.ATTR_SUBSCRIPTSHIFT);
 64  
     }
 65  
 
 66  
     /**
 67  
      * @param subscriptshift
 68  
      *            new value for subscriptshift
 69  
      */
 70  
     public void setSubscriptshift(final String subscriptshift) {
 71  0
         this.setAttribute(AbstractScriptElement.ATTR_SUBSCRIPTSHIFT,
 72  
                 subscriptshift);
 73  0
     }
 74  
 
 75  
     /**
 76  
      * @return attribtue superscriptshift
 77  
      */
 78  
     public String getSuperscriptshift() {
 79  2299
         return this
 80  
                 .getMathAttribute(AbstractScriptElement.ATTR_SUPERSCRIPTSHIFT);
 81  
     }
 82  
 
 83  
     /**
 84  
      * @param superscriptshift
 85  
      *            new value for superscriptshift
 86  
      */
 87  
     public void setSuperscriptshift(final String superscriptshift) {
 88  0
         this.setAttribute(AbstractScriptElement.ATTR_SUPERSCRIPTSHIFT,
 89  
                 superscriptshift);
 90  0
     }
 91  
 
 92  
     /** {@inheritDoc} */
 93  
     @Override
 94  
     public LayoutContext getChildLayoutContext(final int childNum,
 95  
             final LayoutContext context) {
 96  5643
         final LayoutContext now = this.applyLocalAttributesToContext(context);
 97  5643
         if (childNum == 0) {
 98  2299
             return now;
 99  
         } else {
 100  3344
             return new RelativeScriptlevelLayoutContext(
 101  
                     new InlineLayoutContext(now), 1);
 102  
         }
 103  
     }
 104  
 
 105  
 }