(Number value)
| 170 | |
| 171 | |
| 172 | public void setValue(Number value) { |
| 173 | if ("int".equals(type)) { |
| 174 | newValue = value.intValue(); |
| 175 | strNewValue = String.format(Locale.US, textFormat, newValue.intValue()); |
| 176 | |
| 177 | } else if ("hex".equals(type)) { |
| 178 | newValue = value.intValue(); |
| 179 | strNewValue = String.format(Locale.US, textFormat, newValue.intValue()); |
| 180 | |
| 181 | } else if ("webcolor".equals(type)) { |
| 182 | newValue = value.intValue(); |
| 183 | // keep only RGB |
| 184 | int val = (newValue.intValue() & 0xffffff); |
| 185 | strNewValue = String.format(Locale.US, textFormat, val); |
| 186 | |
| 187 | } else if ("float".equals(type)) { |
| 188 | BigDecimal bd = new BigDecimal(value.floatValue()); |
| 189 | bd = bd.setScale(decimalPlaces, RoundingMode.HALF_UP); |
| 190 | newValue = bd.floatValue(); |
| 191 | strNewValue = String.format(Locale.US, textFormat, newValue.floatValue()); |
| 192 | } |
| 193 | |
| 194 | // send new data to the server in the sketch |
| 195 | sendNewValue(); |
| 196 | } |
| 197 | |
| 198 | |
| 199 | public void updateColorBox() { |
no test coverage detected