1 /*******************************************************************************
\r
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g3d.property;
\r
14 import java.lang.reflect.InvocationTargetException;
\r
15 import java.lang.reflect.Method;
\r
17 import javax.vecmath.Vector3d;
\r
19 public class VectorPropertyManipulator implements PropertyManipulator {
\r
21 ValueProvider provider;
\r
22 protected Object input;
\r
25 Vector3d editValue = null;
\r
27 public VectorPropertyManipulator(ValueProvider provider, Object input) {
\r
28 this.provider = provider;
\r
33 public int getValueCount() {
\r
38 public String getDescription(int i) {
\r
49 public String getValue(int i) {
\r
51 Vector3d v = _getValue();
\r
55 return Double.toString(v.x);
\r
57 return Double.toString(v.y);
\r
59 return Double.toString(v.z);
\r
61 } catch (Exception e) {
\r
67 public String setValue(String value, int i) {
\r
69 Double d = Double.parseDouble(value);
\r
70 Vector3d v = _getValue();
\r
71 v = new Vector3d(v.x, v.y, v.z);
\r
80 } catch (Exception e) {
\r
81 return e.getMessage();
\r
86 protected void setValue(Vector3d v) throws Exception {
\r
87 provider.setValue(input, v);
\r
90 private Vector3d _getValue() throws Exception{
\r
93 return (Vector3d) provider.getValue(input);
\r
97 public boolean getEditMode() {
\r
102 public void setEditMode(boolean b) {
\r
106 editValue = (Vector3d) provider.getValue(input);
\r
107 } catch (Exception e) {
\r