Coverage Report - net.sourceforge.combean.graph.containers.doubleval.ScalingDoubleNodeMapDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
ScalingDoubleNodeMapDecorator
89%
8/9
50%
1/2
2
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean 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
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 30.08.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.graph.containers.doubleval;
 23  
 
 24  
 import net.sourceforge.combean.interfaces.graph.Node;
 25  
 import net.sourceforge.combean.interfaces.graph.containers.doubleval.FixedDoubleNodeMap;
 26  
 import net.sourceforge.combean.util.except.IllegalParameterException;
 27  
 
 28  
 /**
 29  
  * Decorator for a double node map. Scales the values before returning them.
 30  
  * 
 31  
  * @author schickin
 32  
  *
 33  
  */
 34  
 public class ScalingDoubleNodeMapDecorator implements FixedDoubleNodeMap {
 35  
     
 36  27
     private FixedDoubleNodeMap wrappedNodeMap = null;
 37  27
     private double scalingFactor = 1.0;
 38  
 
 39  
     /**
 40  
      * Constructor
 41  
      * 
 42  
      * @param wrappedNodeMap the double node map to scale
 43  
      * @param scalingFactor the scaling factor
 44  
      */
 45  
     public ScalingDoubleNodeMapDecorator(FixedDoubleNodeMap wrappedNodeMap,
 46  
             double scalingFactor) {
 47  27
         super();
 48  
         
 49  27
         if (wrappedNodeMap == null) {
 50  0
             throw new IllegalParameterException("wrappedNodeMap is null");
 51  
         }
 52  
         
 53  27
         this.wrappedNodeMap = wrappedNodeMap;
 54  27
         this.scalingFactor = scalingFactor;
 55  27
     }
 56  
     
 57  
     /* (non-Javadoc)
 58  
      * @see net.sourceforge.combean.interfaces.graph.containers.doubleval.FixedDoubleNodeMap#getDouble(net.sourceforge.combean.interfaces.graph.Node)
 59  
      */
 60  
     public double getDouble(Node v) {
 61  108
          return this.wrappedNodeMap.getDouble(v) * this.scalingFactor;
 62  
     }
 63  
 
 64  
 }