Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 125   Methods: 11
NCLOC: 98   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AbsoluteLayout.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * brownies and its relative products are published under the terms of the
 3   
  * Apache Software License.
 4   
  * 
 5   
  * Created on 2004/05/22 16:07:34
 6   
  */
 7   
 package org.asyrinx.brownie.swing;
 8   
 
 9   
 import java.awt.Component;
 10   
 import java.awt.Container;
 11   
 import java.awt.Dimension;
 12   
 import java.awt.LayoutManager2;
 13   
 import java.io.Serializable;
 14   
 import java.util.Hashtable;
 15   
 import java.util.Iterator;
 16   
 import java.util.Map;
 17   
 
 18   
 public class AbsoluteLayout implements LayoutManager2, Serializable {
 19   
 
 20   
     protected final Map constraintMap = new Hashtable();
 21   
 
 22  0
     public AbsoluteLayout() {
 23   
         //do nothing        
 24   
     }
 25   
 
 26  0
     public void addLayoutComponent(Component component, Object obj) {
 27  0
         if (!(obj instanceof AbsoluteConstraints)) {
 28  0
             throw new IllegalArgumentException();
 29   
         } else {
 30  0
             constraintMap.put(component, obj);
 31  0
             return;
 32   
         }
 33   
     }
 34   
 
 35  0
     public void addLayoutComponent(String s, Component component) {
 36  0
         throw new IllegalArgumentException();
 37   
     }
 38   
 
 39  0
     public void removeLayoutComponent(Component component) {
 40  0
         constraintMap.remove(component);
 41   
     }
 42   
 
 43  0
     public float getLayoutAlignmentX(Container container) {
 44  0
         return 0.0F;
 45   
     }
 46   
 
 47  0
     public float getLayoutAlignmentY(Container container) {
 48  0
         return 0.0F;
 49   
     }
 50   
 
 51  0
     public void invalidateLayout(Container container) {
 52   
         //do nothing
 53   
     }
 54   
 
 55  0
     public void layoutContainer(Container container) {
 56  0
         for (Iterator iterator = constraintMap.keySet().iterator(); iterator
 57   
                 .hasNext();) {
 58  0
             final Component component = (Component) iterator.next();
 59  0
             final AbsoluteConstraints constraints = (AbsoluteConstraints) constraintMap
 60   
                     .get(component);
 61  0
             Dimension dimension = component.getPreferredSize();
 62  0
             int i = constraints.getWidth();
 63  0
             if (i == -1)
 64  0
                 i = dimension.width;
 65  0
             int j = constraints.getHeight();
 66  0
             if (j == -1)
 67  0
                 j = dimension.height;
 68  0
             component.setBounds(constraints.x, constraints.y, i, j);
 69   
         }
 70   
 
 71   
     }
 72   
 
 73  0
     public Dimension maximumLayoutSize(Container container) {
 74  0
         return new Dimension(2147483647, 2147483647);
 75   
     }
 76   
 
 77  0
     public Dimension minimumLayoutSize(Container container) {
 78  0
         int i = 0;
 79  0
         int j = 0;
 80  0
         for (Iterator iterator = constraintMap.keySet().iterator(); iterator
 81   
                 .hasNext();) {
 82  0
             final Component component = (Component) iterator.next();
 83  0
             final AbsoluteConstraints constraints = (AbsoluteConstraints) constraintMap
 84   
                     .get(component);
 85  0
             Dimension dimension = component.getMinimumSize();
 86  0
             int k = constraints.getWidth();
 87  0
             if (k == -1)
 88  0
                 k = dimension.width;
 89  0
             int l = constraints.getHeight();
 90  0
             if (l == -1)
 91  0
                 l = dimension.height;
 92  0
             if (constraints.x + k > i)
 93  0
                 i = constraints.x + k;
 94  0
             if (constraints.y + l > j)
 95  0
                 j = constraints.y + l;
 96   
         }
 97   
 
 98  0
         return new Dimension(i, j);
 99   
     }
 100   
 
 101  0
     public Dimension preferredLayoutSize(Container container) {
 102  0
         int i = 0;
 103  0
         int j = 0;
 104  0
         for (Iterator iterator = constraintMap.keySet().iterator(); iterator
 105   
                 .hasNext();) {
 106  0
             final Component component = (Component) iterator.next();
 107  0
             final AbsoluteConstraints absoluteconstraints = (AbsoluteConstraints) constraintMap
 108   
                     .get(component);
 109  0
             final Dimension dimension = component.getPreferredSize();
 110  0
             int k = absoluteconstraints.getWidth();
 111  0
             if (k == -1)
 112  0
                 k = dimension.width;
 113  0
             int l = absoluteconstraints.getHeight();
 114  0
             if (l == -1)
 115  0
                 l = dimension.height;
 116  0
             if (absoluteconstraints.x + k > i)
 117  0
                 i = absoluteconstraints.x + k;
 118  0
             if (absoluteconstraints.y + l > j)
 119  0
                 j = absoluteconstraints.y + l;
 120   
         }
 121   
 
 122  0
         return new Dimension(i, j);
 123   
     }
 124   
 
 125   
 }