Java Code Examples for javafx.application.Platform#isSupported()

The following examples show how to use javafx.application.Platform#isSupported() . 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: SpinningGlobe.java    From mars-sim with GNU General Public License v3.0 7 votes vote down vote up
public Parent createDraggingGlobe() {
 boolean support = Platform.isSupported(ConditionalFeature.SCENE3D);
 if (support)
  logger.config("JavaFX 3D features supported");
 else
  logger.config("JavaFX 3D features NOT supported");

    globe = new Globe();
    rotateGlobe();

 // Use a SubScene
    subScene = new SubScene(globe.getRoot(), WIDTH, HEIGHT);//, true, SceneAntialiasing.BALANCED);
    subScene.setId("sub");
    subScene.setCamera(globe.getCamera());//subScene));

    //return new Group(subScene);
    return new HBox(subScene);
}
 
Example 2
Source File: Controller.java    From everywhere with Apache License 2.0 5 votes vote down vote up
public void getSearchTextChanged(InputMethodEvent event) {
    Platform.isSupported(ConditionalFeature.INPUT_METHOD);
    if (!event.getCommitted().isEmpty()) {
        searchText += event.getCommitted();
        searchTextId.setText(searchText);
        searchTextId.end();
        System.out.println(searchText);
        List<SearchedResult> searchedResults = getSearchResult(searchText, searchField);
        showTableData(searchedResults);
    }
}
 
Example 3
Source File: SpinningGlobe.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public Parent createFixedGlobe() {
  boolean support = Platform.isSupported(ConditionalFeature.SCENE3D);
  if (support)
   logger.config("JavaFX 3D features supported");
  else
   logger.config("JavaFX 3D features NOT supported");

    globe = new Globe();
    rotateGlobe();

    //return new Group(globe.getRoot());
    return new HBox(globe.getRoot());
}
 
Example 4
Source File: Game2048.java    From fx2048 with GNU General Public License v3.0 5 votes vote down vote up
private void setEnhancedDeviceSettings(Stage primaryStage, Scene scene) {
    var isARM = System.getProperty("os.arch").toUpperCase().contains("ARM");
    if (isARM) {
        primaryStage.setFullScreen(true);
        primaryStage.setFullScreenExitHint("");
    }

    if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
        scene.setCursor(Cursor.NONE);
    }
}
 
Example 5
Source File: StylesConfig.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
public StylesConfig(Theme theme) {
    requireNotNullArg(theme, "Theme cannot be null");
    LOG.debug(DefaultI18nContext.getInstance().i18n("Installing theme {0}.", theme.friendlyName()));
    theme.styleSheets().stream().map(s -> this.getClass().getResource(s).toExternalForm()).forEach(styles::add);
    //styles.add(this.getClass().getResource(GlyphsStyle.DEFAULT.getStylePath()).toExternalForm());
    if (!Platform.isSupported(ConditionalFeature.TRANSPARENT_WINDOW)) {
        styles.add(this.getClass().getResource("/themes/transparent-incapable.css").toExternalForm());
        LOG.info("Transparent windows not supported by the platform");
    }
}
 
Example 6
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 7
Source File: MultipleAxesSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    if (Platform.isSupported(ConditionalFeature.TRANSPARENT_WINDOW)) {
        Application.setUserAgentStylesheet(Chart.class.getResource("solid-pick.css").toExternalForm());
    }

    ProcessingProfiler.setVerboseOutputState(true);
    ProcessingProfiler.setLoggerOutputState(true);
    ProcessingProfiler.setDebugState(false);

    final BorderPane root = new BorderPane();
    final Scene scene = new Scene(root, 800, 600);

    final DefaultNumericAxis xAxis1 = new DefaultNumericAxis("x axis");
    xAxis1.setAnimated(false);
    final DefaultNumericAxis yAxis1 = new DefaultNumericAxis("y axis", "random");
    yAxis1.setAnimated(false);
    final DefaultNumericAxis yAxis2 = new DefaultNumericAxis("y axis", "sine/cosine");
    // yAxis2.setSide(Side.LEFT); // unusual but possible case
    yAxis2.setSide(Side.RIGHT);
    yAxis2.setAnimated(false);
    final DefaultNumericAxis yAxis3 = new DefaultNumericAxis("y axis", "gauss");
    yAxis3.setSide(Side.RIGHT);
    yAxis3.invertAxis(true);
    yAxis3.setAnimated(false);
    final XYChart chart = new XYChart(xAxis1, yAxis1);

    // N.B. it's important to set secondary axis on the 2nd renderer before
    // adding the renderer to the chart
    final ErrorDataSetRenderer errorRenderer1 = new ErrorDataSetRenderer();
    errorRenderer1.getAxes().add(yAxis1);
    final ErrorDataSetRenderer errorRenderer2 = new ErrorDataSetRenderer();
    errorRenderer2.getAxes().add(yAxis2);
    final ErrorDataSetRenderer errorRenderer3 = new ErrorDataSetRenderer();
    errorRenderer3.getAxes().add(yAxis3);
    chart.getRenderers().addAll(errorRenderer2, errorRenderer3);

    chart.getPlugins().add(new ParameterMeasurements());
    final Zoomer zoom = new Zoomer();
    // add axes that shall be excluded from the zoom action
    zoom.omitAxisZoomList().add(yAxis3);
    // alternatively (uncomment):
    // Zoomer.setOmitZoom(yAxis3, true);
    chart.getPlugins().add(zoom);
    chart.getToolBar().getChildren().add(new MyZoomCheckBox(zoom, yAxis3));
    chart.getPlugins().add(new EditAxis());

    final Button newDataSet = new Button("new DataSet");
    newDataSet.setOnAction(
            evt -> Platform.runLater(getTask(errorRenderer1, errorRenderer2, errorRenderer3)));
    final Button startTimer = new Button("timer");
    startTimer.setOnAction(evt -> {
        if (scheduledFuture == null || scheduledFuture.isCancelled()) {
            scheduledFuture = timer.scheduleAtFixedRate(
                    getTask(chart.getRenderers().get(0), errorRenderer2, errorRenderer3),
                    MultipleAxesSample.UPDATE_DELAY, MultipleAxesSample.UPDATE_PERIOD, TimeUnit.MILLISECONDS);
        } else {
            scheduledFuture.cancel(false);
        }
    });

    root.setTop(new HBox(newDataSet, startTimer));

    // generate the first set of data
    getTask(chart.getRenderers().get(0), errorRenderer2, errorRenderer3).run();

    long startTime = ProcessingProfiler.getTimeStamp();

    ProcessingProfiler.getTimeDiff(startTime, "adding data to chart");

    startTime = ProcessingProfiler.getTimeStamp();
    root.setCenter(chart);
    ProcessingProfiler.getTimeDiff(startTime, "adding chart into StackPane");

    startTime = ProcessingProfiler.getTimeStamp();
    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.show();
    ProcessingProfiler.getTimeDiff(startTime, "for showing");
}
 
Example 8
Source File: Game2048.java    From util4j with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param primaryStage
 */
@Override
public void start(Stage primaryStage) {
    gameManager = new GameManager();
    gameBounds = gameManager.getLayoutBounds();

    StackPane root = new StackPane(gameManager);
    root.getStyleClass().addAll("game-root");
    ChangeListener<Number> resize = (ov, v, v1) -> {
        double scale = Math.min((root.getWidth() - MARGIN) / gameBounds.getWidth(), (root.getHeight() - MARGIN) / gameBounds.getHeight());
        gameManager.setScale(scale);
        gameManager.setLayoutX((root.getWidth() - gameBounds.getWidth()) / 2d);
        gameManager.setLayoutY((root.getHeight() - gameBounds.getHeight()) / 2d);
    };
    root.widthProperty().addListener(resize);
    root.heightProperty().addListener(resize);

    Scene scene = new Scene(root);
    scene.getStylesheets().add(CSS);
    addKeyHandler(scene);
    addSwipeHandlers(scene);

    if (isARMDevice()) {
        primaryStage.setFullScreen(true);
        primaryStage.setFullScreenExitHint("");
    }

    if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
        scene.setCursor(Cursor.NONE);
    }

    Rectangle2D 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);
    primaryStage.setHeight((gameBounds.getHeight() + MARGIN) * factor);
    primaryStage.show();
}
 
Example 9
Source File: HelloIoTApp.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
public HelloIoTApp(BridgeConfig[] bridgeconfigs, VarProperties config) throws HelloIoTException {

        // Load resources
        resources = ResourceBundle.getBundle("com/adr/helloiot/fxml/main");

        // System and Application devices units
        addSystemDevicesUnits(config.get("app.topicsys").asString());
        addAppDevicesUnits(config.get("app.topicapp").asString());

        ManagerComposed manager = new ManagerComposed();
        
        for (BridgeConfig bc : bridgeconfigs) {
            manager.addManagerProtocol(bc, config);
        }
        
        // TODO: Modelize adding units by manager. Now hardcoded for MQTT
        if (HTTPUtils.getAddress(config.get("mqtt.host").asString()) != null) {           
            // Broker panel
            if ("1".equals(config.get("mqtt.broker").asString())) {
                UnitPage info = new UnitPage("info", IconBuilder.create(IconFontGlyph.FA_SOLID_INFO, 24.0).styleClass("icon-fill").build(), resources.getString("page.info"));
                addUnitPages(Arrays.asList(info));
                addFXMLFileDevicesUnits("local:com/adr/helloiot/panes/mosquitto");
            }          
        }

        styleConnection = config.get("app.retryconnection").asBoolean() ? this::tryConnection : this::oneConnection;

        mainnode = new MainNode(
                this,
                Platform.isSupported(ConditionalFeature.MEDIA) ? new StandardClipFactory() : new SilentClipFactory(),
                config.get("app.exitbutton").asBoolean());

        topicsmanager = new ApplicationTopicsManager(manager);
        topicsmanager.setOnConnectionLost(t -> {
            LOGGER.log(Level.WARNING, "Connection lost to broker.", t);
            Platform.runLater(() -> {
                mainnode.stop();
                CompletableAsync.handle(topicsmanager.close(), 
                    v -> {
                        ultraConnection(3, Duration.seconds(2.5));
                    },
                    ex -> {
                        showConnectionException(t);
                    });
            });
        });
    }