本文整理汇总了Java中org.opensourcephysics.controls.XMLControlElement.getObjectClass方法的典型用法代码示例。如果您正苦于以下问题:Java XMLControlElement.getObjectClass方法的具体用法?Java XMLControlElement.getObjectClass怎么用?Java XMLControlElement.getObjectClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensourcephysics.controls.XMLControlElement
的用法示例。
在下文中一共展示了XMLControlElement.getObjectClass方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Saves the current xml control to the specified file.
*
* @param fileName the file name
* @return the name of the saved file, or null if not saved
*/
private String save(String fileName) {
if((fileName==null)||fileName.equals("")) { //$NON-NLS-1$
return null;
}
if(passwordField.getBackground()==Color.yellow) {
passwordField.setBackground(Color.white);
setPassword(passwordField.getText());
}
XMLControlElement control = getCurrentControl();
if(control==null) {
return null;
}
if(control.getObjectClass()==Cryptic.class) {
control = decrypt(control);
}
if(control.write(fileName)==null) {
return null;
}
this.fileName = fileName;
refreshGUI();
return fileName;
}
示例2: 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();
}
}
示例3: 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);
}
示例4: setPassword
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Sets the password of the currently displayed control.
*
* @param password the password
*/
private void setPassword(String password) {
XMLControlElement control = getCurrentControl();
if(control==null) {
return;
}
String pass = control.getPassword();
if(!encryptedCheckBox.isEnabled()) {
boolean verified = password.equals(pass);
if(verified) {
displayXML(decrypt(control));
encryptedCheckBox.setEnabled(true);
} else {
Toolkit.getDefaultToolkit().beep();
OSPLog.fine("Bad password: "+password); //$NON-NLS-1$
}
} else if(control.getObjectClass()==Cryptic.class) {
// decrypt control, change password, and re-encrypt
XMLControlElement temp = decrypt(control);
temp.setPassword(password);
temp = encrypt(temp);
control.setValue("cryptic", temp.getString("cryptic")); //$NON-NLS-1$ //$NON-NLS-2$
treePanel.refresh();
} else {
// change password
if(password.equals("")&&!encryptedCheckBox.isSelected()) { //$NON-NLS-1$
password = null;
}
control.setPassword(password);
treePanel.refresh();
// treePanel.setSelectedNode("xml_password"); //$NON-NLS-1$
}
refreshGUI();
}
示例5: encrypt
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Encrypts the specified XMLcontrol using a Cryptic object.
*
* @param control the XMLControl
* @return the encrypted control
*/
private XMLControlElement encrypt(XMLControlElement control) {
// return controls that are already encrypted
if(control.getObjectClass()==Cryptic.class) {
return control;
}
// encrypt control and set its password
String xml = control.toXML();
Cryptic cryptic = new Cryptic(xml);
XMLControlElement encrypted = new XMLControlElement(cryptic);
encrypted.setPassword(control.getPassword());
return encrypted;
}
示例6: 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;
}
示例7: getClipboardContents
import org.opensourcephysics.controls.XMLControlElement; //导入方法依赖的package包/类
/**
* Gets the clipboard contents.
*/
protected XMLControl[] getClipboardContents() {
try {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tran = clipboard.getContents(null);
String dataString = (String) tran.getTransferData(DataFlavor.stringFlavor);
if(dataString!=null) {
XMLControlElement control = new XMLControlElement();
control.readXML(dataString);
if(control.getObjectClass()==this.getClass()) {
java.util.List<Object> list = control.getPropertyContent();
for(int i = 0; i<list.size(); i++) {
Object next = list.get(i);
if(next instanceof XMLProperty) {
XMLProperty prop = (XMLProperty) next;
if(prop.getPropertyName().equals("selected")) { //$NON-NLS-1$
return prop.getChildControls();
}
}
}
return null;
}
}
} catch(Exception ex) {
/** empty block */
}
return null;
}
示例8: 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;
}
示例9: 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;
}