Coverage Report - net.sourceforge.jeuclid.layout.LayoutInfoImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
LayoutInfoImpl
100%
71/71
100%
28/28
1,957
 
 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: LayoutInfoImpl.java,v 88b901bf20fb 2008/06/07 14:12:27 maxberger $ */
 18  
 
 19  
 package net.sourceforge.jeuclid.layout;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.List;
 23  
 
 24  
 /**
 25  
  * @version $Revision: 88b901bf20fb $
 26  
  */
 27  
 public class LayoutInfoImpl implements LayoutInfo {
 28  
 
 29  
     private LayoutStage layoutStage;
 30  
 
 31  
     private float ascentHeightS1;
 32  
 
 33  
     private float ascentHeightS2;
 34  
 
 35  
     private float descentHeightS1;
 36  
 
 37  
     private float descentHeightS2;
 38  
 
 39  
     private float horizontalS1;
 40  
 
 41  
     private float horizontalS2;
 42  
 
 43  
     private float widthS1;
 44  
 
 45  
     private float widthS2;
 46  
 
 47  
     private float posXS1;
 48  
 
 49  
     private float posXS2;
 50  
 
 51  
     private float posYS1;
 52  
 
 53  
     private float posYS2;
 54  
 
 55  80899
     private float stretchAscent = -1.0f;
 56  
 
 57  80899
     private float stretchDescent = -1.0f;
 58  
 
 59  80899
     private float stretchWidth = -1.0f;
 60  
 
 61  
     private final List<GraphicsObject> graphicObjects;
 62  
 
 63  
     /**
 64  
      * Default Constructor.
 65  
      */
 66  80899
     public LayoutInfoImpl() {
 67  80899
         this.layoutStage = LayoutStage.NONE;
 68  80899
         this.graphicObjects = new ArrayList<GraphicsObject>();
 69  80899
     }
 70  
 
 71  
     /** {@inheritDoc} */
 72  
     public LayoutStage getLayoutStage() {
 73  352285
         return this.layoutStage;
 74  
     }
 75  
 
 76  
     /** {@inheritDoc} */
 77  
     public void setLayoutStage(final LayoutStage newStage) {
 78  120239
         this.layoutStage = newStage;
 79  120239
     }
 80  
 
 81  
     /** {@inheritDoc} */
 82  
     public float getAscentHeight(final LayoutStage stage) {
 83  158450
         if (LayoutStage.STAGE1.equals(stage)) {
 84  99709
             return this.ascentHeightS1;
 85  
         } else {
 86  58741
             return this.ascentHeightS2;
 87  
         }
 88  
     }
 89  
 
 90  
     /** {@inheritDoc} */
 91  
     public float getDescentHeight(final LayoutStage stage) {
 92  156569
         if (LayoutStage.STAGE1.equals(stage)) {
 93  100963
             return this.descentHeightS1;
 94  
         } else {
 95  55606
             return this.descentHeightS2;
 96  
         }
 97  
     }
 98  
 
 99  
     /** {@inheritDoc} */
 100  
     public float getHorizontalCenterOffset(final LayoutStage stage) {
 101  30932
         if (LayoutStage.STAGE1.equals(stage)) {
 102  19437
             return this.horizontalS1;
 103  
         } else {
 104  11495
             return this.horizontalS2;
 105  
         }
 106  
     }
 107  
 
 108  
     /** {@inheritDoc} */
 109  
     public float getPosX(final LayoutStage stage) {
 110  105963
         if (LayoutStage.STAGE1.equals(stage)) {
 111  22154
             return this.posXS1;
 112  
         } else {
 113  83809
             return this.posXS2;
 114  
         }
 115  
     }
 116  
 
 117  
     /** {@inheritDoc} */
 118  
     public float getPosY(final LayoutStage stage) {
 119  146091
         if (LayoutStage.STAGE1.equals(stage)) {
 120  49324
             return this.posYS1;
 121  
         } else {
 122  96767
             return this.posYS2;
 123  
         }
 124  
     }
 125  
 
 126  
     /** {@inheritDoc} */
 127  
     public float getWidth(final LayoutStage stage) {
 128  158659
         if (LayoutStage.STAGE1.equals(stage)) {
 129  98037
             return this.widthS1;
 130  
         } else {
 131  60622
             return this.widthS2;
 132  
         }
 133  
     }
 134  
 
 135  
     /** {@inheritDoc} */
 136  
     public void moveTo(final float x, final float y, final LayoutStage stage) {
 137  122072
         this.posXS2 = x;
 138  122072
         this.posYS2 = y;
 139  122072
         if (LayoutStage.STAGE1.equals(stage)) {
 140  79436
             this.posXS1 = x;
 141  79436
             this.posYS1 = y;
 142  
         }
 143  
 
 144  122072
     }
 145  
 
 146  
     /** {@inheritDoc} */
 147  
     public void setAscentHeight(final float ascentHeight,
 148  
             final LayoutStage stage) {
 149  111007
         this.ascentHeightS2 = ascentHeight;
 150  111007
         if (LayoutStage.STAGE1.equals(stage)) {
 151  81747
             this.ascentHeightS1 = ascentHeight;
 152  
         }
 153  111007
     }
 154  
 
 155  
     /** {@inheritDoc} */
 156  
     public void setDescentHeight(final float descentHeight,
 157  
             final LayoutStage stage) {
 158  111007
         this.descentHeightS2 = descentHeight;
 159  111007
         if (LayoutStage.STAGE1.equals(stage)) {
 160  81747
             this.descentHeightS1 = descentHeight;
 161  
         }
 162  111007
     }
 163  
 
 164  
     /** {@inheritDoc} */
 165  
     public void setHorizontalCenterOffset(final float newOffset,
 166  
             final LayoutStage stage) {
 167  104528
         this.horizontalS2 = newOffset;
 168  104528
         if (LayoutStage.STAGE1.equals(stage)) {
 169  81747
             this.horizontalS1 = newOffset;
 170  
         }
 171  104528
     }
 172  
 
 173  
     /** {@inheritDoc} */
 174  
     public void setWidth(final float width, final LayoutStage stage) {
 175  108081
         this.widthS2 = width;
 176  108081
         if (LayoutStage.STAGE1.equals(stage)) {
 177  84464
             this.widthS1 = width;
 178  
         }
 179  108081
     }
 180  
 
 181  
     /** {@inheritDoc} */
 182  
     public void setGraphicsObject(final GraphicsObject graphicsObject) {
 183  43480
         this.graphicObjects.clear();
 184  43480
         this.graphicObjects.add(graphicsObject);
 185  43480
     }
 186  
 
 187  
     /** {@inheritDoc} */
 188  
     public List<GraphicsObject> getGraphicObjects() {
 189  75031
         return this.graphicObjects;
 190  
     }
 191  
 
 192  
     /** {@inheritDoc} */
 193  
     public float getStretchWidth() {
 194  1672
         return this.stretchWidth;
 195  
     }
 196  
 
 197  
     /** {@inheritDoc} */
 198  
     public void setStretchWidth(final float newStretchWidth) {
 199  14212
         this.stretchWidth = newStretchWidth;
 200  14212
     }
 201  
 
 202  
     /** {@inheritDoc} */
 203  
     public float getStretchAscent() {
 204  96992
         if (this.stretchAscent < 0.0f) {
 205  36165
             return this.ascentHeightS1;
 206  
         } else {
 207  60827
             return this.stretchAscent;
 208  
         }
 209  
     }
 210  
 
 211  
     /** {@inheritDoc} */
 212  
     public float getStretchDescent() {
 213  96992
         if (this.stretchDescent < 0.0f) {
 214  36165
             return this.descentHeightS1;
 215  
         } else {
 216  60827
             return this.stretchDescent;
 217  
         }
 218  
     }
 219  
 
 220  
     /** {@inheritDoc} */
 221  
     public void setStretchAscent(final float newStretchAscent) {
 222  73588
         this.stretchAscent = newStretchAscent;
 223  
 
 224  73588
     }
 225  
 
 226  
     /** {@inheritDoc} */
 227  
     public void setStretchDescent(final float newStretchDescent) {
 228  73588
         this.stretchDescent = newStretchDescent;
 229  73588
     }
 230  
 
 231  
     /** {@inheritDoc} */
 232  
     public void shiftVertically(final float offsetY, final LayoutStage stage) {
 233  9823
         this.posYS2 += offsetY;
 234  9823
         if (LayoutStage.STAGE1.equals(stage)) {
 235  7733
             this.posYS1 += offsetY;
 236  
         }
 237  9823
     }
 238  
 }