public JungGraphObserver(String name) { this.name = name; this.hyphadataPid = Configuration.getPid(PAR_HYPHADATA_PROTO); this.hyphalinkPid = Configuration.getPid(PAR_HYPHALINK_PROTO); this.mycocastPid = Configuration.getPid(PAR_MYCOCAST_PROTO); this.period = Configuration.getInt(name + "." + PAR_PERIOD); this.walkDelay = Configuration.getInt(name + "." + PAR_WALK_DELAY); mainThread = Thread.currentThread(); this.changeListeners = new HashSet<ChangeListener>(); visualizer = null; // HyphaData.addHyphaDataListener(this); // HyphaLink.addHyphaLinkListener(this); }
protected void saveToFile() { if (this.fileChooser == null) { this.fileChooser = new JFileChooser(); this.fileChooser.setCurrentDirectory(new File(Configuration.getUserHomeDirectory())); } this.fileChooser.setDialogTitle("Choose Directory to Place Airspaces"); this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); this.fileChooser.setMultiSelectionEnabled(false); int status = this.fileChooser.showSaveDialog(null); if (status != JFileChooser.APPROVE_OPTION) return; final File dir = this.fileChooser.getSelectedFile(); if (dir == null) return; if (!dir.exists()) { //noinspection ResultOfMethodCallIgnored dir.mkdirs(); } final Iterable<AirspaceEntry> entries = this.getModel().getEntries(); Thread t = new Thread( new Runnable() { public void run() { try { java.text.DecimalFormat f = new java.text.DecimalFormat("####"); f.setMinimumIntegerDigits(4); int counter = 0; for (AirspaceEntry entry : entries) { Airspace a = entry.getAirspace(); AirspaceAttributes currentAttribs = a.getAttributes(); a.setAttributes(entry.getAttributes()); String xmlString = a.getRestorableState(); if (xmlString != null) { try { PrintWriter of = new PrintWriter( new File( dir, a.getClass().getName() + "-" + entry.getName() + "-" + f.format(counter++) + ".xml")); of.write(xmlString); of.flush(); of.close(); } catch (Exception e) { e.printStackTrace(); } } a.setAttributes(currentAttribs); } } finally { SwingUtilities.invokeLater( new Runnable() { public void run() { setEnabled(true); getApp().setCursor(null); getApp().getWwd().redraw(); } }); } } }); this.setEnabled(false); getApp().setCursor(new Cursor(Cursor.WAIT_CURSOR)); t.start(); }
protected void openFromFile() { if (this.fileChooser == null) { this.fileChooser = new JFileChooser(); this.fileChooser.setCurrentDirectory(new File(Configuration.getUserHomeDirectory())); } this.fileChooser.setDialogTitle("Choose Airspace File Directory"); this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); this.fileChooser.setMultiSelectionEnabled(false); int status = this.fileChooser.showOpenDialog(null); if (status != JFileChooser.APPROVE_OPTION) return; final File dir = this.fileChooser.getSelectedFile(); if (dir == null) return; Thread t = new Thread( new Runnable() { public void run() { final ArrayList<Airspace> airspaces = new ArrayList<Airspace>(); try { File[] files = dir.listFiles( new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith("gov.nasa.worldwind.render.airspaces") && name.endsWith(".xml"); } }); for (File file : files) { String[] name = file.getName().split("-"); try { Class c = Class.forName(name[0]); Airspace airspace = (Airspace) c.newInstance(); BufferedReader input = new BufferedReader(new FileReader(file)); String s = input.readLine(); airspace.restoreState(s); airspaces.add(airspace); if (name.length >= 2) { airspace.setValue(AVKey.DISPLAY_NAME, name[1]); } } catch (Exception e) { e.printStackTrace(); } } } finally { SwingUtilities.invokeLater( new Runnable() { public void run() { setAirspaces(airspaces); setEnabled(true); getApp().setCursor(null); getApp().getWwd().redraw(); } }); } } }); this.setEnabled(false); getApp().setCursor(new Cursor(Cursor.WAIT_CURSOR)); t.start(); }
public static GpuResourceCache createGpuResourceCache() { long cacheSize = Configuration.getLongValue(AVKey.TEXTURE_CACHE_SIZE, FALLBACK_TEXTURE_CACHE_SIZE); return new BasicGpuResourceCache((long) (0.8 * cacheSize), cacheSize); }