mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Add hiding of progressbar when finished creating image
Former-commit-id: b5732d9ac6fbcead8d4127e2b18c446fd7f0e0a6
This commit is contained in:
parent
28f07ec739
commit
632275396b
@ -24,6 +24,7 @@ import javax.swing.JMenu;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingWorker;
|
||||
|
||||
import org.hyperion.hypercon.LedFrameFactory;
|
||||
import org.hyperion.hypercon.spec.ImageProcessConfig;
|
||||
@ -145,22 +146,24 @@ public class LedSimulationComponent extends JPanel {
|
||||
mWorker.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (evt.getPropertyName() == "state") {
|
||||
if (evt.getNewValue() == SwingWorker.StateValue.STARTED) {
|
||||
mProgressBar.setVisible(true);
|
||||
} else if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
|
||||
handleWorkerDone();
|
||||
mProgressBar.setVisible(false);
|
||||
}
|
||||
} else if (evt.getPropertyName() == "progress") {
|
||||
mProgressBar.setValue(mWorker.getProgress());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleWorkerDone() {
|
||||
BufferedImage backgroundImage = null;
|
||||
|
||||
synchronized(LedSimulationComponent.this) {
|
||||
if (mWorker == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt.getPropertyName() == "progress") {
|
||||
mProgressBar.setValue(mWorker.getProgress());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mWorker.isDone()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
backgroundImage = mWorker.get();
|
||||
mWorker = null;
|
||||
@ -169,6 +172,7 @@ public class LedSimulationComponent extends JPanel {
|
||||
if (backgroundImage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int width = backgroundImage.getWidth();
|
||||
int height = backgroundImage.getHeight();
|
||||
int borderWidth = (int) (backgroundImage.getWidth() * 0.1);
|
||||
@ -186,6 +190,7 @@ public class LedSimulationComponent extends JPanel {
|
||||
mBottomRightImage.setImage(backgroundImage.getSubimage(width-borderWidth, height-borderHeight, borderWidth, borderHeight));
|
||||
|
||||
mProgressBar.setValue(100);
|
||||
mProgressBar.setVisible(false);
|
||||
mWorker = null;
|
||||
|
||||
LedSimulationComponent.this.repaint();
|
||||
|
Loading…
Reference in New Issue
Block a user