src/de/pik/lagom/generic/initvalues/InitValuesWithSectors.java

00001 
00002 // Copyright 2010 by Carlo Jaeger, Antoine Mandel, Steffen Fuerst and European Climate Forum
00003 // Licensed under the Open Software License version 3.0
00004 // See the file "License-OSL-3.0.txt" in the distribution for more information 
00005 // The License text can be also found under http://www.opensource.org/licenses/osl-3.0.php
00007 
00008 package de.pik.lagom.generic.initvalues;
00009 
00010 import de.pik.lagom.toolbox.ArrayTools;
00011 import de.pik.lagom.toolbox.io.initvalues.InitValuesBase;
00012 import de.pik.lagom.toolbox.io.initvalues.InitValuesManager;
00013 
00014 public class InitValuesWithSectors extends InitValuesBase {
00015   static protected int numSectors = 10;
00016   static private String[] nameArray;
00017   
00018 
00019   InitValuesWithSectors(InitValuesManager pIVM) {
00020     super(pIVM);
00021   }
00022 
00023   public void numSectorsChanged(int pNumSectors) {
00024     numSectors = pNumSectors;
00025     setArrayValues();
00026   }
00027 
00028   //---- helper methods
00029   protected double[] createArray(double pNewValue){
00030     return ArrayTools.createArray(numSectors, pNewValue);
00031   }
00032 
00033   protected double[][] createMatrix(double pNewValue){
00034     return ArrayTools.createMatrix(numSectors, numSectors, pNewValue);
00035   }
00036 
00037   protected double checkForDefault(double pDefaultValue, double[] pDefaultArray) {
00038     if (ArrayTools.allElementsHaveSameValue(pDefaultArray) != Double.NaN) {
00039       return ArrayTools.allElementsHaveSameValue(pDefaultArray);
00040     } else {
00041       return pDefaultValue;
00042     }
00043   }
00044 
00045   protected double checkForDefault(double pDefaultValue, double[][] pDefaultMarix) {
00046     if (ArrayTools.allElementsHaveSameValue(pDefaultMarix) != Double.NaN) {
00047       return ArrayTools.allElementsHaveSameValue(pDefaultMarix);
00048     } else {
00049       return pDefaultValue;
00050     }
00051   }
00052   
00053   protected void setSectorNames(String[] pNames) {
00054     nameArray = pNames;
00055   }
00056 
00057   public String[] getSectorNames() {
00058     return nameArray;
00059   }
00060 }
00061 
00063 // EOF
00065 

Generated on Tue Sep 14 11:11:48 2010 for lagom_generiC by  doxygen 1.5.4