1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g3d.property;
14 import org.simantics.g3d.math.MathTools;
16 public class DoublePropertyManipulator implements PropertyManipulator {
18 ValueProvider provider;
22 String editValue = null;
24 public DoublePropertyManipulator(ValueProvider provider, Object input) {
25 this.provider = provider;
30 public int getValueCount() {
35 public String getDescription(int i) {
42 public String getValue(int i) {
46 Object value = provider.getValue(input);
47 if (value == null) return null;
48 if (value instanceof Double)
49 return Double.toString(MathTools.round((Double)value, 10));
50 return value.toString();
51 } catch (Exception e) {
57 public String setValue(String value, int i) {
60 provider.setValue(input, Double.parseDouble(value));
61 } catch (Exception e) {
62 return e.getMessage();
68 public boolean getEditMode() {
73 public void setEditMode(boolean b) {
77 Object value = provider.getValue(input);
78 editValue = value.toString();
79 } catch (Exception e) {