Processing PApplet not recovering after exception is thrown
in
Integration and Hardware
•
2 years ago
Dear,
I am using swing to put a GUI around a class extending Processing PApplet, it takes a couple of arguments from textAreas and plots upon a button click. My problems is that when an exception is caught, because one of the arguments is ill-specified, the embedded PApplet "dies" - one cannot re-plot to it, but has to restart the application. How can a remedy that? Here is the relevant part of code (Processing button listener):
I am using swing to put a GUI around a class extending Processing PApplet, it takes a couple of arguments from textAreas and plots upon a button click. My problems is that when an exception is caught, because one of the arguments is ill-specified, the embedded PApplet "dies" - one cannot re-plot to it, but has to restart the application. How can a remedy that? Here is the relevant part of code (Processing button listener):
- private class ListenGenerateProcessing implements ActionListener {
- public void actionPerformed(ActionEvent ev) {
- SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
- // Executed in background thread
- public Void doInBackground() {
- try {
- continuousTreeToProcessing
- .setCoordinatesName(coordinatesNameParser
- .getText());
- continuousTreeToProcessing.setHPD(HPDParser.getText()
- + "%");
- continuousTreeToProcessing
- .setMaxPolygonRedMapping(polygonsColor.getRed());
- continuousTreeToProcessing
- .setMaxPolygonGreenMapping(polygonsColor
- .getGreen());
- continuousTreeToProcessing
- .setMaxPolygonBlueMapping(polygonsColor
- .getBlue());
- continuousTreeToProcessing
- .setMaxPolygonOpacityMapping(polygonsColor
- .getAlpha());
- continuousTreeToProcessing
- .setMaxBranchRedMapping(branchesColor.getRed());
- continuousTreeToProcessing
- .setMaxBranchGreenMapping(branchesColor
- .getGreen());
- continuousTreeToProcessing
- .setMaxBranchBlueMapping(branchesColor
- .getBlue());
- continuousTreeToProcessing
- .setMaxBranchOpacityMapping(branchesColor
- .getAlpha());
- continuousTreeToProcessing.init();
- } catch (Exception e) {
- e.printStackTrace();
- String msg = String.format("Unexpected problem: %s", e
- .toString());
- JOptionPane.showMessageDialog(Utils.getActiveFrame(),
- msg, "Error", JOptionPane.ERROR_MESSAGE,
- errorIcon);
- }
- return null;
- }// END: doInBackground()
- // Executed in event dispatch thread
- public void done() {
- System.out.println("Finished. \n");
- }
- };
- worker.execute();
- }
- }// END: ListenGenerateProcessing
1