本文整理汇总了Java中org.opensourcephysics.controls.XMLControl.getObjectClass方法的典型用法代码示例。如果您正苦于以下问题:Java XMLControl.getObjectClass方法的具体用法?Java XMLControl.getObjectClass怎么用?Java XMLControl.getObjectClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensourcephysics.controls.XMLControl
的用法示例。
在下文中一共展示了XMLControl.getObjectClass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVideo
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Opens a named image as an ImageVideo.
*
* @param name the name of the image
* @return a new image video
*/
public Video getVideo(String name) {
// if an XML file with the image name is found, load it in order to get frame duration
String xmlName = XML.stripExtension(name)+".xml"; //$NON-NLS-1$
XMLControl control = new XMLControlElement(xmlName);
if (!control.failedToRead() && control.getObjectClass()==ImageVideo.class) {
return (Video)control.loadObject(null);
}
// else load image(s) directly
try {
Video video = new ImageVideo(name, true);
video.setProperty("video_type", this); //$NON-NLS-1$
return video;
} catch(IOException ex) {
return null;
}
}
示例2: 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;
}
示例3: addSubLibrary
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Adds a sublibrary. Sublibraries are shown as submenus in a Library's Collections menu.
* Sublibraries are not under user control.
*
* @param path the path to the sublibrary
* @return true if successfully added
*/
public boolean addSubLibrary(String path) {
if (subPathList.contains(path))
return false;
synchronized (subPathList) {
XMLControl control = new XMLControlElement(path);
if (control.failedToRead() || control.getObjectClass() != Library.class)
return false;
Library library = new Library();
library.browser = this.browser;
control.loadObject(library);
subPathList.add(path);
subPathToLibraryMap.put(path, library);
}
return true;
}
示例4: importLibrary
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Imports a library. Imported libraries are managed by the user.
*
* @param path the library path
* @return true if successfully imported
*/
public boolean importLibrary(String path) {
if (importedPathList.contains(path))
return false;
XMLControl control = new XMLControlElement(path);
if (control.failedToRead() || control.getObjectClass()!=Library.class)
return false;
Library library = new Library();
library.browser = this.browser;
control.loadObject(library);
return importLibrary(path, library);
}
示例5: loadFits
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Loads fit functions from an XML file.
*
* @param path the path to the XML file
* @param loadAll true to load all fit functions defined in the file, false to let the user choose
* @return the path to the file opened, or null if failed
*/
private String loadFits(String path, boolean loadAll) {
if (path==null) return loadFits();
XMLControl control = new XMLControlElement(path);
if (control.failedToRead()) {
JOptionPane.showMessageDialog(FitBuilder.this,
ToolsRes.getString("Dialog.Invalid.Message"), //$NON-NLS-1$
ToolsRes.getString("Dialog.Invalid.Title"), //$NON-NLS-1$
JOptionPane.ERROR_MESSAGE);
return null;
}
Class<?> type = control.getObjectClass();
if (FitBuilder.class.isAssignableFrom(type)) {
// choose fits to load
if (loadAll || chooseFitFunctions(control, "Load")) { //$NON-NLS-1$
control.loadObject(this);
}
}
else {
JOptionPane.showMessageDialog(FitBuilder.this,
ToolsRes.getString("DatasetCurveFitter.FitBuilder.Dialog.WrongType.Message"), //$NON-NLS-1$
ToolsRes.getString("DatasetCurveFitter.FitBuilder.Dialog.WrongType.Title"), //$NON-NLS-1$
JOptionPane.ERROR_MESSAGE);
}
return path;
}
示例6: autoloadFits
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Loads fit functions from all FitBuilder XMLControl files found in a specified directory.
*
* @param dirPath the directory path
*/
private void autoloadFits(String dirPath) {
if (dirPath==null) return;
File dir = new File(dirPath);
if (!dir.exists()) return;
File[] files = dir.listFiles(xmlFilter);
if (files!=null) {
for (File file: files) {
XMLControl control = new XMLControlElement(file.getPath());
if (control.failedToRead()) {
continue;
}
Class<?> type = control.getObjectClass();
if (type!=null && FitBuilder.class.isAssignableFrom(type)) {
// copy the control for modification if any functions are autoload_off
XMLControl copyControl = new XMLControlElement(control);
String filePath = XML.forwardSlash(file.getAbsolutePath());
eliminateExcludedFunctions(copyControl, filePath);
copyControl.loadObject(this);
}
}
}
}
示例7: findFitFunctions
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Finds fit functions in all FitBuilder XMLControl files in a specified directory.
* Each fit function is String[] {String name, String expression, String description}
*
* @param dirPath the directory path
* @return a map of filePath to list of fit functions
*/
private Map<String, ArrayList<String[]>> findFitFunctions(String dirPath) {
Map<String, ArrayList<String[]>> results = new TreeMap<String, ArrayList<String[]>>();
if (dirPath==null) return results;
File dir = new File(dirPath);
if (!dir.exists()) return results;
File[] files = dir.listFiles(xmlFilter);
if (files!=null) {
for (File file: files) {
XMLControl control = new XMLControlElement(file.getPath());
if (control.failedToRead()) {
continue;
}
Class<?> type = control.getObjectClass();
if (type!=null && FitBuilder.class.isAssignableFrom(type)) {
ArrayList<String[]> functions = new ArrayList<String[]>();
// look through XMLControl for fit functions
for (Object next: control.getPropertyContent()) {
if (next instanceof XMLProperty
&& ((XMLProperty)next).getPropertyName().equals("functions")) { //$NON-NLS-1$
// found FitFunctionPanels
XMLControl[] panels = ((XMLProperty)next).getChildControls();
for (XMLControl panelControl: panels) {
String name = panelControl.getString("name"); //$NON-NLS-1$
String expression = panelControl.getString("description"); //$NON-NLS-1$
String[] data = new String[] {name, expression};
functions.add(data);
}
break;
}
}
// add entry to the results map
results.put(file.getName(), functions);
}
}
}
return results;
}