Java Code Examples for javafx.application.Application#Parameters

The following examples show how to use javafx.application.Application#Parameters . 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: LauncherParams.java    From fxlauncher with Apache License 2.0 6 votes vote down vote up
public LauncherParams(Application.Parameters delegate, FXManifest manifest) {
    // Add all raw args from the parent application
    rawArgs.addAll(delegate.getRaw());

    // Add parameters from the manifest unless they were already specified on the command line
    if (manifest.parameters != null) {
        for (String arg : manifest.parameters.split("\\s")) {
            if (arg != null) {
                if (rawArgs.contains(arg))
                    continue;

                if (arg.startsWith("--") && arg.contains("=")) {
                    String argname = arg.substring(0, arg.indexOf("="));
                    if (rawArgs.stream().filter(a -> a.startsWith(argname)).findAny().isPresent())
                        continue;
                }

                rawArgs.add(arg);
            }
        }
    }

    computeParams();
}
 
Example 2
Source File: FoxEatsDemo.java    From htm.java-examples with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Application.Parameters params = getParameters();
    List<String> paramList = params.getUnnamed();

    // Check for the existence of a proper API Key
    if(paramList.size() < 1 || !paramList.get(0).startsWith("-K")) {
        throw new IllegalStateException("Demo must be started with arguments [-K]<your-api-key>");
    }

    FoxEatsDemoView view = new FoxEatsDemoView(this, params);
    Scene scene = new Scene(view, 900, 600, Color.WHITE);
    stage.setScene(scene);
    stage.show();

    Rectangle2D primScreenBounds = Screen.getPrimary(). getVisualBounds();
    stage.setX(( primScreenBounds.getWidth() - stage.getWidth()) / 2);
    stage.setY(( primScreenBounds.getHeight() - stage.getHeight()) / 4);

}
 
Example 3
Source File: BreakingNewsDemo.java    From htm.java-examples with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Application.Parameters params = getParameters();
    List<String> paramList = params.getUnnamed();

    // Check for the existence of a proper API Key
    if(paramList.size() < 1 || !paramList.get(0).startsWith("-K")) {
        throw new IllegalStateException("Demo must be started with arguments [-K]<your-api-key>");
    }

    this.apiKey = paramList.get(0).substring(2);

    configureView();

    showView(stage);
}
 
Example 4
Source File: UserPrefs.java    From archivo with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Parse command-line arguments into user preferences.
 *
 * @param parameters The Application parameters
 * @return false if an unrecognized parameter was passed
 */
public boolean parseParameters(Application.Parameters parameters) {
    boolean allParsed = true;
    List<String> params = parameters.getUnnamed();
    for (int i = 0; i < params.size(); i++) {
        String param = params.get(i);
        if (param.equalsIgnoreCase("-tooldir")) {
            tooldir = params.get(++i);
            logger.info("Tools in '{}'", tooldir);
        } else {
            logger.error("Unrecognized parameter: {}", param);
            allParsed = false;
        }
    }
    return allParsed;
}
 
Example 5
Source File: MosaicPaneRefImpl.java    From Mosaic with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
	Application.Parameters params = getParameters();
	Map<String, String> map = params.getNamed();
	System.out.println("params = " + params);
	
	ModelLoader loader = new ModelLoader(map.get("file"));
	String[] model = loader.getModel(map.get("surface"));
	
	System.out.println("model.length = " + model.length);
	MosaicPane<Node> mosaicPane = new MosaicPane<Node>();
	
	int i = 0;
	for(String def : model) {
		String[] args = def.split("[\\s]*\\,[\\s]*");
		int offset = args.length > 4 ? args.length - 4 : 0;
		String id = args.length == 4 ? "" + (i++) : args[0];
		Label l = getLabel(i > 4 ? colors[random.nextInt(5)] : colors[i], id);
		mosaicPane.add(l, id, 
			Double.parseDouble(args[offset + 0]), 
			Double.parseDouble(args[offset + 1]),
			Double.parseDouble(args[offset + 2]),
			Double.parseDouble(args[offset + 3]));
		clientMap.put(id, l);
	}
	
       mosaicPane.getEngine().addSurface(mosaicPane.getSurface());
       
       Scene scene = new Scene(mosaicPane, 1600, 900);
    stage.setTitle("Mosaic Layout Engine Demo (JavaFX)");
	stage.setScene(scene);
	stage.show();
}
 
Example 6
Source File: MultiStageMain.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
 public void start(Stage primaryStage) throws Exception {

     if( logger.isInfoEnabled() ) {
         logger.info("Starting application");
     }

     Application.Parameters parameters = getParameters();

     //
     // Create initial screen; initialize subapps (found on classpath)
     //        
     FXMLLoader loader = new FXMLLoader();
     loader.setLocation( MultiStageMain.class.getResource("app_core/homeScreen.fxml") );
     Parent p = loader.load();

     HomeScreenController c = (HomeScreenController)loader.getController();

     if( parameters.getRaw().contains("bootstrap=true") ) {
         if( logger.isDebugEnabled() ) {
             logger.debug("[START] running in bootstrap mode");
         }
     } else {
     	
         if( logger.isDebugEnabled() ) {
             logger.debug("[START] running in full mode");
         }
         
         //
         // Build runtime classpath from .examples-javafx-dynamic/subapps
         // folder contents
         //
         buildURLClassLoader();

//
// Initializes home object w. args for Guice Module
//
c.initializeHome(subappJars, startupCommandsFullPath);

         //
         // Will additionally scan packages for modules to load with
         // Reflections library
         //
         c.initializeSubApps(urlClassLoader, urls);
     }

     //
     // Show main screen
     //        
     Scene scene = new Scene( p );
     primaryStage.setTitle( "Core" );
     primaryStage.setScene( scene );
     primaryStage.show();

 }
 
Example 7
Source File: FoxEatsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 4 votes vote down vote up
public FoxEatsDemoView(FoxEatsDemo demo, Application.Parameters params) {
    this.demo = demo;
    
    // Extract api key from arguments
    apiKey = params.getUnnamed().get(0).substring(2).trim();
    
    setBackground(new Background(new BackgroundFill(Color.WHITE, null, null)));
    
    // LeftMargin And RightMargin
    HBox h = new HBox();
    h.prefWidthProperty().bind(widthProperty().divide(20));
    h.setFillHeight(true);
    HBox h2 = new HBox();
    h2.prefWidthProperty().bind(widthProperty().divide(20));
    h2.setFillHeight(true);
    
    // StackPane: Center panel, z:0 CorticalLogoPane, z:1 VBox w/main content
    StackPane stack = new StackPane();
    stack.prefWidthProperty().bind(widthProperty().multiply(9.0/10.0));
    stack.prefHeightProperty().bind(heightProperty());
    
    //////////////////////////////
    //    Z:0 background logo   //
    //////////////////////////////
    CorticalLogoBackground backGround = new CorticalLogoBackground(stack);
    backGround.setOpacity(0.2);
    
    //////////////////////////////
    // Z:1 Main Content in VBox //
    //////////////////////////////
    VBox vBox = new VBox();
    vBox.setSpacing(20);
    vBox.prefWidthProperty().bind(stack.widthProperty());
    vBox.prefHeightProperty().bind(new SimpleDoubleProperty(100.0));
    
    LogoTitlePane header = new LogoTitlePane();
    header.setTitleText("What Does A Fox Eat?");
    header.setSubTitleText("an example of using Numenta's Hierarchical Temporal Memory with Cortical.io's Semantic Folding...");
    
    HBox buttonBar = createSegmentedButtonBar();
    
    LabelledRadiusPane inputPane = getDisplayPane();
    vBox.getChildren().addAll(header, buttonBar, inputPane);
    
    stack.getChildren().addAll(backGround, vBox);
    
    // Main Layout: 3 columns, 1 row
    add(h, 0, 0);
    add(stack, 1, 0);
    add(h2, 2, 0);
    
    Platform.runLater(() -> {
        Thread t = new Thread() {
            public void run() { try{ 
                Thread.sleep(100);}catch(Exception e) {}
                Platform.runLater(() -> {
                    getScene().getWindow().setWidth(getScene().getWindow().getWidth() + 10);
                    vBox.layoutBoundsProperty().addListener((v, o, n) -> {
                        inputPane.setPrefHeight(vBox.getLayoutBounds().getHeight() - inputPane.getLayoutY() - 50);
                    });                       
                });
            }
        };
        t.start();
    });
   
}
 
Example 8
Source File: TestController.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void setUI(UI ui, Application.Parameters params) {
    TestController.ui = ui;
    TestController.commandLineArgs = initialiseCommandLineArguments(params);
}
 
Example 9
Source File: TestController.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static HashMap<String, String> initialiseCommandLineArguments(Application.Parameters params) {
    return new HashMap<>(params.getNamed());
}
 
Example 10
Source File: AbstractLauncher.java    From fxlauncher with Apache License 2.0 votes vote down vote up
protected abstract Application.Parameters getParameters();