Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23173/src/net/sourceforge/bprocessor/model
Modified Files:
Attributes.java Camera.java
Log Message:
Let camera implement Parametric
Index: Attributes.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Attributes.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Attributes.java 30 Jan 2006 13:04:55 -0000 1.2
--- Attributes.java 30 Jan 2006 14:45:36 -0000 1.3
***************
*** 39,42 ****
--- 39,51 ----
/**
+ * Constructor
+ * @param name The name
+ * @param value The value
+ */
+ public Attributes(String name, Object value) {
+ this(name, value, 0);
+ }
+
+ /**
* @return Returns the name.
*/
Index: Camera.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Camera.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Camera.java 25 Jan 2006 14:46:01 -0000 1.8
--- Camera.java 30 Jan 2006 14:45:36 -0000 1.9
***************
*** 7,10 ****
--- 7,14 ----
package net.sourceforge.bprocessor.model;
+ import java.util.ArrayList;
+ import java.util.Iterator;
+ import java.util.List;
+
import org.apache.log4j.Logger;
***************
*** 13,17 ****
* as well as a up vector
*/
! public class Camera {
/** The 3D view view */
public static final int VIEW_3D = 1;
--- 17,21 ----
* as well as a up vector
*/
! public class Camera implements Parametric {
/** The 3D view view */
public static final int VIEW_3D = 1;
***************
*** 390,392 ****
--- 394,455 ----
return getName();
}
+
+ /**
+ * Set the attributes of the object to the values in the list
+ * @param attributes The attributes to set
+ */
+ public void setAttributes(List attributes) {
+ Iterator iter = attributes.iterator();
+ while (iter.hasNext()) {
+ Attributes a = (Attributes)iter.next();
+ if (a.getName().equals("Name")) {
+ setName((String)a.getValue());
+ } else if (a.getName().equals("Type")) {
+ setType(((String)a.getValue()).equals("Orthographic") ? ORTHOGRAPHIC : PERSPECTIVE);
+ } else if (a.getName().equals("Camera")) {
+ Double x = (Double)iter.next();
+ Double y = (Double)iter.next();
+ Double z = (Double)iter.next();
+ setCamera(new double[]{x.doubleValue(), y.doubleValue(), z.doubleValue()});
+ } else if (a.getName().equals("Center")) {
+ Double x = (Double)iter.next();
+ Double y = (Double)iter.next();
+ Double z = (Double)iter.next();
+ setCenter(new double[]{x.doubleValue(), y.doubleValue(), z.doubleValue()});
+ } else if (a.getName().equals("Roll")) {
+ Double x = (Double)iter.next();
+ Double y = (Double)iter.next();
+ Double z = (Double)iter.next();
+ setRoll(new double[]{x.doubleValue(), y.doubleValue(), z.doubleValue()});
+ } else if (a.getName().equals("Focalwidth")) {
+ setFocalwidth(((Double)a.getValue()).doubleValue());
+ } else {
+ log.error("Wrong attribute for the object " + a);
+ }
+ }
+ }
+
+ /**
+ * Return a list of the attributes in the object
+ * @return the list of attributes for the object
+ */
+ public List getAttributes() {
+ ArrayList res = new ArrayList();
+ res.add(new Attributes("Name", getName()));
+ res.add(new Attributes("Type", type == ORTHOGRAPHIC ? "Orthographic" : "Perspective"));
+ res.add(new Attributes("Camera", null));
+ res.add(new Attributes("X", new Double(getCamera()[0])));
+ res.add(new Attributes("Y", new Double(getCamera()[1])));
+ res.add(new Attributes("Z", new Double(getCamera()[2])));
+ res.add(new Attributes("Center", null));
+ res.add(new Attributes("X", new Double(getCenter()[0])));
+ res.add(new Attributes("Y", new Double(getCenter()[1])));
+ res.add(new Attributes("Z", new Double(getCenter()[2])));
+ res.add(new Attributes("Roll", null));
+ res.add(new Attributes("X", new Double(getRoll()[0])));
+ res.add(new Attributes("Y", new Double(getRoll()[1])));
+ res.add(new Attributes("Z", new Double(getRoll()[2])));
+ res.add(new Attributes("Focalwidth", new Double(getFocalwidth())));
+ return res;
+ }
}
|