mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
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:
parent
6eaa6e4978
commit
128a512ff6
@ -10,6 +10,7 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
import com.sun.glass.ui.Screen;
|
||||
|
||||
import PamController.PamGUIManager;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
/**
|
||||
@ -138,40 +139,49 @@ public class ScreenSize {
|
||||
|
||||
private static Rectangle findScreenBounds() {
|
||||
Rectangle virtualBounds = new Rectangle();
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] gs =ge.getScreenDevices();
|
||||
nScreens = gs.length;
|
||||
screenDimensions = new Rectangle[nScreens];
|
||||
for (int j = 0; j < gs.length; j++) {
|
||||
GraphicsDevice gd = gs[j];
|
||||
//Think to get screen sizes on multiple monitors
|
||||
//can just use getDefaultConfiguration for
|
||||
//each device rather than looping over
|
||||
//all configurations. Hopefully should
|
||||
//let PAMGUARD start up a little quicker
|
||||
//CJB 2009-06-15
|
||||
GraphicsConfiguration dgc = gd.getDefaultConfiguration();
|
||||
// System.out.printf("", dgc.getBufferCapabilities().)
|
||||
// System.out.println(dgc);
|
||||
screenDimensions[j] = dgc.getBounds();
|
||||
virtualBounds = virtualBounds.union(dgc.getBounds());
|
||||
|
||||
}
|
||||
// new Pane();
|
||||
// List<Screen> screens = Screen.getScreens();
|
||||
// if (screens != null) {
|
||||
// for (Screen aScreen : screens) {
|
||||
// System.out.printf("Screen resX %d, resY %d\n",
|
||||
// aScreen.getResolutionX(),
|
||||
// aScreen.getResolutionY());
|
||||
// }
|
||||
// }
|
||||
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;
|
||||
screenDimensions = new Rectangle[nScreens];
|
||||
for (int j = 0; j < gs.length; j++) {
|
||||
GraphicsDevice gd = gs[j];
|
||||
//Think to get screen sizes on multiple monitors
|
||||
//can just use getDefaultConfiguration for
|
||||
//each device rather than looping over
|
||||
//all configurations. Hopefully should
|
||||
//let PAMGUARD start up a little quicker
|
||||
//CJB 2009-06-15
|
||||
GraphicsConfiguration dgc = gd.getDefaultConfiguration();
|
||||
// System.out.printf("", dgc.getBufferCapabilities().)
|
||||
// System.out.println(dgc);
|
||||
screenDimensions[j] = dgc.getBounds();
|
||||
virtualBounds = virtualBounds.union(dgc.getBounds());
|
||||
|
||||
}
|
||||
}
|
||||
// new Pane();
|
||||
// List<Screen> screens = Screen.getScreens();
|
||||
// if (screens != null) {
|
||||
// for (Screen aScreen : screens) {
|
||||
// System.out.printf("Screen resX %d, resY %d\n",
|
||||
// aScreen.getResolutionX(),
|
||||
// aScreen.getResolutionY());
|
||||
// }
|
||||
// }
|
||||
//System.out.println("virtualBounds="+virtualBounds);
|
||||
return virtualBounds;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Thread to obtain the screen bounds.
|
||||
// /**
|
||||
// * Thread to obtain the screen bounds.
|
||||
// * @author Doug
|
||||
// *
|
||||
// */
|
||||
|
@ -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;
|
||||
|
||||
angleVetoDisplay = new AngleVetoDisplay(this);
|
||||
|
||||
if (PamGUIManager.getGUIType() != PamGUIManager.NOGUI) {
|
||||
angleVetoDisplay = new AngleVetoDisplay(this);
|
||||
}
|
||||
|
||||
PamSettingManager.getInstance().registerSettings(this);
|
||||
}
|
||||
@ -96,7 +100,9 @@ public class AngleVetoes extends Object implements PamSettings {
|
||||
AngleVetoParameters newParams = AngleVetoesDialog.showDialog(frame, this);
|
||||
if (newParams != null) {
|
||||
angleVetoParameters = newParams.clone();
|
||||
angleVetoDisplay.repaint();
|
||||
if (angleVetoDisplay != null) {
|
||||
angleVetoDisplay.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +138,9 @@ public class AngleVetoes extends Object implements PamSettings {
|
||||
}
|
||||
|
||||
private void displayAction(Frame frame) {
|
||||
angleVetoDisplay.setVisible(true);
|
||||
if (angleVetoDisplay != null) {
|
||||
angleVetoDisplay.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,7 +213,9 @@ public class AngleVetoes extends Object implements PamSettings {
|
||||
* @param angle angle in degrees
|
||||
*/
|
||||
public void addAngleData(double angle) {
|
||||
angleVetoDisplay.newAngle(angle);
|
||||
if (angleVetoDisplay != null) {
|
||||
angleVetoDisplay.newAngle(angle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,6 +223,8 @@ public class AngleVetoes extends Object implements PamSettings {
|
||||
* @param pass true if there was a pass, false for a fail.
|
||||
*/
|
||||
public void addPassData(boolean pass) {
|
||||
angleVetoDisplay.newPassData(pass);
|
||||
if (angleVetoDisplay != null) {
|
||||
angleVetoDisplay.newPassData(pass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user