Another attempt at stopping it crashing on a headless system

Dealing with displays that get created for clickangle vetos and a call
to the gui in the click train detector.
This commit is contained in:
Douglas Gillespie 2022-07-19 16:37:57 +01:00
parent 6eaa6e4978
commit 128a512ff6
3 changed files with 61 additions and 36 deletions

View File

@ -10,6 +10,7 @@ import javax.swing.SwingUtilities;
import com.sun.glass.ui.Screen;
import PamController.PamGUIManager;
import javafx.scene.layout.Pane;
/**
@ -138,6 +139,14 @@ public class ScreenSize {
private static Rectangle findScreenBounds() {
Rectangle virtualBounds = new Rectangle();
if (PamGUIManager.getGUIType() == PamGUIManager.NOGUI) {
virtualBounds = new Rectangle(0,0,1024,768);
nScreens = 1;
screenDimensions = new Rectangle[nScreens];
screenDimensions[0] = virtualBounds;
}
else {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs =ge.getScreenDevices();
nScreens = gs.length;
@ -157,6 +166,7 @@ public class ScreenSize {
virtualBounds = virtualBounds.union(dgc.getBounds());
}
}
// new Pane();
// List<Screen> screens = Screen.getScreens();
// if (screens != null) {

View File

@ -9,6 +9,7 @@ import javax.swing.JMenuItem;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings;
import PamController.PamGUIManager;
import PamController.PamSettingManager;
import PamController.PamSettings;
@ -35,7 +36,10 @@ public class AngleVetoes extends Object implements PamSettings {
super();
this.pamControlledUnit = pamControlledUnit;
if (PamGUIManager.getGUIType() != PamGUIManager.NOGUI) {
angleVetoDisplay = new AngleVetoDisplay(this);
}
PamSettingManager.getInstance().registerSettings(this);
}
@ -96,9 +100,11 @@ public class AngleVetoes extends Object implements PamSettings {
AngleVetoParameters newParams = AngleVetoesDialog.showDialog(frame, this);
if (newParams != null) {
angleVetoParameters = newParams.clone();
if (angleVetoDisplay != null) {
angleVetoDisplay.repaint();
}
}
}
/**
* Get a menu item for inclusion in menus of detectors using the veto (i.e. add the output of this function to
@ -132,8 +138,10 @@ public class AngleVetoes extends Object implements PamSettings {
}
private void displayAction(Frame frame) {
if (angleVetoDisplay != null) {
angleVetoDisplay.setVisible(true);
}
}
/**
* Access to the veto parameters
@ -205,14 +213,18 @@ public class AngleVetoes extends Object implements PamSettings {
* @param angle angle in degrees
*/
public void addAngleData(double angle) {
if (angleVetoDisplay != null) {
angleVetoDisplay.newAngle(angle);
}
}
/**
* Add data to pas / fail stats for display
* @param pass true if there was a pass, false for a fail.
*/
public void addPassData(boolean pass) {
if (angleVetoDisplay != null) {
angleVetoDisplay.newPassData(pass);
}
}
}

View File

@ -246,7 +246,10 @@ public class ClickTrainControl extends PamControlledUnit implements PamSettings
this.ctLocalisationProcess.setTMlocParams(this.clickTrainParams);
this.getGUI(PamGUIManager.getGUIType()).notifyGUIChange(ClickTrainControl.NEW_PARAMS);
PamControlledUnitGUI gui = this.getGUI(PamGUIManager.getGUIType());
if (gui != null) {
gui.notifyGUIChange(ClickTrainControl.NEW_PARAMS);
}
}
/**