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 public class VectorPropertyManipulator implements PropertyManipulator {
18 ValueProvider provider;
19 protected Object input;
22 Vector3d editValue = null;
24 public VectorPropertyManipulator(ValueProvider provider, Object input) {
25 this.provider = provider;
30 public int getValueCount() {
35 public String getDescription(int i) {
46 public String getValue(int i) {
48 Vector3d v = _getValue();
52 return Double.toString(v.x);
54 return Double.toString(v.y);
56 return Double.toString(v.z);
58 } catch (Exception e) {
64 public String setValue(String value, int i) {
66 Double d = Double.parseDouble(value);
67 Vector3d v = _getValue();
68 v = new Vector3d(v.x, v.y, v.z);
77 } catch (Exception e) {
78 return e.getMessage();
83 protected void setValue(Vector3d v) throws Exception {
84 provider.setValue(input, v);
87 private Vector3d _getValue() throws Exception{
90 return (Vector3d) provider.getValue(input);
94 public boolean getEditMode() {
99 public void setEditMode(boolean b) {
103 editValue = (Vector3d) provider.getValue(input);
104 } catch (Exception e) {