private void drawInderminate(Graphics2D g) { if (animateThread != null) { animateThread.paintIcon(this, g); } }
public void stopProgress() { bar.setIndeterminate(false); }
@Override public void paint(Graphics g) { if (g instanceof Graphics2D) { if (isIndeterminate()) { drawInderminate((Graphics2D) g); } else { draw((Graphics2D) g); } } }
private void incrementProgressBar(final int progress) { if (taskMonitor == null) { return; } if (taskMonitor.isAborting()) { throw new TaskInterruptionException("Operation from " + this.getClass().getName() + " has been canceled"); //$NON-NLS-1$ //$NON-NLS-2$ } if (taskMonitor.isShowProgression()) { GuiExecutor.instance().execute(() -> { taskMonitor.setProgress(progress); StringBuilder buf = new StringBuilder(Messages.getString("MeanCollectionZprojection.operation")); //$NON-NLS-1$ buf.append(StringUtil.COLON_AND_SPACE); buf.append(progress); buf.append("/"); //$NON-NLS-1$ buf.append(taskMonitor.getMaximum()); taskMonitor.setNote(buf.toString()); }); } }
@Override public void run() { taskMonitor.setProgress(progress); StringBuilder buf = new StringBuilder(Messages.getString("MinCollectionZprojection.operation")); //$NON-NLS-1$ buf.append(StringUtil.COLON_AND_SPACE); buf.append(progress); buf.append("/"); //$NON-NLS-1$ buf.append(taskMonitor.getMaximum()); taskMonitor.setNote(buf.toString()); } });
private void incrementProgressBar(final int progress) { if (taskMonitor == null) { return; } if (taskMonitor.isAborting()) { throw new TaskInterruptionException("Operation from " + this.getClass().getName() + " has been canceled"); //$NON-NLS-1$ //$NON-NLS-2$ } if (taskMonitor.isShowProgression()) { GuiExecutor.instance().execute(new Runnable() { @Override public void run() { taskMonitor.setProgress(progress); StringBuilder buf = new StringBuilder(Messages.getString("MinCollectionZprojection.operation")); //$NON-NLS-1$ buf.append(StringUtil.COLON_AND_SPACE); buf.append(progress); buf.append("/"); //$NON-NLS-1$ buf.append(taskMonitor.getMaximum()); taskMonitor.setNote(buf.toString()); } }); } }
@Override public synchronized void setIndeterminate(boolean newValue) { if (animateThread != null) { stopIndeterminate(); } if (newValue != this.isIndeterminate()) { if (newValue && animateThread == null) { animateThread = new Animate(50); animateThread.start(); } super.setIndeterminate(newValue); } }
private void init() { this.setOpaque(false); this.setSize(30, 30); Dimension dim = new Dimension(30, 30); this.setPreferredSize(dim); this.setMaximumSize(dim); }
@Override public void run() { while (!this.isInterrupted()) { indeterminateIcon.animate(); CircularProgressBar.this.repaint(); try { Thread.sleep(this.refresh); } catch (InterruptedException e) { this.interrupt(); } } } }
protected void stopCurrentProcess() { final MipProcess t = process; if (t != null) { process = null; t.taskMonitor.setAborting(true); // Close won't stop the process immediately t.taskMonitor.close(); t.interrupt(); } }
@Override public int read(byte[] b, int off, int len) throws IOException { if (isLoadingSeriesCanceled()) { InterruptedIOException exc = new InterruptedIOException(INTERUPTION_LABEL); exc.bytesTransferred = nread; series.setFileSize(series.getFileSize() - nread); nread = 0; throw exc; } int nr = in.read(b, off, len); if (nr > 0) { nread += nr; updateSeriesProgression(nr); } return nr; }
public void paintIcon(CircularProgressBar circularProgressBar, Graphics2D g) { int h = circularProgressBar.getHeight(); int w = circularProgressBar.getWidth(); int x = (w - indeterminateIcon.getIconWidth()) / 2; int y = (h - indeterminateIcon.getIconHeight()) / 2; g.setPaint(Color.WHITE); g.fillRect(x, y, indeterminateIcon.getIconWidth(), indeterminateIcon.getIconHeight()); indeterminateIcon.paintIcon(circularProgressBar, g, x, y); }
public CircularProgressBar(int min, int max) { super(min, max); init(); }
@Override public long skip(long n) throws IOException { long nr = in.skip(n); if (nr > 0) { nread += nr; updateSeriesProgression(nr); } return nr; }
public boolean isAborting() { return aborting || isCanceled(); }
@Override public int read(byte[] b, int off, int len) throws IOException { int nr = super.read(b, off, len); if (wadoRequest) { if (nread < header.length) { System.arraycopy(b, off, header, nread - nr, nr); } else { wadoRequest = false; int length = header.length - (nread - nr); System.arraycopy(b, off, header, nread - nr, length); readMetaInfo(this, header); header = null; } } return nr; }
public ExplorerTask(String message, boolean globalLoadingManager, boolean subTask) { this.message = message; this.globalLoadingManager = globalLoadingManager; // Trick to keep progressBar with a final modifier to be instantiated in EDT (required by substance) final CircularProgressBar[] tmp = new CircularProgressBar[1]; GuiExecutor.instance().invokeAndWait(() -> tmp[0] = new CircularProgressBar(0, 100)); this.bar = tmp[0]; this.subTask = subTask; this.cancelListeners = new ArrayList<>(); }
private void incrementProgressBar(final int progress) { if (taskMonitor == null) { return; } if (taskMonitor.isAborting()) { throw new TaskInterruptionException("Operation from " + this.getClass().getName() + " has been canceled"); //$NON-NLS-1$ //$NON-NLS-2$ } if (taskMonitor.isShowProgression()) { GuiExecutor.instance().execute(() -> { taskMonitor.setProgress(progress); StringBuilder buf = new StringBuilder(Messages.getString("MaxCollectionZprojection.operation")); //$NON-NLS-1$ buf.append(StringUtil.COLON_AND_SPACE); buf.append(progress); buf.append("/"); //$NON-NLS-1$ buf.append(taskMonitor.getMaximum()); taskMonitor.setNote(buf.toString()); }); } }
public CircularProgressBar() { init(); }
@Override public synchronized void reset() throws IOException { in.reset(); nread = size - in.available(); updateSeriesProgression(nread); } }