public static void randomToolActions(int numStrokes, boolean brushOnly) { Composition comp = ImageComponents.getActiveComp().get(); Random random = new Random(); if (comp != null) { int canvasWidth = comp.getCanvasWidth(); int canvasHeight = comp.getCanvasHeight(); ProgressMonitor progressMonitor = Utils.createPercentageProgressMonitor("1001 Tool Actions"); // So far we are on the EDT Runnable notEDTThreadTask = () -> { assert !SwingUtilities.isEventDispatchThread(); for (int i = 0; i < numStrokes; i++) { int progressPercentage = (int) ((float) i * 100 / numStrokes); progressMonitor.setProgress(progressPercentage); progressMonitor.setNote(progressPercentage + "%"); Runnable edtRunnable = () -> testToolAction(comp, random, canvasWidth, canvasHeight, brushOnly); try { SwingUtilities.invokeAndWait(edtRunnable); } catch (InterruptedException | InvocationTargetException e) { e.printStackTrace(); } comp.repaint(); } progressMonitor.close(); }; new Thread(notEDTThreadTask).start(); } }
public static void extract() { String ftlPath = (String) JOptionPane.showInputDialog( null, "What is your FTL install directory:\n", "Extracting Resources", JOptionPane.PLAIN_MESSAGE, null, null, "C:/Program Files (x86)/Steam/SteamApps/common/FTL Faster Than Light"); datLib dat = new datLib(ftlPath + "/resources/resource.dat"); int[] ids = dat.List(); ProgressMonitor progressMonitor = new ProgressMonitor(null, "Extracting Resources", "", 0, ids.length); for (int i = 0; i < ids.length; i++) { String path = dat.Filename(ids[i]); File file = new File("resources/" + path); if (!file.exists()) { dat.Extract(ids[i], "resources/" + path); } progressMonitor.setProgress(i); } progressMonitor.close(); }
/** finalise, time to close the progress bar */ protected void finalize() throws Throwable { super.finalize(); _tmpFrame.dispose(); _tmpFrame = null; if (_pm != null) { _pm.close(); _pm = null; } }
/** * Test a synapse on the specified spiking protocol or a series of spiking protocols derived from * initial and final protocols by interpolation over one or two dimensions. The synapse is tested * over all specified parameter configurations. * * @param synapse The SynapseCollection containing the synapse to test (the first synapse is * used). The first configuration (at index 0) in the collection will be replaced with each * configuration specified by the <em>configurations</em> argument. * @param configurationLabels An array containing the labels for each parameter configuration to * test on. These are used to label the data sets in the returned TestResults. * @param configurations An array containing the parameter configurations to test on. * @param timeResolution The time resolution to use in the simulation, see {@link * com.ojcoleman.bain.NeuralNetwork} * @param period The period of the spike pattern in seconds. * @param repetitions The number of times to apply the spike pattern. * @param patterns Array containing spike patterns, in the form [initial, dim 1, dim 2][pre, * post][spike number] = spike time. The [spike number] array contains the times (s) of each * spike, relative to the beginning of the pattern. See {@link * com.ojcoleman.bain.neuron.spiking.FixedProtocolNeuronCollection}. * @param refSpikeIndexes Array specifying indexes of the two spikes to use as timing variation * references for each variation dimension, in the form [dim 1, dim 2][reference spike, * relative spike] = spike index. * @param refSpikePreOrPost Array specifying whether the timing variation reference spikes * specified by refSpikeIndexes belong to the pre- or post-synaptic neurons, in the form [dim * 1, dim 2][base spike, relative spike] = Constants.PRE or Constants.POST. * @param logSpikesAndStateVariables Whether to record pre- and post-synaptic spikes and any state * variables exposed by the synapse model in the test results. * @param progressMonitor If not null, this will be updated to display the progress of the test. * @return For a single spike protocol, a TestResults object with type {@link TYPE#STDP} * consisting of series labelled "Time" and "Efficacy" and if logSpikesAndStateVariables == * true then also "Pre-synaptic spikes", "Post-synaptic spikes" and any state variables * exposed by the synapse model. For a protocol varied over one dimension, a TestResults * object with type {@link TYPE#STDP_1D} consisting of series labelled "Time delta" and * "Efficacy". For a protocol varied over two dimensions, a TestResults object with type * {@link TYPE#STDP_2D} consisting of series labelled "Time delta 1", "Time delta 2" and * "Efficacy". */ public static TestResults[] testPattern( SynapseCollection<? extends ComponentConfiguration> synapse, String[] configurationLabels, ComponentConfiguration[] configurations, int timeResolution, double period, int repetitions, double[][][] patterns, int[][] refSpikeIndexes, int[][] refSpikePreOrPost, boolean logSpikesAndStateVariables, ProgressMonitor progressMonitor) throws IllegalArgumentException { int configCount = configurationLabels.length; TestResults[] results = new TestResults[configCount]; if (synapse.getConfigurationCount() == 0) { synapse.addConfiguration(configurations[0]); } ProgressMonitor progressMonitorSub = null; if (progressMonitor != null) { progressMonitor.setMinimum(0); progressMonitor.setMaximum(configCount); progressMonitor.setMillisToDecideToPopup(0); progressMonitorSub = new ProgressMonitor(null, null, "Performing test...", 0, 0); } for (int c = 0; c < configCount; c++) { if (progressMonitor != null) { progressMonitor.setProgress(c); progressMonitor.setNote("Testing " + configurationLabels[c]); } synapse.setConfiguration(0, configurations[c]); results[c] = testPattern( synapse, timeResolution, period, repetitions, patterns, refSpikeIndexes, refSpikePreOrPost, logSpikesAndStateVariables, progressMonitorSub); results[c].setProperty("label", configurationLabels[c]); } if (progressMonitorSub != null) { progressMonitorSub.close(); } return results; }
private void drawImage() { progressMonitor = new ProgressMonitor(parent, "Drawing dot plot", "", 0, 100); // System.out.println("Redrawing image with seq one bounds " + sequenceOneMin + " .. " + // sequenceOneMax); imageIsBeingRedrawn = true; ImageDrawer drawer = new ImageDrawer(); drawer.execute(); progressMonitor.close(); redrawImage = false; }
/** * @param wfsClient * @throws NoSuchAuthorityCodeException * @throws FactoryException * @throws IOException * @throws ParseException * @throws NoSuchElementException * @throws IndexOutOfBoundsException */ public void loadFeatures(GeoFabrikWFSClient wfsClient) throws NoSuchAuthorityCodeException, FactoryException, IOException, IndexOutOfBoundsException, NoSuchElementException, ParseException { String typeNames[] = wfsClient.getTypeNames(); content.layers().clear(); selectGeomType.clear(); selectGeomType.add(GeomType.POINT); ProgressMonitor monitor = new ProgressMonitor(Main.map.mapView, "Loading features", "", 0, 100); for (int idx = 1; idx < typeNames.length; ++idx) { String typeName = typeNames[idx]; Set<FeatureId> selectedFeatures = new HashSet<>(); monitor.setProgress(100 / typeNames.length * idx); FeatureCollection<SimpleFeatureType, SimpleFeature> features = wfsClient.getFeatures(typeName, monitor); setGeometry(selectGeomType, typeName); Main.info("Osm Inspector Features size: " + features.size()); OSMIFeatureTracker tracker = arrFeatures.get(idx - layerOffset); tracker.mergeFeatures(features); FeatureIterator<SimpleFeature> it = tracker.getFeatures().features(); while (it.hasNext()) { BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size()); if (!osmiBugInfo.keySet().contains(theInfo)) { osmiBugInfo.put(theInfo, theInfo.bugId); } } Style style = createDefaultStyle(idx, selectedFeatures); content.addLayer(new FeatureLayer(tracker.getFeatures(), style)); } osmiIndex.append(osmiBugInfo); monitor.setProgress(100); monitor.close(); bIsChanged = true; // dialog.updateDialog(this); dialog.refreshModel(); // dialog.updateNextPrevAction(this); this.updateView(); }
/** override the readLine method, to tell us were at a new line */ public String readLine() throws IOException { _counter++; final float prog = (_counter / _length * 100); _progress = (int) prog; if (_pm != null) { _pm.setProgress(_progress); _pm.setNote("" + _progress + "% complete"); if (_progress >= 99) { _pm.close(); _pm = null; } } return super.readLine(); }