Skip to content

Commit

Permalink
Fixed static variable problem for XR3Capture
Browse files Browse the repository at this point in the history
  • Loading branch information
goxr3plus committed May 27, 2018
1 parent 4b46d4c commit 9dd9c30
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ private void startPart2() {
aboutWindow.getWindow().initOwner(window);
updateWindow.getWindow().initOwner(window);
tagWindow.getWindow().initOwner(window);
captureWindow.stage.initOwner(window);
captureWindow.getStage().initOwner(window);
captureWindow.settingsWindowController.getStage().initOwner(window);

// --------- Fix the Background ------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private void initialize() {
applicationConsole.setOnAction(a -> Main.consoleWindow.show());

//snapShot
snapshot.setOnAction(a -> CaptureWindow.stage.show());
snapshot.setOnAction(a -> Main.captureWindow.getStage().show());

// importDataBase
importDataBase.setOnAction(e -> importDatabase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CaptureWindow {
private Thread positionFixerThread;

/** The stage. */
public static Stage stage = new Stage();
private Stage stage;

/** The main window controller. */
public MainWindowController mainWindowController;
Expand All @@ -47,20 +47,21 @@ public CaptureWindow() {
try {

// stage
stage.setTitle("XR3Capture Version 9!");
stage = new Stage();
stage.setTitle("XR3Capture");
//stage.getIcons().add(new Image(getClass().getResourceAsStream("/image/icon.png")))
stage.initStyle(StageStyle.TRANSPARENT);
stage.setAlwaysOnTop(true);

// MainWindowController
//FXMLLoader loader1 = new FXMLLoader(getClass().getResource("/fxml/xr3capture/MainWindowController.fxml"))
//loader1.load()
mainWindowController = new MainWindowController();
mainWindowController = new MainWindowController(stage);

// CaptureWindowController
//FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/fxml/xr3capture/CaptureWindowController.fxml"))
// loader2.load()
captureWindowController = new CaptureWindowController();
captureWindowController = new CaptureWindowController(stage);

// SettingsController
// FXMLLoader loader3 = new FXMLLoader(getClass().getResource("/fxml/xr3capture/SettingsWindowController.fxml"))
Expand Down Expand Up @@ -146,4 +147,11 @@ private void stopPositionFixThread() {
positionFixerThread.interrupt();
}

/**
* @return the stage
*/
public Stage getStage() {
return stage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class CaptureWindowController extends StackPane {

private Stage stage;

private final Stage captureWindowStage;

/** The stack pane. */
@FXML
private StackPane stackPane;
Expand Down Expand Up @@ -226,7 +228,8 @@ public void handle(long timestamp) {
/**
* Constructor.
*/
public CaptureWindowController() {
public CaptureWindowController(Stage captureWindowStage) {
this.captureWindowStage = captureWindowStage;

// ------------------------------------FXMLLOADER ----------------------------------------
FXMLLoader loader = new FXMLLoader(getClass().getResource(InfoTool.XR3CAPTURE_FXMLS + "CaptureWindowController.fxml"));
Expand Down Expand Up @@ -409,7 +412,7 @@ private void addKeyHandlers() {
deActivateAllKeys();

// show the appropriate windows
CaptureWindow.stage.show();
captureWindowStage.show();
stage.close();
} else if (key.getCode() == KeyCode.ENTER || key.getCode() == KeyCode.SPACE) {
// Stop MaryTTS
Expand Down Expand Up @@ -586,7 +589,7 @@ private void selectWholeScreen() {
public void prepareForCapture() {
stage.show();
repaintCanvas();
CaptureWindow.stage.close();
captureWindowStage.close();
settingsWindowController.getStage().close();
//if (settingsWindowController.getMarryTTSToggle().isSelected())
// Main.textToSpeech.speak("Select an area of the screen dragging your mouse and then press Enter or Space");
Expand Down Expand Up @@ -658,7 +661,7 @@ public void startService(BufferedImage image2) {
*/
private void done() {

CaptureWindow.stage.show();
captureWindowStage.show();
stage.close();

//Was it seccussful?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javafx.scene.control.Slider;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import main.java.com.goxr3plus.xr3player.application.tools.InfoTool;

/**
Expand Down Expand Up @@ -69,10 +70,13 @@ public class MainWindowController extends StackPane {
/** The capture window controller. */
CaptureWindowController captureWindowController;

private final Stage captureWindowStage;

/**
* Constructor
*/
public MainWindowController() {
public MainWindowController(Stage captureWindowStage) {
this.captureWindowStage = captureWindowStage;

// ------------------------------------FXMLLOADER ----------------------------------------
FXMLLoader loader = new FXMLLoader(getClass().getResource(InfoTool.XR3CAPTURE_FXMLS + "MainWindowController.fxml"));
Expand All @@ -96,7 +100,6 @@ public MainWindowController() {
* @param settingsWindowController
* the settings window controller
*/
@SuppressWarnings("hiding")
public void addControllerReferences(CaptureWindowController captureWindowController , SettingsWindowController settingsWindowController) {

this.captureWindowController = captureWindowController;
Expand All @@ -113,15 +116,11 @@ public void initialize() {
more.setOnAction(a -> settingsWindowController.getStage().show());

// minimize
minimize.setOnAction(a -> CaptureWindow.stage.setIconified(true));
minimize.setOnAction(a -> captureWindowStage.setIconified(true));

// exitButton
exitButton.setText("Close");
exitButton.setOnAction(a -> {
CaptureWindow.stage.close();
//DataBase.saveDataBaseSettings(settingsWindowController);
// Platform.exit();
});
exitButton.setOnAction(a -> captureWindowStage.close());

// captureButton
captureButton.setOnAction(a -> captureWindowController.prepareForCapture());
Expand Down

0 comments on commit 9dd9c30

Please sign in to comment.