1 /* 2 * Copyright 2006 - 2012 Christina Bohk and Roland Ewald 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package p3j.misc; 17 18 import p3j.gui.P3J; 19 20 /** 21 * Enumeration for all kinds of matrix dimensions used in the PPPM. 22 * 23 * Created: August 17, 2008 24 * 25 * @author Christina Bohk 26 * @author Roland Ewald 27 * 28 */ 29 public enum MatrixDimension { 30 31 /** 32 * One line/row. 33 */ 34 SINGLE, 35 36 /** 37 * As many lines/rows as years to be predicted. 38 */ 39 YEARS, 40 41 /** 42 * As many lines/rows as ages to be considered. 43 */ 44 AGES; 45 46 /** 47 * Return name of the dimension. This is used for the matrix editor. Single 48 * lines/rows do not have a specific name. 49 * 50 * @return proper label for dimension 51 */ 52 public String getLabel() { 53 switch (this) { 54 case AGES: 55 return "Age "; 56 case YEARS: 57 return "Year "; 58 case SINGLE: 59 default: 60 return ""; 61 } 62 } 63 64 /** 65 * Defines current numeric equivalent of the dimension. 66 * 67 * @return a mount of entries in this dimension 68 */ 69 public int getDimension() { 70 switch (this) { 71 case SINGLE: 72 return 1; 73 case AGES: 74 return P3J.getCurrentProjection().getMaximumAge() + 1; 75 case YEARS: 76 return P3J.getCurrentProjection().getYears(); 77 default: 78 return 0; 79 } 80 } 81 }