Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 112   Methods: 12
NCLOC: 74   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ZoomLayoutManager.java 66.7% 84.2% 66.7% 75.7%
coverage coverage
 1    /*
 2    * Copyright (C) 2007 Eric MIGNOT - mignots.eric@free.fr
 3    *
 4    * This library is free software; you can redistribute it and/or
 5    * modify it under the terms of the GNU Lesser General Public
 6    * License as published by the Free Software Foundation; either
 7    * version 2.1 of the License, or (at your option) any later version.
 8    *
 9    * This library is distributed in the hope that it will be useful,
 10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12    * Lesser General Public License for more details.
 13    *
 14    * You should have received a copy of the GNU Lesser General Public
 15    * License along with this library; if not, write to the Free Software
 16    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18    package org.ericmignot.modeler.gui.layout;
 19   
 20    import java.awt.Component;
 21    import java.awt.Container;
 22    import java.awt.Dimension;
 23    import java.awt.LayoutManager;
 24   
 25    import org.ericmignot.modeler.gui.StaticValues;
 26   
 27   
 28    public class ZoomLayoutManager implements LayoutManager
 29    {
 30   
 31    private double zoomRatio;
 32   
 33  164 public ZoomLayoutManager()
 34    {
 35  164 this.setZoomRatio(1.0);
 36    }
 37   
 38  0 public Dimension preferredLayoutSize(Container c)
 39    {
 40  0 return zoom(c.getPreferredSize());
 41    }
 42   
 43  0 public Dimension minimumLayoutSize(Container c)
 44    {
 45  0 return zoom(c.getPreferredSize());
 46    }
 47   
 48  0 private Dimension zoom(Dimension dim)
 49    {
 50  0 return new Dimension( (int)(dim.width * getZoomRatio()),
 51    (int)(dim.height * getZoomRatio()) );
 52    }
 53   
 54   
 55  0 public void addLayoutComponent(String s, Component c)
 56    {
 57    }
 58   
 59  18 public void removeLayoutComponent(Component c)
 60    {
 61    }
 62   
 63  1197 public void zoomComponent(Component c)
 64    {
 65  1197 if (c instanceof Zoomable)
 66    {
 67  1197 Zoomable z = (Zoomable) c;
 68  1197 c.setSize(z.getZoomedSize(this.zoomRatio));
 69  1197 c.setLocation(z.getZoomedLocation(this.zoomRatio));
 70    }
 71    }
 72   
 73  531 public void layoutContainer(java.awt.Container target)
 74    {
 75  531 synchronized (target.getTreeLock())
 76    {
 77  531 for (int i = 0; i < target.getComponentCount(); i++)
 78    {
 79  1194 Component c = target.getComponent(i);
 80  1194 this.zoomComponent(c);
 81    }
 82    }
 83    }
 84   
 85   
 86  196 public double getZoomRatio()
 87    {
 88  196 return zoomRatio;
 89    }
 90   
 91   
 92  191 public void setZoomRatio(double zoomRatio)
 93    {
 94  191 if (zoomRatio > 0.0)
 95    {
 96  191 this.zoomRatio = zoomRatio;
 97    }
 98    }
 99   
 100  1 public void zoomIn()
 101    {
 102  1 double increment = Double.parseDouble(StaticValues.getInstance().get("Design.Zoom.IncrementDecrement", "0.2"));
 103  1 this.setZoomRatio(this.getZoomRatio() + increment);
 104    }
 105   
 106  1 public void zoomOut()
 107    {
 108  1 double decrement = Double.parseDouble(StaticValues.getInstance().get("Design.Zoom.IncrementDecrement", "0.2"));
 109  1 this.setZoomRatio(this.getZoomRatio() - decrement);
 110    }
 111   
 112    }