示例#1
0
 /**
  * Saves an object's data to an XMLControl.
  *
  * @param control the control to save to
  * @param obj the object to save
  */
 public void saveObject(XMLControl control, Object obj) {
   ParticleModel p = (ParticleModel) obj;
   // save mass
   control.setValue("mass", p.getMass()); // $NON-NLS-1$
   // save track data
   XML.getLoader(TTrack.class).saveObject(control, obj);
   // save parameters, initial values and functions
   Parameter[] params = p.getParamEditor().getParameters();
   control.setValue("user_parameters", params); // $NON-NLS-1$
   Parameter[] inits = p.getInitEditor().getParameters();
   control.setValue("initial_values", inits); // $NON-NLS-1$
   UserFunction[] functions = p.getFunctionEditor().getMainFunctions();
   control.setValue("main_functions", functions); // $NON-NLS-1$
   functions = p.getFunctionEditor().getSupportFunctions();
   if (functions.length > 0) control.setValue("support_functions", functions); // $NON-NLS-1$
   // save start and end frames (if custom)
   if (p.startFrame > 0) control.setValue("start_frame", p.startFrame); // $NON-NLS-1$
   if (p.endFrame < Integer.MAX_VALUE) control.setValue("end_frame", p.endFrame); // $NON-NLS-1$
   // save inspector size and position
   if (p.inspector != null && p.trackerPanel != null && p.trackerPanel.getTFrame() != null) {
     // save inspector location relative to frame
     TFrame frame = p.trackerPanel.getTFrame();
     int x = p.inspector.getLocation().x - frame.getLocation().x;
     int y = p.inspector.getLocation().y - frame.getLocation().y;
     control.setValue("inspector_x", x); // $NON-NLS-1$
     control.setValue("inspector_y", y); // $NON-NLS-1$  		
     control.setValue("inspector_h", p.inspector.getHeight()); // $NON-NLS-1$
     control.setValue("inspector_visible", p.inspector.isVisible()); // $NON-NLS-1$
   }
 }
 /**
  * Saves object data to an XMLControl.
  *
  * @param control the control to save to
  * @param obj the object to save
  */
 public void saveObject(XMLControl xmlControl, Object obj) {
   OSPControl ospControl = (OSPControl) obj;
   saveControlProperites(xmlControl, ospControl);
   // save the model if the control is the top level
   if (xmlControl.getLevel() == 0) {
     xmlControl.setValue("model", ospControl.model); // $NON-NLS-1$
   }
 }
 protected void saveControlProperites(XMLControl xmlControl, OSPControl ospControl) {
   // save the parameters
   Iterator it = ospControl.getPropertyNames().iterator();
   while (it.hasNext()) {
     String name = (String) it.next();
     Object val = ospControl.getObject(name);
     if (val.getClass() == DoubleArray.class) {
       xmlControl.setValue(name, ((DoubleArray) val).getArray());
     } else if (val.getClass() == IntegerArray.class) {
       xmlControl.setValue(name, ((IntegerArray) val).getArray());
     } else if (val.getClass() == Boolean.class) {
       xmlControl.setValue(name, ((Boolean) val).booleanValue());
     } else if (val.getClass() == Double.class) {
       xmlControl.setValue(name, ((Double) val).doubleValue());
     } else if (val.getClass() == Integer.class) {
       xmlControl.setValue(name, ((Integer) val).intValue());
     } else if (val.getClass().isArray()) {
       xmlControl.setValue(name, val);
     } else {
       xmlControl.setValue(name, val);
     }
     // xmlControl.setValue(name, val.toString());
   }
 }