当前位置: 首页>>代码示例>>Java>>正文


Java XMLControl类代码示例

本文整理汇总了Java中org.opensourcephysics.controls.XMLControl的典型用法代码示例。如果您正苦于以下问题:Java XMLControl类的具体用法?Java XMLControl怎么用?Java XMLControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMLControl类属于org.opensourcephysics.controls包,在下文中一共展示了XMLControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
public Object loadObject(XMLControl control, Object obj) {
  DatasetManager dsm = (DatasetManager) obj;
  dsm.connected = control.getBoolean("connected");      //$NON-NLS-1$
  dsm.sorted = control.getBoolean("sorted");            //$NON-NLS-1$
  dsm.markerShape = control.getInt("maker_shape");      //$NON-NLS-1$
  dsm.stride = control.getInt("stride");                //$NON-NLS-1$
  dsm.linked = control.getBoolean("linked");            //$NON-NLS-1$
  dsm.xColumnName = control.getString("x_column_name"); //$NON-NLS-1$
  dsm.yColumnName = control.getString("y_column_name"); //$NON-NLS-1$
  dsm.setName(control.getString("data_name")); //$NON-NLS-1$
  if (control.getPropertyNames().contains("id")) { //$NON-NLS-1$
  	dsm.setID(control.getInt("id")); //$NON-NLS-1$
  }
  dsm.removeDatasets();
  Collection<?> datasets = Collection.class.cast(control.getObject("datasets")); //$NON-NLS-1$
  if(datasets!=null) {
    Iterator<?> it = datasets.iterator();
    while(it.hasNext()) {
      dsm.datasets.add((Dataset) it.next());
    }
  }
  return obj;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:24,代码来源:DatasetManager.java

示例2: inspectSelectedNode

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
 * Displays the properties of the selected node in an xml inspector.
 */
private void inspectSelectedNode() {
  Node node = getSelectedNode();
  if(node==null) {
    node = root;
  }
  Object obj = node.node;
  if(obj==null) {
    obj = builder.new LaunchSet(builder, builder.tabSetName);
  }
  XMLControl xml = new XMLControlElement(obj);
  XMLTreePanel treePanel = new XMLTreePanel(xml, false);
  inspector.setContentPane(treePanel);
  String name = (node!=root) ? node.node.getFileName() : builder.tabSetName;
  name = XML.getResolvedPath(name, Launcher.tabSetBasePath);
  inspector.setTitle(LaunchRes.getString("Inspector.Title.File")+" \""+name+"\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  inspector.setVisible(true);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:21,代码来源:LaunchSaver.java

示例3: setVideo

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
 * Sets the video.
 *
 * @param newVideo the video
 * @param playAllSteps true to play all steps
 */
public void setVideo(Video newVideo, boolean playAllSteps) {
  if(newVideo==video) {
    return;
  }
  Video prev = video;
  VideoClip prevClip = getPlayer().getVideoClip();
  VideoClip newClip = new VideoClip(newVideo);
  if (newVideo==null && prevClip!=null) {
  	XMLControl control = new XMLControlElement(prevClip);
  	control.setValue("video", null); //$NON-NLS-1$
  	control.loadObject(newClip);
  }
  newClip.setPlayAllSteps(playAllSteps);    
  getPlayer().setVideoClip(newClip);
  if(prev!=null) {
    prev.dispose();
  }
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:25,代码来源:VideoPanel.java

示例4: loadObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
 * Loads a DrawingPanel with data from an XMLControl.
 *
 * @param control the control
 * @param obj the object
 * @return the loaded object
 */
public Object loadObject(XMLControl control, Object obj) {
  DrawingPanel panel = (DrawingPanel) obj;
  double xmin = control.getDouble("preferred x min"); //$NON-NLS-1$
  double xmax = control.getDouble("preferred x max"); //$NON-NLS-1$
  double ymin = control.getDouble("preferred y min"); //$NON-NLS-1$
  double ymax = control.getDouble("preferred y max"); //$NON-NLS-1$
  panel.setPreferredMinMax(xmin, xmax, ymin, ymax); // this sets autoscale to false
  panel.squareAspect = control.getBoolean("square aspect"); //$NON-NLS-1$
  if(control.getBoolean("autoscale x")) { //$NON-NLS-1$
    panel.setAutoscaleX(true);
  }
  if(control.getBoolean("autoscale y")) { //$NON-NLS-1$
    panel.setAutoscaleY(true);
  }
  // load the drawables
  Collection<?> drawables = Collection.class.cast(control.getObject("drawables")); //$NON-NLS-1$
  if(drawables!=null) {
    panel.clear();
    Iterator<?> it = drawables.iterator();
    while(it.hasNext()) {
      panel.addDrawable((Drawable) it.next());
    }
  }
  return obj;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:33,代码来源:DrawingPanel.java

示例5: saveObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
public void saveObject(XMLControl control, Object obj) {
  InteractiveShape interactiveShape = (InteractiveShape) obj;
  control.setValue("geometry", interactiveShape.shapeClass);      //$NON-NLS-1$
  control.setValue("x", interactiveShape.x);                      //$NON-NLS-1$
  control.setValue("y", interactiveShape.y);                      //$NON-NLS-1$
  control.setValue("width", interactiveShape.width);              //$NON-NLS-1$
  control.setValue("height", interactiveShape.height);            //$NON-NLS-1$
  control.setValue("x offset", interactiveShape.xoff);            //$NON-NLS-1$
  control.setValue("y offset", interactiveShape.yoff);            //$NON-NLS-1$
  control.setValue("theta", interactiveShape.theta);              //$NON-NLS-1$
  control.setValue("pixel sized", interactiveShape.pixelSized);   //$NON-NLS-1$
  control.setValue("is enabled", interactiveShape.isEnabled());   //$NON-NLS-1$
  control.setValue("is measured", interactiveShape.isMeasured()); //$NON-NLS-1$
  control.setValue("color", interactiveShape.color);              //$NON-NLS-1$
  Shape shape = AffineTransform.getRotateInstance(-interactiveShape.theta, interactiveShape.x, interactiveShape.y).createTransformedShape(interactiveShape.shape);
  control.setValue("general path", shape); //$NON-NLS-1$
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:18,代码来源:InteractiveShape.java

示例6: loadObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
public Object loadObject(XMLControl control, Object obj) {
  InteractiveShape interactiveShape = (InteractiveShape) obj;
  String type = control.getString("geometry");                                                 //$NON-NLS-1$
  double x = control.getDouble("x");                                                           //$NON-NLS-1$
  double y = control.getDouble("y");                                                           //$NON-NLS-1$
  double theta = control.getDouble("theta");                                                   //$NON-NLS-1$
  Shape shape = getShape(type, x, y, control.getDouble("width"), control.getDouble("height")); //$NON-NLS-1$ //$NON-NLS-2$
  if(shape==null) {                                                           // check for special geometry
    interactiveShape.shape = (GeneralPath) control.getObject("general path"); //$NON-NLS-1$
  } else {
    interactiveShape.shape = shape;
  }
  // the shape should already be scaled so just set the instatance fields
  interactiveShape.width = control.getDouble("width");   //$NON-NLS-1$
  interactiveShape.height = control.getDouble("height"); //$NON-NLS-1$
  interactiveShape.xoff = control.getDouble("x offset"); //$NON-NLS-1$
  interactiveShape.yoff = control.getDouble("y offset"); //$NON-NLS-1$
  interactiveShape.x = x;
  interactiveShape.y = y;
  interactiveShape.setPixelSized(control.getBoolean("pixel sized")); //$NON-NLS-1$
  interactiveShape.setEnabled(control.getBoolean("is enabled"));     //$NON-NLS-1$
  interactiveShape.setMeasured(control.getBoolean("is measured"));   //$NON-NLS-1$
  interactiveShape.color = (Color) control.getObject("color"); //$NON-NLS-1$
  interactiveShape.setTheta(theta); // orient the shape
  return obj;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:27,代码来源:InteractiveShape.java

示例7: saveObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
public void saveObject(XMLControl control, Object obj) {
  ComplexDataset data = (ComplexDataset) obj;
  control.setValue("points", data.getPoints());            //$NON-NLS-1$
  // control.setValue("x_points", data.getXPoints());
  // control.setValue("y_points", data.getYPoints());
  control.setValue("marker_shape", data.getMarkerShape()); //$NON-NLS-1$
  control.setValue("marker_size", data.getMarkerSize());   //$NON-NLS-1$
  control.setValue("sorted", data.isSorted());             //$NON-NLS-1$
  control.setValue("connected", data.isConnected());       //$NON-NLS-1$
  control.setValue("name", data.name);                     //$NON-NLS-1$
  control.setValue("x_name", data.xColumnName);            //$NON-NLS-1$
  control.setValue("re_name", data.reColumnName);          //$NON-NLS-1$
  control.setValue("im_name", data.imColumnName);          //$NON-NLS-1$
  control.setValue("line_color", data.lineColor);          //$NON-NLS-1$
  control.setValue("index", data.index);                   //$NON-NLS-1$
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:17,代码来源:ComplexDataset.java

示例8: clone

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
 * Returns a clone of the specified video.
 *
 * @param video the video to clone
 * @return the clone
 */
public static Video clone(Video video) {
  if(video==null) {
    return null;
  }
  // ImageVideo is special case since may have pasted images
  if(video instanceof ImageVideo) {
    ImageVideo oldVid = (ImageVideo) video;
    ImageVideo newVid = new ImageVideo(oldVid.getImages());
    newVid.rawImage = newVid.images[0];
    Collection<Filter> filters = video.getFilterStack().getFilters();
    if(filters!=null) {
      Iterator<Filter> it = filters.iterator();
      while(it.hasNext()) {
        Filter filter = it.next();
        newVid.getFilterStack().addFilter(filter);
      }
    }
    return newVid;
  }
  XMLControl control = new XMLControlElement(video);
  return(Video) new XMLControlElement(control).loadObject(null);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:29,代码来源:VideoIO.java

示例9: saveObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
 * Saves ImageCoordSystem data to an XMLControl.
 *
 * @param control the control to save to
 * @param obj the ImageCoordSystem object to save
 */
public void saveObject(XMLControl control, Object obj) {
  ImageCoordSystem coords = (ImageCoordSystem) obj;
  control.setValue("fixedorigin", coords.isFixedOrigin()); //$NON-NLS-1$
  control.setValue("fixedangle", coords.isFixedAngle());   //$NON-NLS-1$
  control.setValue("fixedscale", coords.isFixedScale());   //$NON-NLS-1$
  control.setValue("locked", coords.isLocked());           //$NON-NLS-1$
  
  // save frame data: frame 0 and key frames only
  int count = coords.getLength();
  if(coords.isFixedAngle()&&coords.isFixedOrigin()&&coords.isFixedScale()) {
    count = 1;
  }
  FrameData[] data = new FrameData[count];
  for(int n = 0; n<count; n++) {
  	if (n==0 || coords.keyFrames.contains(n)) {
  		data[n] = new FrameData(coords, n);
  	}
  }
  control.setValue("framedata", data); //$NON-NLS-1$
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:27,代码来源:ImageCoordSystem.java

示例10: addOSPLibrary

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
 * Adds an OSP-sponsored library. OSP libraries are not under user control.
 * 
 * @param path the library path
 * @return true if successfully added
 */
public boolean addOSPLibrary(String path) {		
 	if (ospPathList.contains(path))
 		return false;
 	synchronized (ospPathList) {
		XMLControl control = new XMLControlElement(path);
		if (control.failedToRead() || control.getObjectClass() != Library.class) {
			return false;
		}
		Library library = new Library();
		control.loadObject(library);
		library.browser = this.browser;
		ospPathList.add(path);
		ospPathToLibraryMap.put(path, library);
	}
 	return true;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:23,代码来源:Library.java

示例11: loadObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
public Object loadObject(XMLControl control, Object obj) {
  Histogram his = (Histogram) obj;
  double[] bins = (double[]) control.getObject("bins"); //$NON-NLS-1$
  double[] vals = (double[]) control.getObject("vals"); //$NON-NLS-1$
  his.name = control.getString("name");                           //$NON-NLS-1$
  his.xColumnName = control.getString("x_column_name");           //$NON-NLS-1$
  his.yColumnName = control.getString("y_column_name");           //$NON-NLS-1$
  his.binColumnName = control.getString("bin_column_name");       //$NON-NLS-1$
  his.logScale = control.getBoolean("log_scale");                 //$NON-NLS-1$
  his.discrete = control.getBoolean("discrete");                  //$NON-NLS-1$
  his.adjustForWidth = control.getBoolean("adjust_for_width");    //$NON-NLS-1$
  his.binFillColor = (Color) control.getObject("bin_fill_color"); //$NON-NLS-1$
  his.binEdgeColor = (Color) control.getObject("bin_edge_color"); //$NON-NLS-1$
  his.binStyle = control.getInt("bin_style");                     //$NON-NLS-1$
  his.binWidth = control.getDouble("bin_width");                  //$NON-NLS-1$
  his.binOffset = control.getDouble("bin_offset");                //$NON-NLS-1$
  his.adjustForWidth = control.getBoolean("adjust_for_width");    //$NON-NLS-1$
  if((bins!=null)&&(vals!=null)) {
    for(int i = 0, n = bins.length; i<n; i++) {
      his.append(bins[i], vals[i]);
    }
  }
  return obj;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:25,代码来源:Histogram.java

示例12: export

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
public void export(File file, List<Object> data) {
  FileWriter fw = null;
  try {
    fw = new FileWriter(file);
  } catch(IOException ex) {
    JOptionPane.showMessageDialog(null, ToolsRes.getString("ExportFormat.Dialog.WriteError.Message"), //$NON-NLS-1$
      ToolsRes.getString("ExportFormat.Dialog.WriteError.Title"),                                     //$NON-NLS-1$
        JOptionPane.ERROR_MESSAGE);
    return;
  }
  PrintWriter pw = new PrintWriter(fw);
  Iterator<Object> it = data.iterator();
  while(it.hasNext()) {
    XMLControl control = new XMLControlElement(it.next()); // convert the data to xml
    pw.print(control.toXML());
    pw.println();
  }
  pw.close();
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:20,代码来源:ExportXMLFormat.java

示例13: saveObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
     * Saves object data in an XMLControl.
     *
     * @param control the control to save to
     * @param obj the object to save
     */
    public void saveObject(XMLControl control, Object obj) {
      VideoClip clip = (VideoClip) obj;
      Video video = clip.getVideo();
      if(video!=null) {
        if(video instanceof ImageVideo) {
          ImageVideo vid = (ImageVideo) video;
          if(vid.isFileBased()) {
            control.setValue("video", video); //$NON-NLS-1$
          }
  	      control.setValue("video_framecount", clip.getFrameCount()); //$NON-NLS-1$
        } else {
          control.setValue("video", video);   //$NON-NLS-1$
  	      control.setValue("video_framecount", video.getFrameCount()); //$NON-NLS-1$
        }
      }
      control.setValue("startframe", clip.getStartFrameNumber()); //$NON-NLS-1$
      control.setValue("stepsize", clip.getStepSize());           //$NON-NLS-1$
      control.setValue("stepcount", clip.getStepCount());         //$NON-NLS-1$
      control.setValue("starttime", clip.startTimeIsSaved? 			  //$NON-NLS-1$
      		clip.savedStartTime: clip.getStartTime());
//      control.setValue("frameshift", clip.getFrameShift());         //$NON-NLS-1$
      control.setValue("readout", clip.readoutType);         //$NON-NLS-1$
      control.setValue("playallsteps", clip.playAllSteps);         //$NON-NLS-1$
    }
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:31,代码来源:VideoClip.java

示例14: loadObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
public Object loadObject(XMLControl control, Object obj) {
  UserFunction f = (UserFunction) obj;
  f.setName(control.getString("name"));               //$NON-NLS-1$
  f.setDescription(control.getString("description")); //$NON-NLS-1$
  if(control.getPropertyNames().contains("name_editable")) { //$NON-NLS-1$
    f.setNameEditable(control.getBoolean("name_editable"));  //$NON-NLS-1$
  }
  String[] names = (String[]) control.getObject("parameter_names");   //$NON-NLS-1$
  if(names!=null) {
    double[] values = (double[]) control.getObject("parameter_values"); //$NON-NLS-1$
    String[] desc = (String[]) control.getObject("parameter_descriptions");   //$NON-NLS-1$
    f.setParameters(names, values, desc);
  }
  String[] vars = (String[]) control.getObject("variables"); //$NON-NLS-1$
  if(vars==null) {                              // for legacy code
    String var = control.getString("variable"); //$NON-NLS-1$
    vars = new String[] {var};
  }
  f.setExpression(control.getString("expression"), vars); //$NON-NLS-1$
  double[] coeff = (double[])control.getObject("polynomial"); //$NON-NLS-1$
  if (coeff!=null) {
  	f.polynomial = new KnownPolynomial(coeff);
  }
  return obj;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:26,代码来源:UserFunction.java

示例15: saveObject

import org.opensourcephysics.controls.XMLControl; //导入依赖的package包/类
/**
 * Saves data to an XMLControl.
 *
 * @param control the control to save to
 * @param obj the filter to save
 */
public void saveObject(XMLControl control, Object obj) {
	RadialDistortionFilter filter = (RadialDistortionFilter) obj;
	
	control.setValue("fixed_radius", filter.fixedRadius); //$NON-NLS-1$
	control.setValue("input_type", filter.sourceProjectionType); //$NON-NLS-1$
	control.setValue("input_fov", filter.sourceFOV); //$NON-NLS-1$
	control.setValue("output_type", filter.outputProjectionType); //$NON-NLS-1$
	control.setValue("color", filter.color); //$NON-NLS-1$
	
  if((filter.frame!=null) && (filter.inspector!=null) && filter.inspector.isVisible()) {
    int x = filter.inspector.getLocation().x-filter.frame.getLocation().x;
    int y = filter.inspector.getLocation().y-filter.frame.getLocation().y;
    control.setValue("inspector_x", x); //$NON-NLS-1$
    control.setValue("inspector_y", y); //$NON-NLS-1$
  }
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:23,代码来源:RadialDistortionFilter.java


注:本文中的org.opensourcephysics.controls.XMLControl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。