mirror of
https://github.com/badvision/jace.git
synced 2025-02-19 21:30:34 +00:00
Removal of Swing remanants
This commit is contained in:
parent
4fc71a43a7
commit
a641ac555c
@ -28,12 +28,8 @@ import jace.core.CPU;
|
|||||||
import jace.core.Computer;
|
import jace.core.Computer;
|
||||||
import jace.core.Debugger;
|
import jace.core.Debugger;
|
||||||
import jace.core.RAM;
|
import jace.core.RAM;
|
||||||
import jace.core.RAMEvent;
|
|
||||||
import jace.core.RAMListener;
|
import jace.core.RAMListener;
|
||||||
import static jace.core.Utility.*;
|
import static jace.core.Utility.*;
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.HeadlessException;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -50,7 +46,6 @@ import java.util.Set;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.embed.swing.SwingFXUtils;
|
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
@ -58,11 +53,8 @@ import javafx.scene.control.Label;
|
|||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains miscellaneous user-invoked actions such as debugger
|
* This class contains miscellaneous user-invoked actions such as debugger
|
||||||
@ -206,9 +198,8 @@ public class EmulatorUILogic implements Reconfigurable {
|
|||||||
defaultKeyMapping = "ctrl+shift+b")
|
defaultKeyMapping = "ctrl+shift+b")
|
||||||
public static void runFile() {
|
public static void runFile() {
|
||||||
Emulator.computer.pause();
|
Emulator.computer.pause();
|
||||||
JFileChooser select = new JFileChooser();
|
FileChooser select = new FileChooser();
|
||||||
// select.showDialog(Emulator.getFrame(), "Execute binary file");
|
File binary = select.showOpenDialog(null);
|
||||||
File binary = select.getSelectedFile();
|
|
||||||
if (binary == null) {
|
if (binary == null) {
|
||||||
Emulator.computer.resume();
|
Emulator.computer.resume();
|
||||||
return;
|
return;
|
||||||
@ -339,26 +330,25 @@ public class EmulatorUILogic implements Reconfigurable {
|
|||||||
description = "Save image of visible screen",
|
description = "Save image of visible screen",
|
||||||
alternatives = "Save image,save framebuffer,screenshot",
|
alternatives = "Save image,save framebuffer,screenshot",
|
||||||
defaultKeyMapping = "ctrl+shift+s")
|
defaultKeyMapping = "ctrl+shift+s")
|
||||||
public static void saveScreenshot() throws HeadlessException, IOException {
|
public static void saveScreenshot() throws IOException {
|
||||||
JFileChooser select = new JFileChooser();
|
FileChooser select = new FileChooser();
|
||||||
Emulator.computer.pause();
|
Emulator.computer.pause();
|
||||||
Image i = Emulator.computer.getVideo().getFrameBuffer();
|
Image i = Emulator.computer.getVideo().getFrameBuffer();
|
||||||
BufferedImage bufImageARGB = SwingFXUtils.fromFXImage(i, null);
|
// BufferedImage bufImageARGB = SwingFXUtils.fromFXImage(i, null);
|
||||||
// select.showSaveDialog(Emulator.getFrame());
|
File targetFile = select.showSaveDialog(null);
|
||||||
File targetFile = select.getSelectedFile();
|
|
||||||
if (targetFile == null) {
|
if (targetFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String filename = targetFile.getName();
|
String filename = targetFile.getName();
|
||||||
System.out.println("Writing screenshot to " + filename);
|
System.out.println("Writing screenshot to " + filename);
|
||||||
String extension = filename.substring(filename.lastIndexOf(".") + 1);
|
String extension = filename.substring(filename.lastIndexOf(".") + 1);
|
||||||
BufferedImage bufImageRGB = new BufferedImage(bufImageARGB.getWidth(), bufImageARGB.getHeight(), BufferedImage.OPAQUE);
|
// BufferedImage bufImageRGB = new BufferedImage(bufImageARGB.getWidth(), bufImageARGB.getHeight(), BufferedImage.OPAQUE);
|
||||||
|
//
|
||||||
Graphics2D graphics = bufImageRGB.createGraphics();
|
// Graphics2D graphics = bufImageRGB.createGraphics();
|
||||||
graphics.drawImage(bufImageARGB, 0, 0, null);
|
// graphics.drawImage(bufImageARGB, 0, 0, null);
|
||||||
|
//
|
||||||
ImageIO.write(bufImageRGB, extension, targetFile);
|
// ImageIO.write(bufImageRGB, extension, targetFile);
|
||||||
graphics.dispose();
|
// graphics.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String CONFIGURATION_DIALOG_NAME = "Configuration";
|
public static final String CONFIGURATION_DIALOG_NAME = "Configuration";
|
||||||
|
@ -33,11 +33,10 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
import javax.sound.sampled.SourceDataLine;
|
import javax.sound.sampled.SourceDataLine;
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apple // Speaker Emulation Created on May 9, 2007, 9:55 PM
|
* Apple // Speaker Emulation Created on May 9, 2007, 9:55 PM
|
||||||
@ -59,18 +58,17 @@ public class Speaker extends Device {
|
|||||||
out = null;
|
out = null;
|
||||||
fileOutputActive = false;
|
fileOutputActive = false;
|
||||||
} else {
|
} else {
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
fileChooser.showSaveDialog(null);
|
File f = fileChooser.showSaveDialog(null);
|
||||||
File f = fileChooser.getSelectedFile();
|
|
||||||
if (f == null) {
|
if (f == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (f.exists()) {
|
// if (f.exists()) {
|
||||||
int i = JOptionPane.showConfirmDialog(null, "Overwrite existing file?");
|
// int i = JOptionPane.showConfirmDialog(null, "Overwrite existing file?");
|
||||||
if (i != JOptionPane.OK_OPTION && i != JOptionPane.YES_OPTION) {
|
// if (i != JOptionPane.OK_OPTION && i != JOptionPane.YES_OPTION) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
try {
|
try {
|
||||||
out = new FileOutputStream(f);
|
out = new FileOutputStream(f);
|
||||||
fileOutputActive = true;
|
fileOutputActive = true;
|
||||||
|
@ -18,45 +18,31 @@
|
|||||||
*/
|
*/
|
||||||
package jace.core;
|
package jace.core;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
import java.net.JarURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.jar.JarEntry;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.ContentDisplay;
|
import javafx.scene.control.ContentDisplay;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.effect.DropShadow;
|
import javafx.scene.effect.DropShadow;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JProgressBar;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a set of helper functions which do not belong anywhere else.
|
* This is a set of helper functions which do not belong anywhere else.
|
||||||
* Functions vary from introspection, discovery, and string/pattern matching.
|
* Functions vary from introspection, discovery, and string/pattern matching.
|
||||||
@ -323,15 +309,15 @@ public class Utility {
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runModalProcess(String title, final Runnable runnable) {
|
// public static void runModalProcess(String title, final Runnable runnable) {
|
||||||
// final JDialog frame = new JDialog(Emulator.getFrame());
|
//// final JDialog frame = new JDialog(Emulator.getFrame());
|
||||||
final JProgressBar progressBar = new JProgressBar();
|
// final JProgressBar progressBar = new JProgressBar();
|
||||||
progressBar.setIndeterminate(true);
|
// progressBar.setIndeterminate(true);
|
||||||
final JPanel contentPane = new JPanel();
|
// final JPanel contentPane = new JPanel();
|
||||||
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
// contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||||
contentPane.setLayout(new BorderLayout());
|
// contentPane.setLayout(new BorderLayout());
|
||||||
contentPane.add(new JLabel(title), BorderLayout.NORTH);
|
// contentPane.add(new JLabel(title), BorderLayout.NORTH);
|
||||||
contentPane.add(progressBar, BorderLayout.CENTER);
|
// contentPane.add(progressBar, BorderLayout.CENTER);
|
||||||
// frame.setContentPane(contentPane);
|
// frame.setContentPane(contentPane);
|
||||||
// frame.pack();
|
// frame.pack();
|
||||||
// frame.setLocationRelativeTo(null);
|
// frame.setLocationRelativeTo(null);
|
||||||
@ -342,7 +328,7 @@ public class Utility {
|
|||||||
// frame.setVisible(false);
|
// frame.setVisible(false);
|
||||||
// frame.dispose();
|
// frame.dispose();
|
||||||
// }).start();
|
// }).start();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static class RankingComparator implements Comparator<String> {
|
public static class RankingComparator implements Comparator<String> {
|
||||||
|
|
||||||
@ -438,8 +424,11 @@ public class Utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void gripe(final String message) {
|
public static void gripe(final String message) {
|
||||||
EventQueue.invokeLater(() -> {
|
Platform.runLater(() -> {
|
||||||
// JOptionPane.showMessageDialog(Emulator.getFrame(), message, "Error", JOptionPane.ERROR_MESSAGE);
|
Alert errorAlert = new Alert(Alert.AlertType.ERROR);
|
||||||
|
errorAlert.setContentText(message);
|
||||||
|
errorAlert.setTitle("Error");
|
||||||
|
errorAlert.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class MediaCache implements Serializable {
|
|||||||
e.files = new ArrayList<>();
|
e.files = new ArrayList<>();
|
||||||
getLocalLibrary().add(e);
|
getLocalLibrary().add(e);
|
||||||
getLocalLibrary().createBlankFile(e, "Initial", !isPermanent);
|
getLocalLibrary().createBlankFile(e, "Initial", !isPermanent);
|
||||||
getLocalLibrary().downloadImage(e, e.files.get(0), true);
|
// getLocalLibrary().downloadImage(e, e.files.get(0), true);
|
||||||
}
|
}
|
||||||
for (MediaEntry.MediaFile f : e.files) {
|
for (MediaEntry.MediaFile f : e.files) {
|
||||||
if (f.activeVersion) {
|
if (f.activeVersion) {
|
||||||
@ -340,60 +340,60 @@ public class MediaCache implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MediaFile downloadTempCopy(MediaEntry e) {
|
private MediaFile downloadTempCopy(MediaEntry e) {
|
||||||
downloadImage(e, getCurrentFile(e, false), isDownloading);
|
// downloadImage(e, getCurrentFile(e, false), isDownloading);
|
||||||
return getCurrentFile(e, false);
|
return getCurrentFile(e, false);
|
||||||
}
|
}
|
||||||
static boolean isDownloading = false;
|
static boolean isDownloading = false;
|
||||||
|
//
|
||||||
public void downloadImage(final MediaEntry e, final MediaFile target, boolean wait) {
|
// public void downloadImage(final MediaEntry e, final MediaFile target, boolean wait) {
|
||||||
isDownloading = true;
|
// isDownloading = true;
|
||||||
Utility.runModalProcess("Loading disk image...", () -> {
|
// Utility.runModalProcess("Loading disk image...", () -> {
|
||||||
InputStream in = null;
|
// InputStream in = null;
|
||||||
try {
|
// try {
|
||||||
URI uri = null;
|
// URI uri = null;
|
||||||
try {
|
// try {
|
||||||
uri = new URI(e.source);
|
// uri = new URI(e.source);
|
||||||
} catch (URISyntaxException ex) {
|
// } catch (URISyntaxException ex) {
|
||||||
File f = new File(e.source);
|
// File f = new File(e.source);
|
||||||
if (f.exists()) {
|
// if (f.exists()) {
|
||||||
uri = f.toURI();
|
// uri = f.toURI();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (uri == null) {
|
// if (uri == null) {
|
||||||
Utility.gripe("Unable to resolve path: " + e.source);
|
// Utility.gripe("Unable to resolve path: " + e.source);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
in = uri.toURL().openStream();
|
// in = uri.toURL().openStream();
|
||||||
saveFile(target, in);
|
// saveFile(target, in);
|
||||||
} catch (MalformedURLException ex) {
|
// } catch (MalformedURLException ex) {
|
||||||
Utility.gripe("Unable to resolve path: " + e.source);
|
// Utility.gripe("Unable to resolve path: " + e.source);
|
||||||
Logger.getLogger(MediaCache.class.getName()).log(Level.SEVERE, null, ex);
|
// Logger.getLogger(MediaCache.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (IOException ex) {
|
// } catch (IOException ex) {
|
||||||
Utility.gripe("Unable to download file: " + ex.getMessage());
|
// Utility.gripe("Unable to download file: " + ex.getMessage());
|
||||||
Logger.getLogger(MediaCache.class.getName()).log(Level.SEVERE, null, ex);
|
// Logger.getLogger(MediaCache.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} finally {
|
// } finally {
|
||||||
isDownloading = false;
|
// isDownloading = false;
|
||||||
try {
|
// try {
|
||||||
if (in != null) {
|
// if (in != null) {
|
||||||
in.close();
|
// in.close();
|
||||||
}
|
// }
|
||||||
} catch (IOException ex) {
|
// } catch (IOException ex) {
|
||||||
Logger.getLogger(MediaCache.class.getName()).log(Level.SEVERE, null, ex);
|
// Logger.getLogger(MediaCache.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
if (wait) {
|
// if (wait) {
|
||||||
int timeout = 10000;
|
// int timeout = 10000;
|
||||||
while (timeout > 0 && isDownloading) {
|
// while (timeout > 0 && isDownloading) {
|
||||||
try {
|
// try {
|
||||||
Thread.sleep(100);
|
// Thread.sleep(100);
|
||||||
} catch (InterruptedException ex) {
|
// } catch (InterruptedException ex) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
timeout -= 100;
|
// timeout -= 100;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void createBlankFile(MediaEntry e, String label, boolean isTemporary) {
|
private void createBlankFile(MediaEntry e, String label, boolean isTemporary) {
|
||||||
MediaFile f = new MediaEntry.MediaFile();
|
MediaFile f = new MediaEntry.MediaFile();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user