Esempio n. 1
0
 public Object loadObject(XMLControl control, Object obj) {
   Style style = (Style) obj;
   style.setLineColor((Color) control.getObject("line color"));
   style.setLineWidth((float) control.getDouble("line width"));
   style.setFillColor((Color) control.getObject("fill color"));
   style.setResolution(
       (org.opensourcephysics.display3d.core.Resolution) control.getObject("resolution"));
   style.setDrawingFill(control.getBoolean("drawing fill"));
   style.setDrawingLines(control.getBoolean("drawing lines"));
   return obj;
 }
Esempio n. 2
0
 public Object loadObject(XMLControl control, Object obj) {
   VisualizationHints hints = (VisualizationHints) obj;
   hints.setDecorationType(control.getInt("decoration type")); // $NON-NLS-1$
   hints.setCursorType(control.getInt("cursor type")); // $NON-NLS-1$
   hints.setRemoveHiddenLines(control.getBoolean("remove hidden lines")); // $NON-NLS-1$
   hints.setAllowQuickRedraw(control.getBoolean("allow quick redraw")); // $NON-NLS-1$
   hints.setUseColorDepth(control.getBoolean("use color depth")); // $NON-NLS-1$
   hints.setShowCoordinates(control.getInt("show coordinates at")); // $NON-NLS-1$
   hints.setXFormat(control.getString("x format")); // $NON-NLS-1$
   hints.setYFormat(control.getString("y format")); // $NON-NLS-1$
   hints.setZFormat(control.getString("z format")); // $NON-NLS-1$
   hints.setAxesLabels((String[]) control.getObject("axes labels")); // $NON-NLS-1$
   return obj;
 }
Esempio n. 3
0
 public Object loadObject(XMLControl control, Object obj) {
   super.loadObject(control, obj);
   ElementTrail element = (ElementTrail) obj;
   element.setMaximumPoints(control.getInt("maximum")); // $NON-NLS-1$
   element.setConnected(control.getBoolean("connected")); // $NON-NLS-1$
   // This implies element.clear()
   return obj;
 }
Esempio n. 4
0
 /**
  * Loads a VideoClip with data from an XMLControl.
  *
  * @param element the element
  * @param obj the object
  * @return the loaded object
  */
 public Object loadObject(XMLControl control, Object obj) {
   StepperClipControl clipControl = (StepperClipControl) obj;
   // set rate
   double rate = control.getDouble("rate"); // $NON-NLS-1$
   if (rate != Double.NaN) {
     clipControl.setRate(rate);
   }
   // set dt
   double dt = control.getDouble("delta_t"); // $NON-NLS-1$
   if (dt != Double.NaN) {
     clipControl.setFrameDuration(dt);
   }
   // set looping and playing
   clipControl.setLooping(control.getBoolean("looping")); // $NON-NLS-1$
   return obj;
 }
Esempio n. 5
0
 /**
  * Loads an object with data from an XMLControl.
  *
  * @param control the control
  * @param obj the object
  * @return the loaded object
  */
 public Object loadObject(XMLControl control, Object obj) {
   // load track data
   XML.getLoader(TTrack.class).loadObject(control, obj);
   ParticleModel p = (ParticleModel) obj;
   p.mass = control.getDouble("mass"); // $NON-NLS-1$
   p.inspectorX = control.getInt("inspector_x"); // $NON-NLS-1$
   p.inspectorY = control.getInt("inspector_y"); // $NON-NLS-1$
   p.inspectorH = control.getInt("inspector_h"); // $NON-NLS-1$
   p.showInspector = control.getBoolean("inspector_visible"); // $NON-NLS-1$
   Parameter[] params = (Parameter[]) control.getObject("user_parameters"); // $NON-NLS-1$
   p.getParamEditor().setParameters(params);
   params = (Parameter[]) control.getObject("initial_values"); // $NON-NLS-1$
   // remove trailing "0" from initial condition parameters
   for (int i = 0; i < params.length; i++) {
     Parameter param = params[i];
     String name = param.getName();
     int n = name.lastIndexOf("0"); // $NON-NLS-1$
     if (n > -1) {
       // replace parameter with new one
       name = name.substring(0, n);
       Parameter newParam = new Parameter(name, param.getExpression());
       newParam.setDescription(param.getDescription());
       newParam.setNameEditable(false);
       params[i] = newParam;
     }
   }
   p.getInitEditor().setParameters(params);
   UserFunction[] functions =
       (UserFunction[]) control.getObject("main_functions"); // $NON-NLS-1$
   p.getFunctionEditor().setMainFunctions(functions);
   functions = (UserFunction[]) control.getObject("support_functions"); // $NON-NLS-1$
   if (functions != null) {
     for (int i = 0; i < functions.length; i++) {
       p.getFunctionEditor().addObject(functions[i], false);
     }
   }
   p.functionPanel.refreshFunctions();
   int n = control.getInt("start_frame"); // $NON-NLS-1$
   if (n != Integer.MIN_VALUE) p.startFrame = n;
   else {
     p.startFrameUndefined = true;
   }
   n = control.getInt("end_frame"); // $NON-NLS-1$
   if (n != Integer.MIN_VALUE) p.endFrame = n;
   return obj;
 }