00001
00002
00003
00004
00005
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
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
00065