Coverage Report - net.sourceforge.jeuclid.elements.presentation.token.Mspace
 
Classes in this File Line Coverage Branch Coverage Complexity
Mspace
25%
6/24
N/A
1
 
 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: Mspace.java,v b2e8c71e4a50 2009/09/10 14:00:50 max $ */
 18  
 
 19  
 package net.sourceforge.jeuclid.elements.presentation.token;
 20  
 
 21  
 import net.sourceforge.jeuclid.Constants;
 22  
 import net.sourceforge.jeuclid.LayoutContext;
 23  
 import net.sourceforge.jeuclid.elements.AbstractJEuclidElement;
 24  
 import net.sourceforge.jeuclid.elements.support.attributes.AttributesHelper;
 25  
 import net.sourceforge.jeuclid.layout.LayoutInfo;
 26  
 import net.sourceforge.jeuclid.layout.LayoutStage;
 27  
 import net.sourceforge.jeuclid.layout.LayoutView;
 28  
 
 29  
 import org.apache.batik.dom.AbstractDocument;
 30  
 import org.w3c.dom.Node;
 31  
 import org.w3c.dom.mathml.MathMLSpaceElement;
 32  
 
 33  
 /**
 34  
  * This class presents a mspace.
 35  
  * 
 36  
  * <p>
 37  
  * TODO: linebreak is unimplemented
 38  
  * 
 39  
  * @version $Revision: b2e8c71e4a50 $
 40  
  */
 41  
 public final class Mspace extends AbstractJEuclidElement implements
 42  
         MathMLSpaceElement {
 43  
 
 44  
     /**
 45  
      * The XML element from this class.
 46  
      */
 47  
     public static final String ELEMENT = "mspace";
 48  
 
 49  
     /** Attribute for width. */
 50  
     public static final String ATTR_WIDTH = "width";
 51  
 
 52  
     /** Attribute for height. */
 53  
     public static final String ATTR_HEIGHT = "height";
 54  
 
 55  
     /** Attribute for depth. */
 56  
     public static final String ATTR_DEPTH = "depth";
 57  
 
 58  
     /** Attribute for linebreak. */
 59  
     public static final String ATTR_LINEBREAK = "linebreak";
 60  
 
 61  
     private static final long serialVersionUID = 1L;
 62  
 
 63  
     /**
 64  
      * Default constructor. Sets MathML Namespace.
 65  
      * 
 66  
      * @param qname
 67  
      *            Qualified name.
 68  
      * @param odoc
 69  
      *            Owner Document.
 70  
      */
 71  
     public Mspace(final String qname, final AbstractDocument odoc) {
 72  418
         super(qname, odoc);
 73  
 
 74  418
         this.setDefaultMathAttribute(Mspace.ATTR_DEPTH, Constants.ZERO);
 75  418
         this.setDefaultMathAttribute(Mspace.ATTR_HEIGHT, Constants.ZERO);
 76  418
         this.setDefaultMathAttribute(Mspace.ATTR_WIDTH, Constants.ZERO);
 77  418
         this.setDefaultMathAttribute(Mspace.ATTR_LINEBREAK, "auto");
 78  418
     }
 79  
 
 80  
     /** {@inheritDoc} */
 81  
     @Override
 82  
     protected Node newNode() {
 83  0
         return new Mspace(this.nodeName, this.ownerDocument);
 84  
     }
 85  
 
 86  
     /**
 87  
      * @return Space width
 88  
      */
 89  
     public String getWidth() {
 90  0
         return this.getMathAttribute(Mspace.ATTR_WIDTH);
 91  
     }
 92  
 
 93  
     /**
 94  
      * @param width
 95  
      *            Space width
 96  
      */
 97  
     public void setWidth(final String width) {
 98  0
         this.setAttribute(Mspace.ATTR_WIDTH, width);
 99  0
     }
 100  
 
 101  
     /**
 102  
      * @return Space height
 103  
      */
 104  
     public String getHeight() {
 105  0
         return this.getMathAttribute(Mspace.ATTR_HEIGHT);
 106  
     }
 107  
 
 108  
     /**
 109  
      * @param height
 110  
      *            Space height
 111  
      */
 112  
     public void setHeight(final String height) {
 113  0
         this.setAttribute(Mspace.ATTR_HEIGHT, height);
 114  0
     }
 115  
 
 116  
     /**
 117  
      * @return Space depth
 118  
      */
 119  
     public String getDepth() {
 120  0
         return this.getMathAttribute(Mspace.ATTR_DEPTH);
 121  
     }
 122  
 
 123  
     /**
 124  
      * @param depth
 125  
      *            Space depth
 126  
      */
 127  
     public void setDepth(final String depth) {
 128  0
         this.setAttribute(Mspace.ATTR_DEPTH, depth);
 129  0
     }
 130  
 
 131  
     /** {@inheritDoc} */
 132  
     @Override
 133  
     protected void layoutStageInvariant(final LayoutView view,
 134  
             final LayoutInfo info, final LayoutStage stage,
 135  
             final LayoutContext context) {
 136  0
         final LayoutContext now = this.applyLocalAttributesToContext(context);
 137  0
         info.setAscentHeight(AttributesHelper.convertSizeToPt(this.getHeight(),
 138  
                 now, AttributesHelper.PT), stage);
 139  0
         info.setDescentHeight(AttributesHelper.convertSizeToPt(this.getDepth(),
 140  
                 now, AttributesHelper.PT), stage);
 141  0
         info.setWidth(AttributesHelper.convertSizeToPt(this.getWidth(), now,
 142  
                 AttributesHelper.PT), stage);
 143  0
     }
 144  
 
 145  
     /** {@inheritDoc} */
 146  
     public String getLinebreak() {
 147  0
         return this.getMathAttribute(Mspace.ATTR_LINEBREAK);
 148  
     }
 149  
 
 150  
     /** {@inheritDoc} */
 151  
     public void setLinebreak(final String linebreak) {
 152  0
         this.setAttribute(Mspace.ATTR_LINEBREAK, linebreak);
 153  0
     }
 154  
 }