[#2456] Replace sim status icons with tick and refresh arrows

This commit is contained in:
SiboVG 2024-02-14 15:38:43 +01:00
parent 3c7f35c137
commit 70717c3d17
5 changed files with 36 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

View File

@ -239,12 +239,24 @@ public class SimulationPanel extends JPanel {
}
if (e.getButton() == MouseEvent.BUTTON1) {
// Edit the simulation or plot/export
if (e.getClickCount() == 2) {
if (e.getClickCount() == 1) {
if (column == 0) {
int selected = simulationTable.convertRowIndexToModel(selectedRow);
Simulation sim = document.getSimulations().get(selected);
Status status = sim.getStatus();
if (status == Status.NOT_SIMULATED || status == Status.OUTDATED) {
runSimulation();
}
}
} else if (e.getClickCount() == 2) {
int selected = simulationTable.convertRowIndexToModel(selectedRow);
// Show the warnings for the simulation
if (column == 0) {
SimulationWarningDialog.showWarningDialog(SimulationPanel.this, document.getSimulations().get(selected));
} else {
}
// Edit the simulation or plot/export
else {
simulationTable.clearSelection();
simulationTable.addRowSelectionInterval(selectedRow, selectedRow);

View File

@ -29,13 +29,17 @@ public class Icons {
*/
public static final Map<Simulation.Status, Icon> SIMULATION_STATUS_ICON_MAP;
static {
final String SIM_UPTODATE = "pix/icons/tick.png";
final String SIM_CANTRUN = "pix/icons/sim_cantrun.png";
final String SIM_OUTDATED = "pix/icons/refresh_sim.png";
HashMap<Simulation.Status, Icon> map = new HashMap<Simulation.Status, Icon>();
map.put(Simulation.Status.NOT_SIMULATED, loadImageIcon("pix/spheres/gray-16x16.png", "Not simulated"));
map.put(Simulation.Status.CANT_RUN, loadImageIcon("pix/spheres/yellow-16x16.png", "Can't run, no motors assigned."));
map.put(Simulation.Status.UPTODATE, loadImageIcon("pix/spheres/green-16x16.png", "Up to date"));
map.put(Simulation.Status.LOADED, loadImageIcon("pix/spheres/blue-16x16.png", "Loaded from File"));
map.put(Simulation.Status.OUTDATED, loadImageIcon("pix/spheres/red-16x16.png", "Out-of-date"));
map.put(Simulation.Status.EXTERNAL, loadImageIcon("pix/spheres/blue-16x16.png", "Imported data"));
map.put(Simulation.Status.NOT_SIMULATED, loadImageIcon(SIM_OUTDATED, "Not simulated"));
map.put(Simulation.Status.CANT_RUN, loadImageIcon(SIM_CANTRUN, "Can't run, no motors assigned."));
map.put(Simulation.Status.UPTODATE, loadImageIcon(SIM_UPTODATE, "Up to date"));
map.put(Simulation.Status.LOADED, loadImageIcon(SIM_UPTODATE, "Loaded from File"));
map.put(Simulation.Status.OUTDATED, loadImageIcon(SIM_OUTDATED, "Out-of-date"));
map.put(Simulation.Status.EXTERNAL, loadImageIcon(SIM_UPTODATE, "Imported data"));
SIMULATION_STATUS_ICON_MAP = Collections.unmodifiableMap(map);
}
@ -139,6 +143,17 @@ public class Icons {
return new ImageIcon(url, name);
}
/**
* Loads an ImageIcon with a new name.
*
* @param icon the original ImageIcon to load.
* @param newName the new name for the ImageIcon.
* @return the loaded ImageIcon with the new name.
*/
public static ImageIcon loadImageIconWithNewName(ImageIcon icon, String newName) {
return new ImageIcon(icon.getImage(), newName);
}
/**
* Scales an ImageIcon to the specified scale.
* @param icon icon to scale