01: /*
02: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/sourcecontrol/spec/javax/media/j3d/PositionPathInterpolator.java,v 1.1 2005/04/20 22:21:24 paulby Exp $
03: *
04: * Sun Public License Notice
05: *
06: * The contents of this file are subject to the Sun Public License Version
07: * 1.0 (the "License"). You may not use this file except in compliance with
08: * the License. A copy of the License is available at http://www.sun.com/
09: *
10: * The Original Code is the Java 3D(tm) Scene Graph Editor.
11: * The Initial Developer of the Original Code is Jan Becicka.
12: * Portions created by Jan Becicka are Copyright (C) 2002.
13: * All Rights Reserved.
14: *
15: * Contributor(s): Jan Becicka.
16: *
17: **/
18: package org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.spec.javax.media.j3d;
19:
20: import org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.NamePool;
21: import org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol.BeanCodeGenerator;
22: import javax.vecmath.Point3f;
23:
24: /**
25: *
26: * @author Jan Becicka
27: * @version
28: */
29: public class PositionPathInterpolator extends BeanCodeGenerator {
30:
31: javax.media.j3d.PositionPathInterpolator ppi;
32: float[] knots;
33: Point3f[] positions;
34:
35: public PositionPathInterpolator(Object bean, NamePool naming) {
36: super (bean, naming);
37: }
38:
39: protected void init() {
40: ppi = (javax.media.j3d.PositionPathInterpolator) bean;
41: int len = ppi.getArrayLengths();
42: knots = new float[len];
43: positions = new Point3f[len];
44: //ppi.getKnots(knots);
45: //ppi.getPositions(positions); it throws NPE. I'm using this workaround
46: for (int i = 0; i < len; i++) {
47: positions[i] = new Point3f();
48: ppi.getPosition(i, positions[i]);
49: knots[i] = ppi.getKnot(i);
50: }
51:
52: }
53:
54: /** Override this method, if you want to create parametric constructor constr
55: */
56: protected void createConstructionCode() {
57: StringBuffer buf = new StringBuffer();
58:
59: buf.append(getFieldName() + " = new " + beanClassName);
60: buf.append("(" + createIdentifier(ppi.getAlpha()) + ", ");
61: buf.append(createIdentifier(ppi.getTarget()) + ", ");
62: buf.append(createIdentifier(ppi.getAxisOfTranslation()) + ", ");
63: buf.append(createIdentifier(knots) + ", ");
64: buf.append(createIdentifier(positions) + ");\n");
65: constructionCode = buf.toString();
66: }
67:
68: /** Override this method, if you want to have different default instance (e.g. YourNean(10))
69: * @return instance of bean
70: */
71: protected Object createDefaultInstanceOfBean() {
72:
73: return new javax.media.j3d.PositionPathInterpolator(ppi
74: .getAlpha(), ppi.getTarget(), ppi
75: .getAxisOfTranslation(), knots, positions);
76: }
77:
78: /** creates setters e.g. <CODE>t.setTransform(..);</CODE>
79: */
80: protected void createCustomizationCode() {
81: //do nothing
82: }
83: }
|