package radicalzephyr;

import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.List;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.scene.web.WebEngine;
import javafx.stage.Stage;

public class WebFX extends Application {
    private String domain;
    private String port;
    private int width;
    private int height;

    private int getIntArgOrDefault(Map<String, String> args, String argName, int defaultValue) {
        try {
            return Integer.parseInt(args.getOrDefault(argName, ""));
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }

    @Override
    public void init() throws Exception {
        Map<String, String> args = getParameters().getNamed();

        this.domain = args.getOrDefault("domain", "localhost");
        this.port   = args.getOrDefault("port", "3000");

        this.width  = getIntArgOrDefault(args, "width", 1024);
        this.height = getIntArgOrDefault(args, "height", 768);
    }

    @Override
    public void start(Stage primaryStage) {
        WebView browser = new WebView();
        WebEngine engine = browser.getEngine();

        String domain = "localhost";
        String port = "9393";

        engine.load("http://" + domain + ":" + port);

        int width = 1024;
        int height = 768;
        Scene s = new Scene(browser, width, height);

        primaryStage.setScene(s);
        primaryStage.show();
    }

    private static String[] constructArgVector(Map<String, Object> options) {
        List<String> args = new ArrayList<String>();

        for (Entry<String, Object> option: options.entrySet()) {
            String argName  = option.getKey();
            String argValue = option.getValue().toString();
            args.add(String.format("--%s=%s", argName, argValue));
        }

        return args.toArray(new String[0]);
    }

    public static void start(Map<String, Object> options) {
        String[] args = constructArgVector(options);
        launch(args);
    }

    public static void main(String[] args) {
        launch(args);
    }

}

@@ -1223,76 +1223,8 @@
 );%0A%0A
-        String domain = %22localhost%22;%0A        String port = %229393%22;%0A%0A
     
@@ -1251,16 +1251,21 @@
 p://%22 + 
+this.
 domain +
@@ -1275,16 +1275,21 @@
 %22 + 
+this.
 port);%0A%0A
     
@@ -1288,60 +1288,8 @@
 );%0A%0A
-        int width = 1024;%0A        int height = 768;%0A
     
@@ -1325,15 +1325,25 @@
 er, 
+this.
 width, 
+this.
 heig

Use values passed in configuration instead of dummy local variables