Search in sources :

Example 1 with Configuration

use of kutch.biff.marvin.configuration.Configuration in project Board-Instrumentation-Framework by intel.

the class Marvin method testAppSize.

/*
    private void LoadApplication(Stage stage)
    {
        stage.setIconified(true);
        _Config = new ConfigurationReader();
        if (null == _Config)
        {
            return;
        }

        Configuration config = _Config.ReadStartupInfo(ConfigFilename);
        if (null == config)
        {
            return;
        }
        _objTabPane = new TabPane();
        _objTabPane.setSide(config.getSide());

        GridPane sceneGrid = new GridPane();

        GridPane.setHalignment(_Config.getConfiguration().getMenuBar(), HPos.LEFT);
        GridPane.setValignment(_Config.getConfiguration().getMenuBar(), VPos.TOP);

        sceneGrid.add(_Config.getConfiguration().getMenuBar(), 0, 0);
        sceneGrid.add(_objTabPane, 0, 1);

        Scene scene = null;
        Rectangle2D visualBounds = _Config.getConfiguration().getPrimaryScreen().getVisualBounds();
        int appWidth = (int) visualBounds.getWidth();
        int appHeight = (int) visualBounds.getHeight();

        if (config.getWidth() > 0)
        {
            appWidth = config.getWidth();
        }
        else
        {
            config.setWidth(appWidth);
        }
        if (config.getHeight() > 0)
        {
            appHeight = config.getHeight();
        }
        else
        {
            config.setHeight(appHeight);
        }

        scene = new Scene(sceneGrid);
        SetAppStyle(scene.getStylesheets());
        stage.setScene(scene);
        stage.setIconified(true);

        stage.setX(_Config.getConfiguration().getPrimaryScreen().getVisualBounds().getMinX());
        stage.setY(_Config.getConfiguration().getPrimaryScreen().getVisualBounds().getMinY());

        stage.setMaximized(true);

        stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>()
                      {
                          @Override
                          public void handle(WindowEvent window)
                          {
                              FinishLoad(stage);
                          }
                      });

        while (false && !_SizeCheckWindowShowing)
        {
            try
            {
                Thread.sleep(100);
            }
            catch (InterruptedException ex)
            {
                Logger.getLogger(Marvin.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        FinishLoad(stage);

    }
     */
// / pop up quick simple tab,menu and style it, then grab the size of the window
// / so we know the canvas dimenstions
private void testAppSize(Stage stage) {
    final GridPane stagePane = new GridPane();
    final GridPane canvasPane = new GridPane();
    canvasPane.setAlignment(Pos.TOP_LEFT);
    _Config = new ConfigurationReader();
    final Configuration basicConfig = _Config.ReadStartupInfo(ConfigFilename);
    stage.setX(basicConfig.getPrimaryScreen().getVisualBounds().getMinX());
    stage.setY(basicConfig.getPrimaryScreen().getVisualBounds().getMinY());
    TabPane tabPane = new TabPane();
    Tab objTab = new Tab();
    final Side tabSide = basicConfig.getSide();
    if (tabSide == Side.TOP || tabSide == Side.BOTTOM) {
        tabPane.setSide(Side.TOP);
    } else {
        tabPane.setSide(Side.LEFT);
    }
    objTab.setText("");
    tabPane.getTabs().add(objTab);
    stagePane.add(tabPane, 0, 1);
    MenuBar objMenuBar = new MenuBar();
    if (basicConfig.getShowMenuBar()) {
        Menu objMenu = new Menu("About");
        MenuItem objItem = new MenuItem("Dummy");
        objMenu.getItems().add(objItem);
        objMenuBar.getMenus().add(objMenu);
        stagePane.add(objMenuBar, 0, 0);
    }
    if (basicConfig.getEnableScrollBars()) {
        ScrollPane testScrollPane = new ScrollPane();
        testScrollPane.setPannable(true);
        testScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
        testScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
        testScrollPane.setContent(canvasPane);
        objTab.setContent(testScrollPane);
    } else {
        objTab.setContent(canvasPane);
    }
    stage.setTitle(basicConfig.getAppTitle());
    Scene scene = new Scene(stagePane);
    stage.setScene(scene);
    SetAppStyle(scene.getStylesheets());
    stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() {

        @Override
        public void handle(WindowEvent window) {
            scene.heightProperty().addListener(new ChangeListener<Number>() {

                @Override
                public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneHeight, Number newSceneHeight) {
                    scene.heightProperty().removeListener(this);
                    Point2D canvasInScene = canvasPane.localToScene(0.0, 0.0);
                    int cvHeight;
                    int cvWidth;
                    if (tabSide == Side.TOP || tabSide == Side.BOTTOM) {
                        cvHeight = (int) (scene.getHeight() - canvasInScene.getY());
                        cvWidth = (int) scene.getWidth();
                    } else {
                        cvHeight = (int) (scene.getHeight() - canvasInScene.getY());
                        cvWidth = (int) (scene.getWidth() - canvasInScene.getX());
                    }
                    basicConfig.setCanvasWidth(cvWidth);
                    basicConfig.setCanvasHeight(cvHeight);
                    stage.setIconified(true);
                    Platform.runLater(new Runnable() {

                        @Override
                        public void run() {
                            FinishLoad(stage);
                        }
                    });
                }
            });
        }
    });
    stage.show();
    if (basicConfig.getWidth() > 0) {
        stage.setWidth(basicConfig.getWidth());
        stage.setHeight(basicConfig.getHeight());
    } else {
        stage.setMaximized(true);
    }
}
Also used : TabPane(javafx.scene.control.TabPane) GridPane(javafx.scene.layout.GridPane) Configuration(kutch.biff.marvin.configuration.Configuration) ObservableValue(javafx.beans.value.ObservableValue) MenuBar(javafx.scene.control.MenuBar) MenuItem(javafx.scene.control.MenuItem) Scene(javafx.scene.Scene) Side(javafx.geometry.Side) Tab(javafx.scene.control.Tab) Point2D(javafx.geometry.Point2D) ScrollPane(javafx.scene.control.ScrollPane) WindowEvent(javafx.stage.WindowEvent) ChangeListener(javafx.beans.value.ChangeListener) Menu(javafx.scene.control.Menu) ConfigurationReader(kutch.biff.marvin.configuration.ConfigurationReader)

Example 2 with Configuration

use of kutch.biff.marvin.configuration.Configuration in project Board-Instrumentation-Framework by intel.

the class AliasMgr method addMarvinInfo.

public void addMarvinInfo() {
    try {
        String current = new java.io.File(".").getCanonicalPath();
        AddRootAlias("WORKING_DIR", current);
        String path = new File(".").toURI().toString();
        AddRootAlias("WORKING_DIR_URI", path);
    } catch (IOException ex) {
    }
    Configuration CONFIG = Configuration.getConfig();
    Rectangle2D visualBounds = CONFIG.getPrimaryScreen().getVisualBounds();
    double Width = CONFIG.getWidth();
    double Height = CONFIG.getHeight();
    // use configured dimensions, otherwise use screen;
    if (Width == 0.0) {
        Width = visualBounds.getWidth();
    }
    if (Height == 0.0) {
        Height = visualBounds.getHeight();
    }
    // Width = Width - CONFIG.getAppBorderWidth() * 2;
    // Height = Height - CONFIG.getBottomOffset() - CONFIG.getTopOffset();
    double H2W_Ratio = Width / Height;
    double W2H_Ratio = Height / Width;
    H2W_Ratio = visualBounds.getWidth() / visualBounds.getHeight();
    W2H_Ratio = visualBounds.getHeight() / visualBounds.getWidth();
    AddRootAlias("CANVAS_WIDTH", Integer.toString(Configuration.getConfig().getCanvasWidth()));
    AddRootAlias("CANVAS_HEIGHT", Integer.toString(Configuration.getConfig().getCanvasHeight()));
    AddRootAlias("SCREEN_H2W_RATIO", Double.toString(H2W_Ratio));
    AddRootAlias("SCREEN_W2H_RATIO", Double.toString(W2H_Ratio));
}
Also used : Configuration(kutch.biff.marvin.configuration.Configuration) Rectangle2D(javafx.geometry.Rectangle2D) IOException(java.io.IOException) OpenXMLFile(kutch.biff.marvin.configuration.ConfigurationReader.OpenXMLFile) File(java.io.File) File(java.io.File)

Aggregations

Configuration (kutch.biff.marvin.configuration.Configuration)2 File (java.io.File)1 IOException (java.io.IOException)1 ChangeListener (javafx.beans.value.ChangeListener)1 ObservableValue (javafx.beans.value.ObservableValue)1 Point2D (javafx.geometry.Point2D)1 Rectangle2D (javafx.geometry.Rectangle2D)1 Side (javafx.geometry.Side)1 Scene (javafx.scene.Scene)1 Menu (javafx.scene.control.Menu)1 MenuBar (javafx.scene.control.MenuBar)1 MenuItem (javafx.scene.control.MenuItem)1 ScrollPane (javafx.scene.control.ScrollPane)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 GridPane (javafx.scene.layout.GridPane)1 WindowEvent (javafx.stage.WindowEvent)1 ConfigurationReader (kutch.biff.marvin.configuration.ConfigurationReader)1 OpenXMLFile (kutch.biff.marvin.configuration.ConfigurationReader.OpenXMLFile)1