/** * * @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(); }
public Scene3D(Parent parent, double width, double height) { // super(new Group(parent), width, height, true); // see http://javafx-jira.kenai.com/browse/RT-22696 super(new Group(parent), width, height); if (true == Platform.isSupported(ConditionalFeature.SCENE3D)) { setCamera(new PerspectiveCamera()); Translate centerTranslate = new Translate(); centerTranslate.xProperty().bind(widthProperty().divide(2)); centerTranslate.yProperty().bind(heightProperty().divide(2)); getRoot().getTransforms().addAll(centerTranslate, translateZ, rotateX, rotateY, translateY); // getRoot().setDepthTest(DepthTest.ENABLE);// see http://javafx-jira.kenai.com/browse/RT-22696 } }
public Parent createDraggingGlobe() { boolean support = Platform.isSupported(ConditionalFeature.SCENE3D); if (support) logger.info("JavaFX 3D features supported"); else logger.info("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); }
@Override public void init() throws Exception { appInstance = this; VERSION = getVersion(); // Lets install/update the overlays if newer version AppSetup.install(VERSION); log = LogManager.getLogger(TokenTool.class); log.info("3D Hardware Available? " + Platform.isSupported(ConditionalFeature.SCENE3D)); // Now lets cache any overlays we find and update preLoader with progress overlayCount = (int) Files.walk(AppConstants.OVERLAY_DIR.toPath()).filter(Files::isRegularFile).count(); overlayTreeItems = cacheOverlays(AppConstants.OVERLAY_DIR, null, THUMB_SIZE); // All Done! notifyPreloader(new Preloader.ProgressNotification(1.0)); }
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); } }
@Test public void mouseEventDeliveryTest() { if(Platform.isSupported(ConditionalFeature.SCENE3D)) { final Object referenceColor = getCenterColor(referenceGreen); iterate(new TestCore() { @Override protected void catchError() { Object detectedColor = getCenterColor(indicator); if(!(JemmyUtils.usingGlassRobot() ? Arrays.equals((double[]) detectedColor, (double[]) referenceColor) : ((Integer) detectedColor).intValue() == ((Integer) referenceColor).intValue())) { StringBuilder builder = new StringBuilder(); builder.append("Wrong node reached with following configuration:\nFirst node: "). append(firstNodeCombo.getControl().getValue()).append("\nSecond node: "). append(secondNodeCombo.getControl().getValue()). append("\nFirst node DepthTest: ").append(firstDTest.getControl().getValue()). append("\nSecond node DepthTest: ").append(secondDTest.getControl().getValue()). append("\nParent node DepthTest: ").append(parentDTest.getControl().getValue()). append("\nWith ").append(firstToFront.getControl().isSelected() ? "first" : "second"). append(" node infront\n"); System.err.println(builder.toString()); setPassed(false); } } }); } }
public HelloIoTApp(ApplicationConfig config) { this.config = config; // Load resources resources = ResourceBundle.getBundle("com/adr/helloiot/fxml/main"); // System devices units addSystemDevicesUnits(config.mqtt_topicapp); // MQTT Manager mqttmanager = new MQTTManager( config.mqtt_url, config.mqtt_username, config.mqtt_password, config.mqtt_clientid, config.mqtt_connectiontimeout, config.mqtt_keepaliveinterval, config.mqtt_defaultqos, config.mqtt_version, config.mqtt_cleansession, null, config.mqtt_topicprefix); mqttmanager.setOnConnectionLost(t -> { LOGGER.log(Level.WARNING, "Connection lost to broker.", t); Platform.runLater(() -> { stopUnits(); connection(); }); }); styleConnection = config.app_retryconnection ? this::tryConnection : this::oneConnection; mqttnode = new MQTTMainNode( this, Platform.isSupported(ConditionalFeature.MEDIA) ? new StandardClipFactory() : new SilentClipFactory(), config.app_clock, config.app_exitbutton); }
public Parent createFixedGlobe() { boolean support = Platform.isSupported(ConditionalFeature.SCENE3D); if (support) logger.info("JavaFX 3D features supported"); else logger.info("JavaFX 3D features NOT supported"); globe = new Globe(); rotateGlobe(); //return new Group(globe.getRoot()); return new HBox(globe.getRoot()); }
/** * open url(non-blank) using JavaFx web engine. */ public static void openInnerBrowser(String openUrl) { if (Strings.isBlank(openUrl)) return; if (Platform.isSupported(ConditionalFeature.WEB)) { try { new CookieCatcher(openUrl, openUrl); } catch (Exception e) { String errMsg = "open URL failed:" + openUrl; JOptionPane.showMessageDialog(null, errMsg + "\n" + e.getMessage()); log.error(errMsg, e); } } else { log.error("javaFx web not supported, url not opened: " + openUrl); } }
@Override public void start(Stage primaryStage) { root = new GamePane(); Scene scene = new Scene(root); scene.getStylesheets().add("game2048/game.css"); if (isARMDevice()) { primaryStage.setFullScreen(true); primaryStage.setFullScreenExitHint(""); } if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) { scene.setCursor(Cursor.NONE); } Bounds gameBounds = root.getGameManager().getLayoutBounds(); int MARGIN = GamePane.getMargin(); 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.setOnCloseRequest(t->{ t.consume(); root.getGameManager().quitGame(); }); primaryStage.show(); }
public StylesConfig(Theme theme) { requireNotNull(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"); } }
@Override public void init() throws Exception { super.init(); log.setLevel(Level.DEBUG); log.info("Log system initialized"); km = KernelManager.getManager(); nm = NetManager.getManager(); gm = GUIManager.getManager(); log.info("All moduels initialized"); if (Platform.isSupported(ConditionalFeature.EFFECT)) log.info("Check Effect support...Yes!"); else log.warn("Check Effect support...No!"); // The following check is only allowed on the event thread. I've commented it in the last commit // if (Platform.isSupported(ConditionalFeature.INPUT_METHOD)) // log.info("Check Input Method support...Yes!"); // else // log.warn("Check Input Method support...No!"); if (Platform.isSupported(ConditionalFeature.SCENE3D)) log.info("Check 3D Scene support...Yes!"); else { log.warn("Check 3D Scene support...No!"); log.warn("Turn down Effect-Level automatically..."); GUIManager.enableReflectionEffect = false; GUIManager.enableSmooth = false; } if (Platform.isSupported(ConditionalFeature.SHAPE_CLIP)) log.info("Check Shape Clip support...Yes!"); else log.warn("Check Shape Clip support...No!"); }
@Override public void start(Stage stage) { VBox vb = new VBox(); Scene scene = new Scene(vb); stage.setScene(scene); stage.setWidth(500); stage.setHeight(480); Pane p = new Pane(); p.setTranslateX(75); p.setTranslateY(75); final Text strOutput = new Text(); strOutput.setId("strOutput"); MyTextInput mti = new MyTextInput(); mti.setId("inputfield"); TextInputControl www = new TextField("bwbeb"); for (ConditionalFeature c : ConditionalFeature.values()) { System.out.println(c); } EventHandler<? super InputEvent> qqq = new EventHandler<InputEvent>() { public void handle(InputEvent e) { System.out.println("*"); //strOutput.setText("ok"); // let it be here for debug } }; EventHandler<? super InputMethodEvent> qqq2 = new EventHandler<InputMethodEvent>() { public void handle(InputMethodEvent t) { strOutput.setText("ok"); // TODO: test all these getters listed below. // "setOnInputMethodTextChanged" does not work now (see http://javafx-jira.kenai.com/browse/RT-12915), // and exact values returned by getters are not documented in details, so, // this test should be improved and expanded after RT-12915 fix. int caretPosition = t.getCaretPosition(); String committedString = t.getCommitted(); String strRepresentation = t.toString(); ObservableList<InputMethodTextRun> lstRun =t.getComposed(); for (InputMethodTextRun run: lstRun) { String runText = run.getText(); String runString = run.toString(); InputMethodHighlight imh = run.getHighlight(); InputMethodHighlight imh1 = InputMethodHighlight.SELECTED_RAW; InputMethodHighlight imh2 = InputMethodHighlight.valueOf("SELECTED_RAW"); } } }; mti.setOnInputMethodTextChanged(qqq2); mti.setOnKeyTyped(qqq); www.setOnInputMethodTextChanged(qqq2); www.setOnKeyTyped(qqq); vb.getChildren().add(mti); vb.getChildren().add(www); vb.getChildren().add(strOutput); stage.show(); }
@Override protected Scene getScene() { root = new Pane(); scene = new Scene(root, 320, 200, Color.WHITE); HBox hbox = new HBox(); rectGreen = new Rectangle(50, 50, 100, 100); rectGreen.setFill(Color.GREEN); rectGreen.setId("RectGreen"); root.getChildren().add(rectGreen); AbstractButton btnShowPopup = ButtonBuilderFactory.newButtonBuilder() .text("Show Popup") .id("BtnShowPopup") .setOnClickHandler( new OnClickHandler() { @Override public void onClick() { Popup popup = new Popup(); popup.setWidth(stage.getWidth()); popup.setHeight(stage.getHeight()); popup.setOpacity(0.5); Pane rootPopup = new Pane(); Rectangle rectBg = new Rectangle(0, 0, rectGreen.getWidth() + smallRectSize * 2, rectGreen.getHeight() + smallRectSize * 2); rectBg.setId("RectPopupBg"); rectBg.setFill(Color.BLUE); rectBg.setOpacity(0.5); rootPopup.getChildren().add(rectBg); rootPopup.getChildren().add(new Rectangle(0, 0, smallRectSize, smallRectSize)); rootPopup.getChildren().add(new Rectangle(rectBg.getWidth() - smallRectSize, rectBg.getHeight() - smallRectSize, smallRectSize, smallRectSize)); rootPopup.getChildren().add(new Rectangle(0, rectBg.getHeight() - smallRectSize, smallRectSize, smallRectSize)); rootPopup.getChildren().add(new Rectangle(rectBg.getWidth() - smallRectSize, 0, smallRectSize, smallRectSize)); popup.getContent().add(rootPopup); popup.show(stage, stage.getX() + scene.getX() + rectGreen.getX() - smallRectSize, stage.getY() + scene.getY() + rectGreen.getY() - smallRectSize); } } ).build(); AbstractCheckBox chIsSupportedTransparentWindow = CheckBoxBuilderFactory.newCheckboxBuilder() .text("Platform.isSupported(ConditionalFeature.TRANSPARENT_WINDOW)") .id("TRANSPARENT_WINDOW") .setChecked(Platform.isSupported(ConditionalFeature.TRANSPARENT_WINDOW)) .build(); hbox.getChildren().addAll(btnShowPopup.node(), chIsSupportedTransparentWindow.node()); root.getChildren().add(hbox); Utils.addBrowser(scene); return scene; }
@BeforeClass public static void runUI() { is3DCapablePlatform = Platform.isSupported(ConditionalFeature.SCENE3D); Layout3DApp.main(null); }
@BeforeClass public static void runUI() { is3DCapablePlatform = Platform.isSupported(ConditionalFeature.SCENE3D); Effects3DApp.main(null); }
@Test public void renderingTest() { if(Platform.isSupported(ConditionalFeature.SCENE3D)) { iterate(new TestCore() { @Override protected void catchError() { Object color = isOnTop(firstNode) ? getCenterColor(referenceGreen) : getCenterColor(referenceRed); Point point = getCheckpoint(); Object detectedColor = getColor(getScene(), point.getX(), point.getY()); if(!(JemmyUtils.usingGlassRobot() ? Arrays.equals((double[]) detectedColor, (double[]) color) : ((Integer) detectedColor).intValue() == ((Integer) color).intValue())) { StringBuilder builder = new StringBuilder(); builder.append("Wrong color detected on nodes intesection area with following configuration:\nFirst node: "). append(firstNodeCombo.getControl().getValue()).append("\nSecond node: "). append(secondNodeCombo.getControl().getValue()). append("\nFirst node DepthTest: ").append(firstDTest.getControl().getValue()). append("\nSecond node DepthTest: ").append(secondDTest.getControl().getValue()). append("\nParent node DepthTest: ").append(parentDTest.getControl().getValue()). append("\nWith ").append(firstToFront.getControl().isSelected() ? "first" : "second"). append(" node infront\n"); System.err.println(builder.toString()); setPassed(false); } } public boolean isOnTop(Wrap<? extends Node> node) { boolean meets = false; boolean onTop = node.equals(secondNode); boolean firstDTEnable = isDepthTestEnable(firstDTest); boolean secondDTEnable = isDepthTestEnable(secondDTest); boolean inFront = onTop ? secondToFront.getState() : firstToFront.getState(); if((!firstDTEnable || !secondDTEnable) && onTop) meets = true; if(firstDTEnable && secondDTEnable && inFront) meets = true; return meets; } private boolean isDepthTestEnable(ComboBoxWrap<? extends ComboBox> cb) { boolean enable = cb.getControl().getValue().equals(DepthTest.ENABLE) || (cb.getControl().getValue().equals(DepthTest.INHERIT) && parentDTest.getControl().getValue().equals(DepthTest.ENABLE)); return enable; } }); } }
static boolean isSupported() { return Platform.isSupported(ConditionalFeature.GRAPHICS) && Platform.isSupported(ConditionalFeature.CONTROLS); }
public static void main(String[] args) { System.out.println("3D supported? " + Platform.isSupported(ConditionalFeature.SCENE3D)); launch(args); }
/** * Constructs a new JavaFxJUnit4ClassRunner with the given parameters. * * @param clazz * The class that is to be run with this Runner * @throws InitializationError * Thrown by the BlockJUnit4ClassRunner in the super() */ public JfxRunner(final Class<?> clazz) throws InitializationError { super(clazz); if (Platform.isSupported(ConditionalFeature.GRAPHICS)) { TestJfxApplication.startJavaFx(); } }