Java Code Examples for com.sun.javafx.application.PlatformImpl#startup()
The following examples show how to use
com.sun.javafx.application.PlatformImpl#startup() .
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: MainWindow.java From Recaf with MIT License | 6 votes |
/** * @param controller * Window context. * * @return main window instance. */ public static MainWindow get(GuiController controller) { if(window == null) { MainWindow app = window = new MainWindow(controller); PlatformImpl.startup(() -> { Stage stage = new Stage(); try { Field field = Stage.class.getDeclaredField("primary"); field.setAccessible(true); field.setBoolean(stage, true); app.init(); app.start(stage); } catch (Exception ex) { throw new RuntimeException(ex); } // Disable CSS logger, it complains a lot about non-issues try { ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class) .setLoggerLevel("javafx.css", "OFF"); } catch (IllegalArgumentException ignored) { // Expected: logger may not exist } }); } return window; }
Example 2
Source File: CreateDataset.java From paintera with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IOException, ReflectionException { PlatformImpl.startup(() -> { }); final AffineTransform3D tf = new AffineTransform3D(); tf.set( 4.0, 0.0, 0.0, 1.0, 0.0, 5.0, 0.0, 5.0, 0.0, 0.0, 40., -1. ); final N5Reader reader = new N5FSReader( "/home/phil/local/tmp/sample_a_padded_20160501.n5"); final DataSource<UnsignedByteType, VolatileUnsignedByteType> raw = N5Data.openRawAsSource( reader, "volumes/raw/data/s0", tf, new SharedQueue(1, 20), 1, "NAME" ); final CreateDataset cd = new CreateDataset(raw); Platform.runLater(() -> { final Button b = new Button("BUTTON"); b.setOnAction(e -> LOG.info( "Got new dataset meta: {}", cd.showDialog())); final Scene scene = new Scene(b); final Stage stage = new Stage(); stage.setScene(scene); stage.show(); }); }
Example 3
Source File: MatchSelectionExample.java From paintera with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IOException { final List<String> filenames = Files.list(Paths.get(System.getProperty("user.home"))).map(Path::toAbsolutePath).map(Path::toString).collect(Collectors.toList()); Collections.sort(filenames); PlatformImpl.startup(() -> {}); Platform.setImplicitExit(true); Platform.runLater(() -> { final MenuButton button = new MenuButton("Select!"); final DirectoryChooser chooser = new DirectoryChooser(); final MenuItem chooserButton = new MenuItem("Browse"); chooserButton.setOnAction(e -> chooser.showDialog(null)); button.getItems().setAll( chooserButton, MatchSelectionExample.menu("Recent...", System.out::println, filenames), MatchSelectionExample.menu("Favorites...", System.out::println, filenames)); final Stage stage = new Stage(); final Scene scene = new Scene(button); stage.setScene(scene); stage.addEventHandler(KeyEvent.KEY_PRESSED, e -> { if (KeyCode.ESCAPE.equals(e.getCode())) { if (!e.isConsumed()) stage.close(); e.consume(); } }); stage.show(); }); }
Example 4
Source File: CatmaidJsonLoader.java From paintera with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws IOException { PlatformImpl.startup(() -> {}); final Path path = Paths.get(System.getProperty("user.home"), "Downloads", "catmaid-meshes", "Block3.json"); final TriangleMesh mesh = new CatmaidJsonLoader().loadMesh(path); final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY}; final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY}; for (int i = 0; i < mesh.getPoints().size(); i += 3) { for (int d = 0; d < 3; ++d) { min[d] = Math.min(min[d], mesh.getPoints().get(i + d)); max[d] = Math.max(max[d], mesh.getPoints().get(i + d)); } } System.out.print(Arrays.toString(min) +" " + Arrays.toString(max)); final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max)); final MeshView mv = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE)); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); final Viewer3DFX viewer = new Viewer3DFX(800, 600); viewer.meshesEnabledProperty().set(true); mv.setOpacity(1.0); viewer.setInitialTransformToInterval(interval); final MeshView mv2 = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial()); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); mv2.setTranslateX(100); viewer.meshesGroup().getChildren().addAll(mv, mv2); Platform.setImplicitExit(true); Platform.runLater(() -> { final Scene scene = new Scene(viewer); final Stage stage = new Stage(); stage.setScene(scene); stage.setWidth(800); stage.setHeight(600); stage.show(); }); // final String mesh = "<IndexedTriangleSet index='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35'><Coordinate point='440474 99212 136120 440474 119212 136120 460474 99212 136120 460474 99212 136120 440474 119212 136120 460474 119212 136120 440474 99212 136120 460474 99212 136120 460474 99212 156120 440474 99212 136120 460474 99212 156120 440474 99212 156120 440474 119212 136120 440474 119212 156120 460474 119212 156120 440474 119212 136120 460474 119212 156120 460474 119212 136120 440474 99212 156120 460474 119212 156120 440474 119212 156120 440474 99212 156120 460474 99212 156120 460474 119212 156120 440474 99212 136120 440474 119212 156120 440474 119212 136120 440474 99212 136120 440474 99212 156120 440474 119212 156120 460474 99212 136120 460474 119212 136120 460474 99212 156120 460474 119212 136120 460474 119212 156120 460474 99212 156120'/></IndexedTriangleSet>"; // final Document doc = Jsoup.parse(mesh); // System.out.println(doc); // System.out.println(doc.select("IndexedTriangleSet").attr("index")); }
Example 5
Source File: ObjLoader.java From paintera with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws IOException { PlatformImpl.startup(() -> {}); // https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html // final String objFile = "al.obj"; // final String objFile = "diamond.obj"; final String objFile = "alfa147.obj"; final Path path = Paths.get(System.getProperty("user.home"), "Downloads", objFile); final TriangleMesh mesh = new ObjLoader().loadMesh(path); final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY}; final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY}; for (int i = 0; i < mesh.getPoints().size(); i += 3) { for (int d = 0; d < 3; ++d) { min[d] = Math.min(min[d], mesh.getPoints().get(i + d)); max[d] = Math.max(max[d], mesh.getPoints().get(i + d)); } } final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max)); final MeshView mv = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE)); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); final Viewer3DFX viewer = new Viewer3DFX(800, 600); viewer.meshesEnabledProperty().set(true); mv.setOpacity(1.0); viewer.setInitialTransformToInterval(interval); final MeshView mv2 = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial()); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); mv2.setTranslateX(100); viewer.meshesGroup().getChildren().addAll(mv, mv2); // final double factor = 1; // final double w = 1*factor, h = 2*factor, d = 3*factor; // final Box box = new Box(w, h, d); // box.setCullFace(CullFace.NONE); // box.setOpacity(1.0); // box.setMaterial(Meshes.painteraPhongMaterial(Color.RED)); // viewer.meshesGroup().getChildren().add(box); Platform.setImplicitExit(true); Platform.runLater(() -> { final Scene scene = new Scene(viewer); final Stage stage = new Stage(); stage.setScene(scene); stage.setWidth(800); stage.setHeight(600); stage.show(); }); }
Example 6
Source File: JavaFXCompatibilityWrapper.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Start the JavaFX runtime and run runnable on the JavaFX * Application thread. * <p> * On Java 9, PlatformImpl is no longer available, so we have to use * the new Platform.startup() function instead. */ static void platformStartup(Runnable runnable) { PlatformImpl.startup(runnable); }
Example 7
Source File: MdSlideManager.java From opencards with BSD 2-Clause "Simplified" License | 2 votes |
private void createScene() { PlatformImpl.startup(() -> { Browser browser = new Browser(); Scene scene = new Scene(browser, 80, 20); // scene.getStylesheets().add("equal_sizes.css"); Stage stage = new Stage(); stage.setTitle("Hello Java FX"); stage.setResizable(true); stage.setScene(scene); webEngine = browser.webEngine; // Set up the embedded browser: // webEngine = browser.webEngine; // webEngine.load("http://heise.de"); // https://stackoverflow.com/questions/38432698/webview-size-in-javafx-stage browser.prefHeightProperty().bind(stage.heightProperty()); browser.prefWidthProperty().bind(stage.widthProperty()); // ScrollPane scrollPane = new ScrollPane(); // scrollPane.setContent(browser); webEngine.loadContent("<b>asdf</b>"); // webEngine.setUserStyleSheetLocation("equal_sizes.css"); // root.getChildren().addAll(scrollPane); // scene.setRoot(root); // stage.setScene(scene); // root.getChildren().add(browser); // children.add(browser); jfxPanel.setScene(scene); }); while (webEngine == null) { Utils.sleep(25); } }