Java Code Examples for javafx.stage.Stage#setMinHeight()

The following examples show how to use javafx.stage.Stage#setMinHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrexApp.java    From trex-stateless-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    speedupTooltip();
    primaryStage = stage;
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/MainView.fxml"));
    AnchorPane page = fxmlLoader.load();
    MainViewController mainviewcontroller = fxmlLoader.getController();
    Scene scene = new Scene(page);
    scene.getStylesheets().add(TrexApp.class.getResource("/styles/mainStyle.css").toExternalForm());
    stage.setScene(scene);
    stage.setTitle("TRex");
    stage.setResizable(true);
    stage.setMinWidth(780);
    stage.setMinHeight(700);
    stage.getIcons().add(new Image("/icons/trex.png"));

    packetBuilderAppController = injector.getInstance(AppController.class);
    PreferencesManager.getInstance().setPacketEditorConfigurations(packetBuilderAppController.getConfigurations());
    packetBuilderAppController.registerEventBusHandler(mainviewcontroller);

    stage.show();
}
 
Example 2
Source File: AlertBox.java    From SmartCity-ParkingManagement with Apache License 2.0 6 votes vote down vote up
public void display(final String title, final String message) {
	window = new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	window.setTitle(title);
	window.setMinWidth(250);
	window.setMinHeight(100);
	window.getIcons().add(new Image(getClass().getResourceAsStream("Smart_parking_icon.png")));

	final Label label = new Label();
	label.setText(message);
	final Button button = new Button("OK");
	button.setOnAction(λ -> window.close());
	final VBox layout = new VBox();
	layout.getChildren().addAll(label, button);
	layout.setAlignment(Pos.CENTER);

	final Scene scene = new Scene(layout);
	scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm());
	window.setScene(scene);
	window.showAndWait();
}
 
Example 3
Source File: MessageBox.java    From SmartCity-ParkingManagement with Apache License 2.0 6 votes vote down vote up
public void display(final String title, final String message) {
	window = new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	window.setTitle(title);
	window.setMinWidth(250);
	window.setMinHeight(100);
	window.getIcons().add(new Image(getClass().getResourceAsStream("Smart_parking_icon.png")));

	final Label label = new Label();
	label.setText(message);

	final VBox layout = new VBox();
	layout.getChildren().addAll(label);
	layout.setAlignment(Pos.CENTER);

	final Scene scene = new Scene(layout);
	scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm());
	window.setScene(scene);
	window.showAndWait();

}
 
Example 4
Source File: MainApp.java    From Motion_Profile_Generator with MIT License 6 votes vote down vote up
@Override
public void start( Stage primaryStage )
{
    try
    {
        Pane root = FXMLLoader.load( getClass().getResource("/com/mammen/ui/javafx/main/MainUI.fxml") );
        root.autosize();

        primaryStage.setScene( new Scene( root ) );
        primaryStage.sizeToScene();
        primaryStage.setTitle("Motion Profile Generator");
        primaryStage.setMinWidth( 1280 ); //1170
        primaryStage.setMinHeight( 720 ); //790
        primaryStage.setResizable( true );

        primaryStage.show();
    }
    catch( Exception e )
    {
        e.printStackTrace();
    }
}
 
Example 5
Source File: Main.java    From Cryogen with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    //iCloudTest.dryRun("email", "password");
    Font.loadFont(Main.class.getResource("binResc/Roboto-Thin.ttf").toExternalForm(), 24);
    StaticStage.mainStage = primaryStage;
    primaryStage.initStyle(StageStyle.TRANSPARENT);
    primaryStage.setTitle("Icew1nd");
    StaticStage.loadScreen(Lite.splash() ? "Splash" : "Title");
    primaryStage.setMinHeight(600);
    primaryStage.setMinWidth(800);
    primaryStage.setHeight(600);
    primaryStage.setWidth(800);
    primaryStage.getIcons().addAll(
            //This isn't working with my ultra-high DPI. :(
            new Image(Main.class.getResourceAsStream("binResc/icon.png"))
    );
}
 
Example 6
Source File: Main.java    From gramophy with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception{

    AnchorPane root = FXMLLoader.load(getClass().getResource("dash.fxml"));
    primaryStage.setTitle("Gramophy");
    primaryStage.setMinWidth(950);
    primaryStage.setMinHeight(570);
    Scene s = new Scene(root);
    primaryStage.setScene(s);
    primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("assets/app_icon.png")));
    primaryStage.show();

    primaryStage.setOnCloseRequest(event -> {
        try
        {
            GlobalScreen.unregisterNativeHook();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    });
}
 
Example 7
Source File: GUI.java    From density-converter with Apache License 2.0 5 votes vote down vote up
public static GUIController setup(Stage primaryStage, IPreferenceStore store, Dimension screenSize) throws IOException {
    primaryStage.setTitle("Density Converter");

    ResourceBundle bundle = ResourceBundle.getBundle("bundles.strings", Locale.getDefault());

    FXMLLoader loader = new FXMLLoader(GUI.class.getClassLoader().getResource("main.fxml"));
    loader.setResources(bundle);
    Parent root = loader.load();
    GUIController controller = loader.getController();
    controller.onCreate(primaryStage, store, bundle);

    if (screenSize.getHeight() <= 768) {
        MIN_HEIGHT = 740;
    }

    Scene scene = new Scene(root, 600, MIN_HEIGHT);
    primaryStage.setScene(scene);
    primaryStage.setResizable(true);
    primaryStage.setMinWidth(400);
    primaryStage.setMinHeight(500);
    primaryStage.getIcons().add(new Image("img/density_converter_icon_16.png"));
    primaryStage.getIcons().add(new Image("img/density_converter_icon_24.png"));
    primaryStage.getIcons().add(new Image("img/density_converter_icon_48.png"));
    primaryStage.getIcons().add(new Image("img/density_converter_icon_64.png"));
    primaryStage.getIcons().add(new Image("img/density_converter_icon_128.png"));
    primaryStage.getIcons().add(new Image("img/density_converter_icon_256.png"));

    return controller;
}
 
Example 8
Source File: ConfirmBox.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
public boolean display(final String title, final String message) {
	final Stage window = new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	window.setTitle(title);
	window.setMinWidth(250);
	window.setMinHeight(150);
	window.getIcons().add(new Image(getClass().getResourceAsStream("Smart_parking_icon.png")));

	final Label label = new Label();
	label.setText(message);

	yesButton = new Button("Yes");
	yesButton.setOnAction(λ -> {

		answer = true;
		window.close();
	});

	noButton = new Button("No");
	noButton.setOnAction(λ -> {
		answer = false;
		window.close();
	});

	final VBox layout = new VBox();
	layout.getChildren().addAll(label, noButton, yesButton);
	layout.setAlignment(Pos.CENTER);
	final Scene scene = new Scene(layout);
	scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm());
	window.setScene(scene);
	window.showAndWait();

	return answer;
}
 
Example 9
Source File: Visualizer.java    From HdrHistogramVisualizer with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    VisualizerView root = new VisualizerView();
    Scene scene = new Scene(root.getView());
    stage.setMinWidth(500);
    stage.setMinHeight(550);
    stage.setTitle("HdrHistogram Visualizer");
    stage.setScene(scene);
    stage.show();

    // Auto load css file
    registerCssChangeListener(root.getView().getStylesheets(), Paths.get("visualizer.css"));

}
 
Example 10
Source File: UndecoratorScene.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * UndecoratorScene constructor
 *
 * @param stage The main stage
 * @param stageStyle could be StageStyle.UTILITY or StageStyle.TRANSPARENT
 * @param root your UI to be displayed in the Stage
 * @param stageDecorationFxml Your own Stage decoration or null to use the
 * built-in one
 */
public UndecoratorScene(Stage stage, StageStyle stageStyle, Region root, String stageDecorationFxml) {
    super(root);
    myRoot = root;
    /*
     * Fxml
     */
    if (stageDecorationFxml == null) {
        if (stageStyle == StageStyle.UTILITY) {
            stageDecorationFxml = STAGEDECORATION_UTILITY;
        } else {
            stageDecorationFxml = STAGEDECORATION;
        }
    }
    undecorator = new Undecorator(stage, root, stageDecorationFxml, stageStyle);
    super.setRoot(undecorator);

    // Customize it by CSS if needed:
    if (stageStyle == StageStyle.UTILITY) {
        undecorator.getStylesheets().add(STYLESHEET_UTILITY);
    } else {
        undecorator.getStylesheets().add(STYLESHEET);
    }

    // Transparent scene and stage
    if (stage.getStyle() != StageStyle.TRANSPARENT) {
        stage.initStyle(StageStyle.TRANSPARENT);
    }
    super.setFill(Color.TRANSPARENT);

    // Default Accelerators
    undecorator.installAccelerators(this);

    // Forward pref and max size to main stage
    stage.setMinWidth(undecorator.getMinWidth());
    stage.setMinHeight(undecorator.getMinHeight());
    stage.setWidth(undecorator.getPrefWidth());
    stage.setHeight(undecorator.getPrefHeight());
}
 
Example 11
Source File: MainApp.java    From Corendon-LostLuggage with MIT License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {

    //Method to set the db property
    setDatabase("corendonlostluggage", "root", "admin");
            
    //set root
    root = FXMLLoader.load(getClass().getResource("/fxml/MainView.fxml"));
    Scene mainScene = new Scene(root);

    checkLoggedInStatus(currentUser);

    mainScene.getStylesheets().add("/styles/Styles.css");

    stage.setTitle("Corendon Lost Luggage");
    stage.setScene(mainScene);

    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());

    stage.setMinWidth(1000);
    stage.setMinHeight(700);

    Image logo = new Image("Images/Stage logo.png");
    //Image applicationIcon = new Image(getClass().getResourceAsStream("Images/Logo.png"));
    stage.getIcons().add(logo);

    stage.show();

    //Set the mainstage as a property
    MainApp.mainStage = stage;

}
 
Example 12
Source File: FeatureTableFXUtil.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates and shows a new FeatureTable. Should be called via {@link
 * Platform#runLater(Runnable)}.
 *
 * @param flist The feature list.
 * @return The {@link FeatureTableWindowFXMLController} of the window or null if failed to
 * initialise.
 */
@Nullable
public static FeatureTableWindowFXMLController createFeatureTableWindow(
    ModularFeatureList flist) {

  FeatureTableWindowFXMLController controller;

  FXMLLoader loader =
      new FXMLLoader((FeatureTableFX.class.getResource("FeatureTableFXMLWindow.fxml")));
  Stage stage = new Stage();

  try {
    AnchorPane root = (AnchorPane) loader.load();
    Scene scene = new Scene(root, 1000, 600);

    // Use main CSS
    scene.getStylesheets()
        .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets());
    stage.setScene(scene);
    logger.finest("Feature table stage has been successfully loaded from the FXML loader.");
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }

  // Get controller
  controller = loader.getController();

  stage.setTitle("Feature table - " + flist.getName());
  stage.show();
  stage.setMinWidth(stage.getWidth());
  stage.setMinHeight(stage.getHeight());

  controller.setFeatureList(flist);

  return controller;
}
 
Example 13
Source File: Game2048.java    From fx2048 with GNU General Public License v3.0 5 votes vote down vote up
private void setGameBounds(Stage primaryStage, Scene scene) {
    var margin = UserSettings.MARGIN;
    var gameBounds = gamePane.getGameManager().getLayoutBounds();
    var visualBounds = Screen.getPrimary().getVisualBounds();
    double factor = Math.min(visualBounds.getWidth() / (gameBounds.getWidth() + margin),
            visualBounds.getHeight() / (gameBounds.getHeight() + margin));
    primaryStage.setTitle("2048FX");
    primaryStage.setScene(scene);
    primaryStage.setMinWidth(gameBounds.getWidth() / 2d);
    primaryStage.setMinHeight(gameBounds.getHeight() / 2d);
    primaryStage.setWidth(((gameBounds.getWidth() + margin) * factor) / 1.5d);
    primaryStage.setHeight(((gameBounds.getHeight() + margin) * factor) / 1.5d);
}
 
Example 14
Source File: EditThemeScheduleActionHandler.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Edit the theme of the currently selected item in the schedule.
 *
 * @param t the action event.
 */
@Override
public void handle(ActionEvent t) {
    TextDisplayable firstSelected = selectedDisplayable;
    if (selectedDisplayable == null) {
        firstSelected = (TextDisplayable) QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList().getSelectionModel().getSelectedItem();
    }
    InlineCssTextArea wordsArea = new InlineCssTextArea();
    wordsArea.replaceText(firstSelected.getSections()[0].toString().trim());
    Button confirmButton = new Button(LabelGrabber.INSTANCE.getLabel("ok.button"), new ImageView(new Image("file:icons/tick.png")));
    Button cancelButton = new Button(LabelGrabber.INSTANCE.getLabel("cancel.button"), new ImageView(new Image("file:icons/cross.png")));
    final Stage s = new Stage();
    s.initModality(Modality.APPLICATION_MODAL);
    s.initOwner(QueleaApp.get().getMainWindow());
    s.resizableProperty().setValue(false);
    final BorderPane bp = new BorderPane();
    final ThemePanel tp = new ThemePanel(wordsArea, confirmButton, true);
    tp.setPrefSize(500, 500);
    if (firstSelected.getSections().length > 0) {
        tp.setTheme(firstSelected.getSections()[0].getTheme());
    }
    confirmButton.setOnAction(e -> {
        if (tp.getTheme() != null) {
            ScheduleList sl = QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList();
            tp.updateTheme(false);
            List<Displayable> displayableList;
            if (selectedDisplayable == null) {
                displayableList = sl.getSelectionModel().getSelectedItems();
            } else {
                displayableList = new ArrayList<>();
                displayableList.add(selectedDisplayable);
            }
            for (Displayable eachDisplayable : displayableList) {
                if (eachDisplayable instanceof TextDisplayable) {
                    ((TextDisplayable) eachDisplayable).setTheme(tp.getTheme());
                    for (TextSection ts : ((TextDisplayable) eachDisplayable).getSections()) {
                        ts.setTheme(tp.getTheme());
                    }
                    if (eachDisplayable instanceof SongDisplayable) {
                        Utils.updateSongInBackground((SongDisplayable) eachDisplayable, true, false);
                    }
                }
            }
            QueleaApp.get().getMainWindow().getMainPanel().getPreviewPanel().refresh();
        }
        s.hide();
    });
    cancelButton.setOnAction(e -> {
        s.hide();
    });
    bp.setCenter(tp);

    HBox hb = new HBox(10);
    hb.setPadding(new Insets(10));
    BorderPane.setAlignment(hb, Pos.CENTER);
    hb.setAlignment(Pos.CENTER);
    hb.getChildren().addAll(confirmButton, cancelButton);
    bp.setBottom(hb);

    Scene scene = new Scene(bp);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    s.setScene(scene);
    s.setMinHeight(600);
    s.setMinWidth(250);
    s.showAndWait();
}
 
Example 15
Source File: Main.java    From JavaFXSmartGraph with MIT License 4 votes vote down vote up
@Override
public void start(Stage ignored) {

    Graph<String, String> g = build_sample_digraph();
    //Graph<String, String> g = build_flower_graph();
    System.out.println(g);
    
    SmartPlacementStrategy strategy = new SmartCircularSortedPlacementStrategy();
    //SmartPlacementStrategy strategy = new SmartRandomPlacementStrategy();
    SmartGraphPanel<String, String> graphView = new SmartGraphPanel<>(g, strategy);

    /*
    After creating, you can change the styling of some element.
    This can be done at any time afterwards.
    */
    if (g.numVertices() > 0) {
        graphView.getStylableVertex("A").setStyle("-fx-fill: gold; -fx-stroke: brown;");
    }

    /*
    Basic usage:            
    Use SmartGraphDemoContainer if you want zoom capabilities and automatic layout toggling
    */
    //Scene scene = new Scene(graphView, 1024, 768);
    Scene scene = new Scene(new SmartGraphDemoContainer(graphView), 1024, 768);

    Stage stage = new Stage(StageStyle.DECORATED);
    stage.setTitle("JavaFX SmartGraph Visualization");
    stage.setMinHeight(500);
    stage.setMinWidth(800);
    stage.setScene(scene);
    stage.show();

    /*
    IMPORTANT: Must call init() after scene is displayed so we can have width and height values
    to initially place the vertices according to the placement strategy
    */
    graphView.init();

    /*
    Bellow you can see how to attach actions for when vertices and edges are double clicked
     */
    graphView.setVertexDoubleClickAction(graphVertex -> {
        System.out.println("Vertex contains element: " + graphVertex.getUnderlyingVertex().element());

        //toggle different styling
        if( !graphVertex.removeStyleClass("myVertex") ) {
            /* for the golden vertex, this is necessary to clear the inline
               css class. Otherwise, it has priority. Test and uncomment. */
            //graphVertex.setStyle(null); 
            
            graphVertex.addStyleClass("myVertex");
        }            
        
        //want fun? uncomment below with automatic layout
        //g.removeVertex(graphVertex.getUnderlyingVertex());
        //graphView.update();
    });

    graphView.setEdgeDoubleClickAction(graphEdge -> {
        System.out.println("Edge contains element: " + graphEdge.getUnderlyingEdge().element());
        //dynamically change the style when clicked
        graphEdge.setStyle("-fx-stroke: black; -fx-stroke-width: 2;");
        
        
        //uncomment to see edges being removed after click
        //Edge<String, String> underlyingEdge = graphEdge.getUnderlyingEdge();
        //g.removeEdge(underlyingEdge);
        //graphView.update();
    });

    /*
    Should proceed with automatic layout or keep original placement?
    If using SmartGraphDemoContainer you can toggle this in the UI 
     */
    //graphView.setAutomaticLayout(true);

    /* 
    Uncomment lines to test adding of new elements
     */
    //continuously_test_adding_elements(g, graphView);
    //stage.setOnCloseRequest(event -> {
    //    running = false;
    //});
}
 
Example 16
Source File: JfxApplication.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
public void start(@NotNull Stage stage) throws Exception {
    JfxApplication.instance = this;
    this.stage = stage;

    addWindow(stage);
    try {

        // initialize javaFX events in javaFX thread.
        ArrayFactory.asArray(ComboBoxBase.ON_SHOWN);

        var resourceManager = ResourceManager.getInstance();
        resourceManager.reload();

        var initializationManager = InitializationManager.getInstance();
        initializationManager.onBeforeCreateJavaFxContext();

        var pluginManager = PluginManager.getInstance();
        pluginManager.handlePlugins(editorPlugin -> editorPlugin.register(CssRegistry.getInstance()));

        LogView.getInstance();
        SvgImageLoaderFactory.install();
        ImageIO.read(getClass().getResourceAsStream("/ui/icons/test/test.jpg"));

        var icons = stage.getIcons();
        icons.add(new Image("/ui/icons/app/256x256.png"));
        icons.add(new Image("/ui/icons/app/128x128.png"));
        icons.add(new Image("/ui/icons/app/96x96.png"));
        icons.add(new Image("/ui/icons/app/64x64.png"));
        icons.add(new Image("/ui/icons/app/48x48.png"));
        icons.add(new Image("/ui/icons/app/32x32.png"));
        icons.add(new Image("/ui/icons/app/24x24.png"));
        icons.add(new Image("/ui/icons/app/16x16.png"));

        var config = EditorConfig.getInstance();

        stage.initStyle(StageStyle.DECORATED);
        stage.setMinHeight(600);
        stage.setMinWidth(800);
        stage.setWidth(config.getScreenWidth());
        stage.setHeight(config.getScreenHeight());
        stage.setMaximized(config.isMaximized());
        stage.setTitle(Config.TITLE);
        stage.show();


        if (!stage.isMaximized()) {
            stage.centerOnScreen();
        }

        stage.widthProperty().addListener((observable, oldValue, newValue) -> {
            if (stage.isMaximized()) return;
            config.setScreenWidth(newValue.intValue());
        });
        stage.heightProperty().addListener((observable, oldValue, newValue) -> {
            if (stage.isMaximized()) return;
            config.setScreenHeight(newValue.intValue());
        });

        stage.maximizedProperty()
                .addListener((observable, oldValue, newValue) -> config.setMaximized(newValue));

        buildScene();

    } catch (Throwable e) {
        LOGGER.error(this, e);
        throw e;
    }
}
 
Example 17
Source File: MZmineGUI.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  MZmineGUI.mainStage = stage;
  MZmineCore.setDesktop(this);

  logger.finest("Initializing MZmine main window");

  try {
    // Load the main window
      URL mainFXML = this.getClass().getResource(mzMineFXML);
      FXMLLoader loader = new FXMLLoader(mainFXML);

    rootScene = loader.load();
    mainWindowController = loader.getController();
    stage.setScene(rootScene);

  } catch (Exception e) {
    e.printStackTrace();
    logger.severe("Error loading MZmine GUI from FXML: " + e);
    Platform.exit();
  }

  stage.setTitle("MZmine " + MZmineCore.getMZmineVersion());
  stage.setMinWidth(600);
  stage.setMinHeight(400);

  // Set application icon
  stage.getIcons().setAll(mzMineIcon);

  stage.setOnCloseRequest(e -> {
    requestQuit();
    e.consume();
  });

  // Drag over surface
  rootScene.setOnDragOver(MZmineGUI::activateSetOnDragOver);
  // Dropping over surface
  rootScene.setOnDragDropped(MZmineGUI::activateSetOnDragDropped);

  // Configure desktop properties such as the application taskbar icon
  // on a new thread. It is important to start this thread after the
  // JavaFX subsystem has started. Otherwise we could be treated like a
  // Swing application.
  Thread desktopSetupThread = new Thread(new DesktopSetup());
  desktopSetupThread.setPriority(Thread.MIN_PRIORITY);
  desktopSetupThread.start();

  setStatusBarText("Welcome to MZmine " + MZmineCore.getMZmineVersion());

  stage.show();

  // update the size and position of the main window
  /*
   * ParameterSet paramSet = configuration.getPreferences(); WindowSettingsParameter settings =
   * paramSet .getParameter(MZminePreferences.windowSetttings);
   * settings.applySettingsToWindow(desktop.getMainWindow());
   */
  // add last project menu items
  /*
   * if (desktop instanceof MainWindow) { ((MainWindow) desktop).createLastUsedProjectsMenu(
   * configuration.getLastProjects()); // listen for changes
   * configuration.getLastProjectsParameter() .addFileListChangedListener(list -> { // new list of
   * last used projects Desktop desk = getDesktop(); if (desk instanceof MainWindow) {
   * ((MainWindow) desk) .createLastUsedProjectsMenu(list); } }); }
   */

  // Activate project - bind it to the desktop's project tree
  MZmineProjectImpl currentProject =
      (MZmineProjectImpl) MZmineCore.getProjectManager().getCurrentProject();
  MZmineGUI.activateProject(currentProject);


  // Check for updated version
  NewVersionCheck NVC = new NewVersionCheck(CheckType.DESKTOP);
  Thread nvcThread = new Thread(NVC);
  nvcThread.setPriority(Thread.MIN_PRIORITY);
  nvcThread.start();

  // Tracker
  GoogleAnalyticsTracker GAT =
      new GoogleAnalyticsTracker("MZmine Loaded (GUI mode)", "/JAVA/Main/GUI");
  Thread gatThread = new Thread(GAT);
  gatThread.setPriority(Thread.MIN_PRIORITY);
  gatThread.start();

  // register shutdown hook only if we have GUI - we don't want to
  // save configuration on exit if we only run a batch
  ShutDownHook shutDownHook = new ShutDownHook();
  Runtime.getRuntime().addShutdownHook(shutDownHook);

}
 
Example 18
Source File: Fx3DVisualizerModule.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public @Nonnull ExitCode runModule(@Nonnull MZmineProject project,
    @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {

  final RawDataFile[] currentDataFiles = parameters
      .getParameter(Fx3DVisualizerParameters.dataFiles).getValue().getMatchingRawDataFiles();

  final ScanSelection scanSel =
      parameters.getParameter(Fx3DVisualizerParameters.scanSelection).getValue();
  final List<Feature> featureSelList =
      parameters.getParameter(Fx3DVisualizerParameters.features).getValue();
  logger.finest("Feature selection is:" + featureSelList.toString());

  Range<Double> rtRange = ScanUtils.findRtRange(scanSel
      .getMatchingScans(MZmineCore.getProjectManager().getCurrentProject().getDataFiles()[0]));

  ParameterSet myParameters =
      MZmineCore.getConfiguration().getModuleParameters(Fx3DVisualizerModule.class);
  Range<Double> mzRange = myParameters.getParameter(Fx3DVisualizerParameters.mzRange).getValue();

  int rtRes = myParameters.getParameter(Fx3DVisualizerParameters.rtResolution).getValue();
  int mzRes = myParameters.getParameter(Fx3DVisualizerParameters.mzResolution).getValue();

  if (!Platform.isSupported(ConditionalFeature.SCENE3D)) {
    MZmineCore.getDesktop().displayErrorMessage("The platform does not provide 3D support.");
    return ExitCode.ERROR;
  }
  FXMLLoader loader = new FXMLLoader((getClass().getResource("Fx3DStage.fxml")));
  Stage stage = null;
  try {
    stage = loader.load();
    logger.finest("Stage has been successfully loaded from the FXML loader.");
  } catch (Exception e) {
    e.printStackTrace();
    return ExitCode.ERROR;
  }
  String title = "";
  Fx3DStageController controller = loader.getController();
  controller.setScanSelection(scanSel);
  controller.setRtAndMzResolutions(rtRes, mzRes);
  controller.setRtAndMzValues(rtRange, mzRange);
  for (int i = 0; i < currentDataFiles.length; i++) {
    MZmineCore.getTaskController().addTask(
        new Fx3DSamplingTask(currentDataFiles[i], scanSel, mzRange, rtRes, mzRes, controller),
        TaskPriority.HIGH);

  }
  controller.addFeatureSelections(featureSelList);
  for (int i = 0; i < currentDataFiles.length; i++) {
    title = title + currentDataFiles[i].toString() + " ";
  }
  stage.show();
  stage.setMinWidth(400.0);
  stage.setMinHeight(400.0);

  return ExitCode.OK;

}
 
Example 19
Source File: MZmineGUI.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void start(Stage stage) {

    try {
      // Load the main window
      URL mainFXML = new URL(mzMineFXML);
      FXMLLoader loader = new FXMLLoader(mainFXML);

      rootScene = loader.load();
      mainWindowController = loader.getController();
      stage.setScene(rootScene);

    } catch (IOException e) {
      e.printStackTrace();
      logger.error("Error loading MZmine GUI from FXML: " + e);
      Platform.exit();
    }

    stage.setTitle("MZmine " + MZmineCore.getMZmineVersion());
    stage.setMinWidth(300);
    stage.setMinHeight(300);

    // Set application icon
    stage.getIcons().setAll(mzMineIcon);

    stage.setOnCloseRequest(e -> {
      requestQuit();
      e.consume();
    });

    // Activate new GUI-supported project
    MZmineGUIProject project = new MZmineGUIProject();
    MZmineGUI.activateProject(project);

    stage.show();

    // Check for new version of MZmine
    NewVersionCheck NVC = new NewVersionCheck(CheckType.DESKTOP);
    Thread nvcThread = new Thread(NVC);
    nvcThread.setPriority(Thread.MIN_PRIORITY);
    nvcThread.start();
  }
 
Example 20
Source File: DriversInstall.java    From ns-usbloader with GNU General Public License v3.0 4 votes vote down vote up
public DriversInstall(ResourceBundle rb){

        if (DriversInstall.isRunning)
            return;

        DriversInstall.isRunning = true;

        DownloadDriversTask downloadTask = new DownloadDriversTask();

        Button cancelButton = new Button(rb.getString("btn_Cancel"));

        HBox hBoxInformation = new HBox();
        hBoxInformation.setAlignment(Pos.TOP_LEFT);
        hBoxInformation.getChildren().add(new Label(rb.getString("windowBodyDownloadDrivers")));

        ProgressBar progressBar = new ProgressBar();
        progressBar.setPrefWidth(Double.MAX_VALUE);
        progressBar.progressProperty().bind(downloadTask.progressProperty());

        Label downloadStatusLabel = new Label();
        downloadStatusLabel.setWrapText(true);
        downloadStatusLabel.textProperty().bind(downloadTask.messageProperty());

        runInstallerStatusLabel = new Label();
        runInstallerStatusLabel.setWrapText(true);

        Pane fillerPane1 = new Pane();
        Pane fillerPane2 = new Pane();

        VBox parentVBox = new VBox();
        parentVBox.setAlignment(Pos.TOP_CENTER);
        parentVBox.setFillWidth(true);
        parentVBox.setSpacing(5.0);
        parentVBox.setPadding(new Insets(5.0));
        parentVBox.setFillWidth(true);
        parentVBox.getChildren().addAll(
                hBoxInformation,
                fillerPane1,
                downloadStatusLabel,
                runInstallerStatusLabel,
                fillerPane2,
                progressBar,
                cancelButton
        ); // TODO:FIX

        VBox.setVgrow(fillerPane1, Priority.ALWAYS);
        VBox.setVgrow(fillerPane2, Priority.ALWAYS);

        Stage stage = new Stage();

        stage.setTitle(rb.getString("windowTitleDownloadDrivers"));
        stage.getIcons().addAll(
                new Image("/res/dwnload_ico32x32.png"),    //TODO: REDRAW
                new Image("/res/dwnload_ico48x48.png"),
                new Image("/res/dwnload_ico64x64.png"),
                new Image("/res/dwnload_ico128x128.png")
        );
        stage.setMinWidth(400);
        stage.setMinHeight(150);

        Scene mainScene = new Scene(parentVBox, 405, 155);

        mainScene.getStylesheets().add(AppPreferences.getInstance().getTheme());

        stage.setOnHidden(windowEvent -> {
            downloadTask.cancel(true );
            DriversInstall.isRunning = false;
        });

        stage.setScene(mainScene);
        stage.show();
        stage.toFront();

        downloadTask.setOnSucceeded(event -> {
            cancelButton.setText(rb.getString("btn_Close"));

            String returnedValue = downloadTask.getValue();

            if (returnedValue == null)
                return;

            if (runInstaller(returnedValue))
                stage.close();
        });

        Thread downloadThread = new Thread(downloadTask);
        downloadThread.start();

        cancelButton.setOnAction(actionEvent -> {
            downloadTask.cancel(true );
            stage.close();
        });
    }