1 /* 2 * Copyright (c) 2003-2008 by Cosylab d. d. 3 * 4 * This file is part of CosyBeans-Common. 5 * 6 * CosyBeans-Common is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * CosyBeans-Common is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with CosyBeans-Common. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package com.cosylab.gui.components.table.cells; 21 22 /** 23 * Numeric cell holds numeric value: double or long. 24 * 25 * @author <a href="mailto:igor.kriznar@cosylab.com">Igor Kriznar</a> 26 */ 27 public abstract class NumericCell extends TableCell 28 { 29 /** Characteristic name for string describing ANSI type of format. */ 30 public static final String FORMAT = "format"; 31 32 /** Characteristic name for string describing physical units of value. */ 33 public static final String UNITS = "units"; 34 35 /** Characteristic name for string describing minimal allowed value. */ 36 public static final String MINIMUM = "minimum"; 37 38 /** Characteristic name for string describing maximal allowed value. */ 39 public static final String MAXIMUM = "maximum"; 40 41 /** Characteristic name for value defining if units should be visible. */ 42 public static final String UNITS_VISIBLE = "unitsVisible"; 43 44 /** 45 * Constructs a new NumericCell. 46 * 47 */ 48 public NumericCell() 49 { 50 super(); 51 } 52 53 /** 54 * Constructs a new NumericCell. 55 * 56 * @param identifier 57 * @param dataSource 58 * @param value 59 * @param commands 60 */ 61 public NumericCell(String identifier, Object dataSource, Object value, 62 Command[] commands) 63 { 64 super(identifier, dataSource, value, commands); 65 } 66 67 /** 68 * Returns value of FORMAT characteristic. 69 * 70 * @return value of FORMAT characteristic 71 */ 72 public String getFormat() 73 { 74 return (String)getCharacteristic(FORMAT); 75 } 76 77 /** 78 * Returns value of UNITS characteristic. 79 * 80 * @return value of UNITS characteristic 81 */ 82 public String getUnits() 83 { 84 return (String)getCharacteristic(UNITS); 85 } 86 87 /** 88 * Returns a flag if units are visible. 89 * 90 * @return 91 */ 92 public boolean isUnitsVisible() { 93 Boolean b = (Boolean) getCharacteristic(UNITS_VISIBLE); 94 if (b == null) return false; 95 else return b; 96 } 97 98 /** 99 * Returns value of MINIMUM characteristic. 100 * 101 * @return value of MINIMUM characteristic 102 */ 103 public Number getMinimum() 104 { 105 return (Number)getCharacteristic(MINIMUM); 106 } 107 108 /** 109 * Returns value of MINIMUM characteristic. 110 * 111 * @param defaultValue DOCUMENT ME! 112 * 113 * @return value of MINIMUM characteristic 114 */ 115 public Number getMinimum(Number defaultValue) 116 { 117 return (Number)getCharacteristic(MINIMUM, defaultValue); 118 } 119 120 /** 121 * Returns value of MAXIMUM characteristic. 122 * 123 * @return value of MAXIMUM characteristic 124 */ 125 public Number getMaximum() 126 { 127 return (Number)getCharacteristic(MAXIMUM); 128 } 129 130 /** 131 * Returns value of MAXIMUM characteristic. 132 * 133 * @param defaultValue DOCUMENT ME! 134 * 135 * @return value of MAXIMUM characteristic 136 */ 137 public Number getMaximum(Number defaultValue) 138 { 139 return (Number)getCharacteristic(MAXIMUM, defaultValue); 140 } 141 } 142 143 /* __oOo__ */