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


Java XMLControl.failedToRead方法代码示例

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


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

示例1: send

import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
@Override
public void send(Job job, Tool replyTo) throws RemoteException {
   XMLControl control = new XMLControlElement();
   control.readXML(job.getXML());
   if (control.failedToRead()) return;
   int sourceID = control.getInt("sourceID"); //$NON-NLS-1$
   if (control.getBoolean("handshake")) { //$NON-NLS-1$
   	connected = true;
   	support.firePropertyChange("tracker_ready", sourceID, null); //$NON-NLS-1$
   }
   else if (control.getBoolean("exiting")) { //$NON-NLS-1$
   	remoteTool = null;
   	connected = false;
   	support.firePropertyChange("tracker_exited", null, null); //$NON-NLS-1$
   }

}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:18,代码来源:DataTrackSupport.java

示例2: 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;
   }
 }
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:24,代码来源:ImageVideoType.java

示例3: main

import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
 * Main entry point when used as application.
 *
 * @param args args[0] may be an xml file name
 */
public static void main(String[] args) {
  //    java.util.Locale.setDefault(new java.util.Locale("es"));
  //    OSPLog.setLevel(ConsoleLevel.ALL);
  // get current memory size
  java.lang.management.MemoryMXBean memory
		= java.lang.management.ManagementFactory.getMemoryMXBean();
  long memorySize = memory.getHeapMemoryUsage().getMax()/(1024*1024);
  // open default xset, if any, and look for desired memory size
  if (OSPRuntime.getLaunchJarName()!=null) {
  	String xset = XML.stripExtension(OSPRuntime.getLaunchJarName())+".xset"; //$NON-NLS-1$
    String jarBase = OSPRuntime.getLaunchJarDirectory();
    String path = XML.getResolvedPath(xset, jarBase);
    XMLControl control = new XMLControlElement(path);
    if (!control.failedToRead() && control.getPropertyNames().contains("memory_size")) { //$NON-NLS-1$
    	memorySize = control.getInt("memory_size"); //$NON-NLS-1$
    }
  }
  start(args, memorySize);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:25,代码来源:Launcher.java

示例4: 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

示例5: 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;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:23,代码来源:Library.java

示例6: getSearchCacheTargets

import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
 * Returns the set of all searchable cache resources.
 * 
 * @return a set of searchable resources
 */
protected Set<LibraryResource> getSearchCacheTargets() {
	// set up search targets
	Set<LibraryResource> searchTargets = new TreeSet<LibraryResource>();
	File cache = ResourceLoader.getSearchCache();
	FileFilter xmlFilter = new XMLFilter();
	List<File> xmlFiles = ResourceLoader.getFiles(cache, xmlFilter);
	for (File file: xmlFiles) {
		XMLControl control = new XMLControlElement(file.getAbsolutePath());
		if (!control.failedToRead() && LibraryResource.class.isAssignableFrom(control.getObjectClass())) {
			LibraryResource resource = (LibraryResource)control.loadObject(null);
			resource.collectionPath = control.getString("real_path"); //$NON-NLS-1$
			searchTargets.add(resource);
		}
	}
	return searchTargets;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:22,代码来源:LibraryBrowser.java

示例7: 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);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:18,代码来源:Library.java

示例8: 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;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:35,代码来源:FitBuilder.java

示例9: 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);            	
	    }
			
		}
	}
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:32,代码来源:FitBuilder.java

示例10: 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;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:51,代码来源:FitBuilder.java


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