本文整理汇总了Java中org.opensourcephysics.controls.XMLControlElement.loadObject方法的典型用法代码示例。如果您正苦于以下问题:Java XMLControlElement.loadObject方法的具体用法?Java XMLControlElement.loadObject怎么用?Java XMLControlElement.loadObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensourcephysics.controls.XMLControlElement
的用法示例。
在下文中一共展示了XMLControlElement.loadObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Sends a job to this tool and specifies a tool to reply to.
*
* @param job the Job
* @param replyTo the tool to notify when the job is complete (may be null)
* @throws RemoteException
*/
public void send(Job job, Tool replyTo) throws RemoteException {
XMLControlElement control = new XMLControlElement(job.getXML());
if(control.failedToRead()||(control.getObjectClass()==Object.class)) {
return;
}
// log the job in
jobManager.log(job, replyTo);
// if control is for a Data object, load it into this tab
if(Data.class.isAssignableFrom(control.getObjectClass())) {
Data data = (Data) control.loadObject(null, true, true);
loadData(data, replaceColumnsWithMatchingNames);
jobManager.associate(job, dataManager);
refreshGUI();
}
// if control is for DataToolTab class, load this tab from control
else if(DataToolTab.class.isAssignableFrom(control.getObjectClass())) {
control.loadObject(this);
refreshGUI();
}
}
示例2: loadResource
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Loads a library resource from a given path.
*
* @param path the path
* @return the resource, or null if failed
*/
protected LibraryResource loadResource(String path) {
isRecentPathXML = false;
File targetFile = new File(path);
if (targetFile.isDirectory()) {
return createCollection(targetFile, targetFile, dlFileFilter);
}
if (LibraryComPADRE.isComPADREPath(path)) {
return LibraryComPADRE.getCollection(path);
}
XMLControlElement control = new XMLControlElement(path);
if (!control.failedToRead()
&& control.getObjectClass()!=null
&& LibraryResource.class.isAssignableFrom(control.getObjectClass())) {
isRecentPathXML = true;
return (LibraryResource)control.loadObject(null);
}
return createResource(targetFile, targetFile.getParentFile(), dlFileFilter);
}
示例3: decrypt
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Decrypts the specified XMLcontrol.
*
* @param control the XMLControl
* @return the decrypted control
*/
private XMLControlElement decrypt(XMLControlElement control) {
if(control.getObjectClass()!=Cryptic.class) {
return control;
}
Cryptic cryptic = (Cryptic) control.loadObject(null);
// get the decrypted xml, make new control and set password
String xml = cryptic.decrypt();
XMLControlElement decrypted = new XMLControlElement(xml);
return decrypted;
}
示例4: hasPastableData
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Determines if the clipboard has pastable data.
*
* @return true if data is pastable
*/
protected boolean hasPastableData() {
controlContainsData = false;
String dataString = paste();
boolean hasData = dataString!=null;
if(hasData) {
if(!dataString.startsWith("<?xml")) { //$NON-NLS-1$
addableData = parseData(dataString, null);
hasData = addableData!=null;
} else {
control = new XMLControlElement();
control.readXML(dataString);
Class<?> type = control.getObjectClass();
if(Data.class.isAssignableFrom(type)) {
addableData = (Data) control.loadObject(null);
} else if(!DataToolTab.class.isAssignableFrom(type)) {
// find all Data objects in the control
XMLTree tree = new XMLTree(control);
tree.setHighlightedClass(Data.class);
tree.selectHighlightedProperties();
if(!tree.getSelectedProperties().isEmpty()) {
controlContainsData = true;
}
}
hasData = (addableData!=null)||DataToolTab.class.isAssignableFrom(type)||controlContainsData;
}
}
return hasData;
}
示例5: open
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Loads data or a video from a specified file into a VideoPanel.
* If file is null, a file chooser is displayed.
*
* @param file the file to be loaded
* @param vidPanel the video panel
* @return the file opened
*/
public static File open(File file, VideoPanel vidPanel) {
if(file==null) {
File[] files = getChooserFiles("open"); //$NON-NLS-1$
if(files!=null) {
file = files[0];
}
}
if(file==null) {
return null;
}
if(videoFileFilter.accept(file)) { // load video
VideoType[] types = getVideoTypes();
Video video = null;
for(int i = 0; i<types.length; i++) {
video = types[i].getVideo(file.getAbsolutePath());
if(video!=null) {
OSPLog.info(file.getName()+" opened as type "+types[i].getDescription()); //$NON-NLS-1$
break;
}
OSPLog.info(file.getName()+" failed as type "+types[i].getDescription()); //$NON-NLS-1$
}
if(video!=null) {
vidPanel.setVideo(video);
vidPanel.repaint();
} else {
JOptionPane.showMessageDialog(vidPanel, MediaRes.getString("VideoIO.Dialog.BadVideo.Message")+ //$NON-NLS-1$
ResourceLoader.getNonURIPath(XML.getAbsolutePath(file)));
}
}
else { // load data
XMLControlElement control = new XMLControlElement();
control.read(file.getAbsolutePath());
Class<?> type = control.getObjectClass();
if(VideoPanel.class.isAssignableFrom(type)) {
vidPanel.setDataFile(file);
control.loadObject(vidPanel);
} else if(!control.failedToRead()) {
JOptionPane.showMessageDialog(vidPanel, "\""+file.getName()+"\" "+ //$NON-NLS-1$ //$NON-NLS-2$
MediaRes.getString("VideoIO.Dialog.XMLMismatch.Message"), //$NON-NLS-1$
MediaRes.getString("VideoIO.Dialog.XMLMismatch.Title"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
return null;
} else {
JOptionPane.showMessageDialog(vidPanel, MediaRes.getString("VideoIO.Dialog.BadFile.Message")+ //$NON-NLS-1$
ResourceLoader.getNonURIPath(XML.getAbsolutePath(file)));
}
vidPanel.changed = false;
}
return file;
}
示例6: getSelfContainedData
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Loads self-contained Data objects from an XMLControl.
*
* @param control the XMLControl
* @param useChooser true to present data choices to user
*
* @return a list of self-contained Data objects
*/
private static ArrayList<Data> getSelfContainedData(XMLControl control, boolean useChooser) {
ArrayList<Data> dataList = new ArrayList<Data>();
java.util.List<XMLProperty> xmlControls;
// first get the Data XMLControls
if(useChooser) {
// get user-selected Data XMLControls from an xml tree chooser
XMLTreeChooser chooser = new XMLTreeChooser(ToolsRes.getString("Chooser.Title"), //$NON-NLS-1$
ToolsRes.getString("Chooser.Label"), null); //$NON-NLS-1$
xmlControls = chooser.choose(control, Data.class);
} else {
// get all Data XMLControls
XMLTree tree = new XMLTree(control);
tree.setHighlightedClass(Data.class);
tree.selectHighlightedProperties();
xmlControls = tree.getSelectedProperties();
if(xmlControls.isEmpty()) {
JOptionPane.showMessageDialog(null, ToolsRes.getString("Dialog.NoDatasets.Message")); //$NON-NLS-1$
}
}
// load the Data XMLControls and collect Data objects
HashSet<Integer> IDs = new HashSet<Integer>();
for(XMLProperty prop : xmlControls) {
XMLControl next = (XMLControl) prop;
Data data = null;
if(next instanceof XMLControlElement) {
XMLControlElement element = (XMLControlElement) next;
data = (Data) element.loadObject(null, true, true);
} else {
data = (Data) next.loadObject(null);
}
if(data!=null) {
for(Data nextData : getSelfContainedData(data)) {
// check IDs to prevent duplicates
Integer id = new Integer(nextData.getID());
if(!IDs.contains(id)) {
IDs.add(id);
dataList.add(nextData);
// remove any previously added Datasets within DatasetManagers
if(nextData instanceof DatasetManager) {
for(Dataset dataset : nextData.getDatasets()) {
dataList.remove(dataset);
id = new Integer(dataset.getID());
IDs.add(id);
}
}
}
}
}
}
return dataList;
}