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 javax.vecmath.Vector3d;
16 import org.simantics.g3d.math.MathTools;
18 public class VectorPropertyManipulator implements PropertyManipulator {
20 ValueProvider provider;
21 protected Object input;
24 Vector3d editValue = null;
26 public VectorPropertyManipulator(ValueProvider provider, Object input) {
27 this.provider = provider;
32 public int getValueCount() {
37 public String getDescription(int i) {
48 public String getValue(int i) {
50 Vector3d v = _getValue();
54 return Double.toString(MathTools.round(v.x, 10));
56 return Double.toString(MathTools.round(v.y, 10));
58 return Double.toString(MathTools.round(v.z, 10));
60 } catch (Exception e) {
66 public String setValue(String value, int i) {
68 Double d = Double.parseDouble(value);
69 Vector3d v = _getValue();
70 v = new Vector3d(v.x, v.y, v.z);
79 } catch (Exception e) {
80 return e.getMessage();
85 protected void setValue(Vector3d v) throws Exception {
86 provider.setValue(input, v);
89 private Vector3d _getValue() throws Exception{
92 return (Vector3d) provider.getValue(input);
96 public boolean getEditMode() {
101 public void setEditMode(boolean b) {
105 editValue = (Vector3d) provider.getValue(input);
106 } catch (Exception e) {