Skip to content

Commit

Permalink
Bug fixes for save dialog and window resizing
Browse files Browse the repository at this point in the history
Fixed issue where trying to save plots failed. Fixed some issues with window resizing that caused weird behavior like the status bar getting really tall as the window narrows. Now window resizing should only resize the plot. On startup, the window is sized to show the entire plot.
  • Loading branch information
averydonovan committed Aug 23, 2024
1 parent 8e2354a commit 1a5e986
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.averydonovan</groupId>
<artifactId>SkewTVSP</artifactId>
<name>Skew-T Virtual Sounding Plotter</name>
<version>0.3.0-alpha.4</version>
<version>0.3.0-alpha.5</version>
<url>http://github.com/averydonovan/SkewTVirtualSoundingPlotter/</url>
<inceptionYear>2016</inceptionYear>
<developers>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.averydonovan</groupId>
<artifactId>SkewTVSP</artifactId>
<version>0.3.0-alpha.4</version>
<version>0.3.0-alpha.5</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/averydonovan/skewtvsp/SkewTVSP.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static javafx.application.Application.launch;
import javafx.stage.Screen;

/**
* Main class for application. Loads main window from FXML file.
Expand All @@ -48,8 +49,12 @@ public class SkewTVSP extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/fxml/STVSP.fxml"));

Scene scene = new Scene(root, 1149, 700);

int screenHeight = (int) (Screen.getPrimary().getBounds().getHeight()*10)/11;
int screenWidth = (screenHeight*9)/12 + 220;

//Scene scene = new Scene(root, 1100, 1000);
Scene scene = new Scene(root, screenWidth, screenHeight);

primaryStage.titleProperty().bind(STVSPController.windowTitle);
primaryStage.setScene(scene);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ protected void doSaveSkewT(ActionEvent event) {
chooser.setInitialFileName(initFileName);
ExtensionFilter fileExtsPNG = new ExtensionFilter("PNG images", "*.png", "*.PNG");
chooser.getExtensionFilters().addAll(fileExtsPNG);
File file = chooser.showSaveDialog(anchorPane.getScene().getWindow());
File file = chooser.showSaveDialog(getMainStage());

// Only try to save plot if a location and filename was chosen
if (file != null) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fxml/STVSP.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox fx:id="mainContainer" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="700.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.averydonovan.skewtvsp.controllers.STVSPController">
<VBox fx:id="mainContainer" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="1000.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/21.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.averydonovan.skewtvsp.controllers.STVSPController">
<children>
<SplitPane dividerPositions="0.1">
<SplitPane dividerPositions="0.1" VBox.vgrow="ALWAYS">
<items>
<AnchorPane maxHeight="1.7976931348623157E308" SplitPane.resizableWithParent="false">
<children>
Expand Down Expand Up @@ -215,7 +215,7 @@
</ScrollPane>
</items>
</SplitPane>
<HBox alignment="BOTTOM_CENTER" maxWidth="1.7976931348623157E308" spacing="5.0">
<HBox alignment="BOTTOM_CENTER" fillHeight="false" maxHeight="28.0" maxWidth="1.7976931348623157E308" spacing="5.0">
<children>
<Label fx:id="lblStatus" maxWidth="1.7976931348623157E308" minWidth="400.0" prefWidth="600.0" text="Label" HBox.hgrow="ALWAYS" />
<ProgressBar fx:id="pbProgress" maxWidth="200.0" minWidth="200.0" prefWidth="200.0" progress="0.0" visible="false" />
Expand Down

0 comments on commit 1a5e986

Please sign in to comment.