Java Code Examples for javafx.scene.layout.BorderPane#setCenter()

The following examples show how to use javafx.scene.layout.BorderPane#setCenter() . 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: HelpBox.java    From scenic-view with GNU General Public License v3.0 7 votes vote down vote up
public HelpBox(final String title, final String url, final double x, final double y) {
    final BorderPane pane = new BorderPane();
    pane.setId(StageController.FX_CONNECTOR_BASE_ID + "HelpBox");
    pane.setPrefWidth(SCENE_WIDTH);
    pane.setPrefHeight(SCENE_HEIGHT);
    final ProgressWebView wview = new ProgressWebView();
    wview.setPrefHeight(SCENE_HEIGHT);
    wview.setPrefWidth(SCENE_WIDTH);
    wview.doLoad(url);
    pane.setCenter(wview);
    final Scene scene = new Scene(pane, SCENE_WIDTH, SCENE_HEIGHT); 
    stage = new Stage();
    stage.setTitle(title);
    stage.setScene(scene);
    stage.getIcons().add(HELP_ICON);
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {

        @Override public void handle(final WindowEvent arg0) {
            DisplayUtils.showWebView(false);
        }
    });
    stage.show();
}
 
Example 2
Source File: RunUiSamples.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    final BorderPane root = new BorderPane();

    final FlowPane buttons = new FlowPane();
    buttons.setAlignment(Pos.CENTER_LEFT);
    root.setCenter(buttons);
    root.setBottom(makeScreenShot);

    buttons.getChildren().add(new MyButton("AcqButtonTests", new AcqButtonTests()));

    final Scene scene = new Scene(root);

    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(evt -> System.exit(0));
    primaryStage.show();
}
 
Example 3
Source File: EditAreaView.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node constructContent() {
    
    StackPane stackpaneroot = new StackPane();
    stackpaneroot.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    
    BorderPane borderpane = new BorderPane();
    
    statusview = new TextArea();
    statusview.setEditable(false);
    statusview.setFocusTraversable(false);
    statusview.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    statusview.setPrefHeight(100.0);
    statusview.getStyleClass().add("unitinputview");
    BorderPane.setAlignment(statusview, Pos.CENTER);
    
    borderpane.setCenter(statusview);
    
    stackpaneroot.getChildren().add(borderpane);
    
    initialize();
    return stackpaneroot;
}
 
Example 4
Source File: BooleanManagedMenuItem.java    From tcMenu with Apache License 2.0 6 votes vote down vote up
@Override
public Node createNodes(RemoteMenuController remoteControl) {
    //
    // For boolean items, we just create a buttons turn the item on or off when pressed
    //

    flipButton = new Button("--");
    flipButton.setDisable(item.isReadOnly());
    flipButton.setOnAction(event -> {
        MenuTree menuTree = remoteControl.getManagedMenu();
        MenuState<Boolean> state = menuTree.getMenuState(item);
        var val = (state != null && !state.getValue()) ? 1 : 0;
        waitingFor = Optional.of(remoteControl.sendAbsoluteUpdate(item, val));
    });

    // Now generate the label where we'll store everything
    itemLabel = new Label();

    // and put all the controls into a panel
    BorderPane borderPane = new BorderPane();
    borderPane.setCenter(itemLabel);
    borderPane.setRight(flipButton);
    return borderPane;
}
 
Example 5
Source File: Main.java    From java_fx_node_link_demo with The Unlicense 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	BorderPane root = new BorderPane();
	
	try {
		
		Scene scene = new Scene(root,640,480);
		scene.getStylesheets().add(getClass().getResource("/application.css").toExternalForm());
		primaryStage.setScene(scene);
		primaryStage.show();
		
	} catch(Exception e) {
		e.printStackTrace();
	}
	
	root.setCenter(new RootLayout());
}
 
Example 6
Source File: ConsoleLogStage.java    From dm3270 with Apache License 2.0 6 votes vote down vote up
public ConsoleLogStage (Screen screen)
{
  setTitle ("Console Logs");

  setOnCloseRequest (e -> closeWindow ());
  btnHide.setOnAction (e -> closeWindow ());

  BorderPane borderPane = new BorderPane ();
  borderPane.setTop (menuBar);
  borderPane.setCenter (tabPane);

  consoleTab.setClosable (false);

  menuBar.setUseSystemMenuBar (SYSTEM_MENUBAR);
  tabPane.getTabs ().addAll (consoleTab, consoleMessageTab);
  tabPane.setTabMinWidth (80);

  Scene scene = new Scene (borderPane, 800, 500);             // width/height
  setScene (scene);

  windowSaver = new WindowSaver (prefs, this, "DatasetStage");
  windowSaver.restoreWindow ();

  tabPane.getSelectionModel ().select (consoleTab);
}
 
Example 7
Source File: FileExplorerView.java    From Maus with GNU General Public License v3.0 5 votes vote down vote up
public BorderPane getFileExplorerView(String pathName, String[] files, Stage stage, ClientObject client) {
    setClient(client);
    BorderPane borderPane = new BorderPane();
    borderPane.getStylesheets().add(getClass().getResource("/css/global.css").toExternalForm());
    borderPane.setTop(new TopBar().getTopBarSansOptions(stage));
    borderPane.setCenter(getFileExplorerViewCenter(pathName, files));
    borderPane.setBottom(new BottomBar().getBottomBar());
    return borderPane;
}
 
Example 8
Source File: OrsonChartsFXDemo.java    From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
   
    TabPane tabPane = new TabPane();
    Tab tab1 = new Tab();
    tab1.setText("Demos");
    tab1.setClosable(false);
    
    SplitPane sp = new SplitPane();
    final StackPane sp1 = new StackPane();
    sp1.getChildren().add(createTreeView());
    final BorderPane sp2 = new BorderPane();
    sp2.setCenter(createChartPane());
 
    sp.getItems().addAll(sp1, sp2);
    sp.setDividerPositions(0.3f, 0.6f);
    tab1.setContent(sp);
    tabPane.getTabs().add(tab1);        
 
    Tab tab2 = new Tab();
    tab2.setText("About");
    tab2.setClosable(false);
    
    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    webEngine.load(getClass().getResource("/org/jfree/chart3d/fx/demo/about.html").toString());
    tab2.setContent(browser);
    tabPane.getTabs().add(tab2);        

    Scene scene = new Scene(tabPane, 1024, 768);
    stage.setScene(scene);
    stage.setTitle("Orson Charts JavaFX Demo");
    stage.show();
}
 
Example 9
Source File: DemoPane.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public DemoPane(String type)
	{
		super(type);
		
		CheckBox cb = new CheckBox("boolean property");
		LocalSettings.get(this).add("CHECKBOX", cb);
		
		TextField textField = new TextField();
		LocalSettings.get(this).add("TEXTFIELD", textField); 
		
//		VPane vb = new VPane();
//		a(vb, 2, 0.25, 0.25, HPane.FILL);
//		a(vb, 2, 30, 30, 100);
//		a(vb, 2, 0.2, 0.2, 0.6);
//		a(vb, 2, HPane.PREF, HPane.FILL, HPane.PREF);
//		a(vb, 2, HPane.FILL, HPane.FILL, HPane.FILL);
//		a(vb, 2, 20, HPane.FILL, 20);
//		a(vb, 2, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL);
//		a(vb, 2, 50, HPane.FILL, HPane.FILL, 50);
		
		HPane vb = new HPane(2);
		vb.add(cb);
		vb.add(textField);
			
		BorderPane bp = new BorderPane();
		bp.setCenter(createColorNode(type));
		bp.setBottom(vb);
		
		setCenter(bp);
		this.pseq = seq++;
		setTitle("pane " + pseq);
		
		// set up context menu off the title field
		FX.setPopupMenu(titleField, this::createTitleFieldPopupMenu);
	}
 
Example 10
Source File: Puzzle.java    From games_oop_javafx with Apache License 2.0 5 votes vote down vote up
private void refresh(final BorderPane border) {
    Group grid = this.buildGrid();
    this.logic.clean();
    border.setCenter(grid);
    this.generate(true, 6, grid);
    this.generate(false, 5, grid);
}
 
Example 11
Source File: Exercise_16_16.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Set combo box properties
	cbo.getItems().addAll("SINGLE", "MULTIPLE");
	cbo.setValue("SINGLE");

	// Create a label and set its content display
	Label lblSelectionMode = new Label("Choose Selection Mode:", cbo);
	lblSelectionMode.setContentDisplay(ContentDisplay.RIGHT);

	// Set defaut list view as single
	lv.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

	// Create and register the handlers
	cbo.setOnAction(e -> {
		setMode();
		setText();
	});

	lv.getSelectionModel().selectedItemProperty().addListener(
		ov -> {
		setMode();
		setText();
	});

	// Place nodes in the pane
	BorderPane pane = new BorderPane();
	pane.setTop(lblSelectionMode);
	pane.setCenter(new ScrollPane(lv));
	pane.setBottom(lblSelectedItems);
	pane.setAlignment(lblSelectionMode, Pos.CENTER);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 268, 196);
	primaryStage.setTitle("Exercise_16_16"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 12
Source File: Main.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked by JavaFX for starting the application.
 * This method is called on the JavaFX Application Thread.
 *
 * @param window  the primary stage onto which the application scene will be be set.
 */
@Override
public void start(final Stage window) {
    this.window = window;
    final Vocabulary vocabulary = Vocabulary.getResources((Locale) null);
    /*
     * Configure the menu bar. For most menu item, the action is to invoke a method
     * of the same name in this application class (e.g. open()).
     */
    final MenuBar menus = new MenuBar();
    final Menu file = new Menu(vocabulary.getString(Vocabulary.Keys.File));
    {
        final MenuItem open = new MenuItem(vocabulary.getMenuLabel(Vocabulary.Keys.Open));
        open.setAccelerator(KeyCombination.keyCombination("Shortcut+O"));
        open.setOnAction(e -> open());

        final MenuItem exit = new MenuItem(vocabulary.getString(Vocabulary.Keys.Exit));
        exit.setOnAction(e -> Platform.exit());
        file.getItems().addAll(open, new SeparatorMenuItem(), exit);
    }
    menus.getMenus().add(file);
    /*
     * Set the main content and show.
     */
    content = new ResourceView();
    final BorderPane pane = new BorderPane();
    pane.setTop(menus);
    pane.setCenter(content.pane);
    Scene scene = new Scene(pane);
    window.setTitle("Apache Spatial Information System");
    window.setScene(scene);
    window.setWidth(800);
    window.setHeight(650);
    window.show();
}
 
Example 13
Source File: HistoryPane.java    From Recaf with MIT License 5 votes vote down vote up
@Override
public void updateItem(History item, boolean empty) {
	super.updateItem(item, empty);
	if(!empty) {
		Node g = null;
		String text = item.name;
		// Create graphic based on history content
		// - (only way to differ between class/file)
		int count = item.size() - 1;
		byte[] data = item.peek();
		if (ClassUtil.isClass(data)) {
			g = UiUtil.createClassGraphic(ClassUtil.getAccess(data));
		} else {
			g = UiUtil.createFileGraphic(text);
		}
		getStyleClass().add("hist-cell");
		BorderPane wrap = new BorderPane();
		String sub = count > 0 ? "[" + count + " states]" : "[Initial state]";
		wrap.setLeft(g);
		wrap.setLeft(new BorderPane(wrap.getLeft()));
		wrap.getLeft().getStyleClass().add("hist-icon");
		wrap.setCenter(new SubLabeled(text, sub, "bold"));
		setGraphic(wrap);
	} else {
		setGraphic(null);
		setText(null);
	}
}
 
Example 14
Source File: FeatureOverviewWindow.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public FeatureOverviewWindow(PeakListRow row) {

    mainPane = new BorderPane();
    mainScene = new Scene(mainPane);

    // Use main CSS
    mainScene.getStylesheets()
        .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets());
    setScene(mainScene);

    this.feature = row.getBestPeak();
    rawFiles = row.getRawDataFiles();

    // setBackground(Color.white);
    // setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    SplitPane splitPaneCenter = new SplitPane();
    splitPaneCenter.setOrientation(Orientation.HORIZONTAL);
    mainPane.setCenter(splitPaneCenter);

    // split pane left for plots
    SplitPane splitPaneLeftPlot = new SplitPane();
    splitPaneLeftPlot.setOrientation(Orientation.VERTICAL);

    splitPaneCenter.getItems().add(splitPaneLeftPlot);

    // add Tic plots
    splitPaneLeftPlot.getItems().add(addTicPlot(row));

    // add feature data summary
    splitPaneLeftPlot.getItems().add(addFeatureDataSummary(row));

    // split pane right
    SplitPane splitPaneRight = new SplitPane();
    splitPaneRight.setOrientation(Orientation.VERTICAL);
    splitPaneCenter.getItems().add(splitPaneRight);

    // add spectra MS1
    splitPaneRight.getItems().add(addSpectraMS1());

    // add Spectra MS2
    if (feature.getMostIntenseFragmentScanNumber() > 0) {
      splitPaneRight.getItems().add(addSpectraMS2());
    } else {
      FlowPane noMSMSPanel = new FlowPane();
      Label noMSMSScansFound = new Label("Sorry, no MS/MS scans found!");
      // noMSMSScansFound.setFont(new Font("Dialog", Font.BOLD, 16));
      // noMSMSScansFound.setForeground(Color.RED);
      noMSMSPanel.getChildren().add(noMSMSScansFound);
      splitPaneRight.getItems().add(noMSMSPanel);
    }

    // Add the Windows menu
    WindowsMenu.addWindowsMenu(mainScene);
    this.show();

  }
 
Example 15
Source File: ReplayStage.java    From xframium-java with GNU General Public License v3.0 4 votes vote down vote up
public ReplayStage (Session session, Path path, Preferences prefs, Screen screen)
{
  this.prefs = prefs;

  final Label label = session.getHeaderLabel ();
  label.setFont (new Font ("Arial", 20));
  label.setPadding (new Insets (10, 10, 10, 10));                 // trbl

  boolean showTelnet = prefs.getBoolean ("ShowTelnet", false);
  boolean showExtended = prefs.getBoolean ("ShowExtended", false);

  final HBox checkBoxes = new HBox ();
  checkBoxes.setSpacing (15);
  checkBoxes.setPadding (new Insets (10, 10, 10, 10));            // trbl
  checkBoxes.getChildren ().addAll (showTelnetCB, show3270ECB);

  SessionTable sessionTable = new SessionTable ();
  CommandPane commandPane =
      new CommandPane (sessionTable, CommandPane.ProcessInstruction.DoProcess);

  //    commandPane.setScreen (session.getScreen ());
  commandPane.setScreen (screen);

  setTitle ("Replay Commands - " + path.getFileName ());

  ObservableList<SessionRecord> masterData = session.getDataRecords ();
  FilteredList<SessionRecord> filteredData = new FilteredList<> (masterData, p -> true);

  ChangeListener<? super Boolean> changeListener =
      (observable, oldValue, newValue) -> change (sessionTable, filteredData);

  showTelnetCB.selectedProperty ().addListener (changeListener);
  show3270ECB.selectedProperty ().addListener (changeListener);

  if (true)         // this sucks - remove it when java works properly
  {
    showTelnetCB.setSelected (true);          // must be a bug
    show3270ECB.setSelected (true);
  }

  showTelnetCB.setSelected (showTelnet);
  show3270ECB.setSelected (showExtended);

  SortedList<SessionRecord> sortedData = new SortedList<> (filteredData);
  sortedData.comparatorProperty ().bind (sessionTable.comparatorProperty ());
  sessionTable.setItems (sortedData);

  displayFirstScreen (session, sessionTable);

  setOnCloseRequest (e -> Platform.exit ());

  windowSaver = new WindowSaver (prefs, this, "Replay");
  if (!windowSaver.restoreWindow ())
  {
    primaryScreenBounds = javafx.stage.Screen.getPrimary ().getVisualBounds ();
    setX (800);
    setY (primaryScreenBounds.getMinY ());
    double height = primaryScreenBounds.getHeight ();
    setHeight (Math.min (height, 1200));
  }

  BorderPane borderPane = new BorderPane ();
  borderPane.setLeft (sessionTable);      // fixed size
  borderPane.setCenter (commandPane);     // expands to fill window
  borderPane.setTop (label);
  borderPane.setBottom (checkBoxes);

  Scene scene = new Scene (borderPane);
  setScene (scene);
}
 
Example 16
Source File: Exercise_16_15.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Appliction class
public void start(Stage primaryStage) {
	// Set properties for combobox
	cbo.getItems().addAll("TOP", "BOTTOM", "LEFT", "RIGHT");
	cbo.setStyle("-fx-color: green");
	cbo.setValue("LEFT");

	// Create a text field
	TextField tfGap = new TextField("0");
	tfGap.setPrefColumnCount(3);

	// Create a hox to hold labels a text field and combo box
	HBox paneForSettings = new HBox(10);
	paneForSettings.setAlignment(Pos.CENTER);
	paneForSettings.getChildren().addAll(new Label("contentDisplay:"),
		cbo, new Label("graphicTextGap:"), tfGap);

	// Create an imageview
	ImageView image = new ImageView(new Image("image/grapes.gif"));

	// Label the image
	Label lblGrapes = new Label("Grapes", image);
	lblGrapes.setGraphicTextGap(0);

	// Place the image and its label in a stack pane
	StackPane paneForImage = new StackPane(lblGrapes);

	// Create and register handlers
	cbo.setOnAction(e -> {
		lblGrapes.setContentDisplay(setDisplay());
	});

	tfGap.setOnAction(e -> {
		lblGrapes.setGraphicTextGap(Integer.parseInt(tfGap.getText()));
	});

	// Place nodes in a border pane
	BorderPane pane = new BorderPane();
	pane.setTop(paneForSettings);
	pane.setCenter(paneForImage);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 400, 200);
	primaryStage.setTitle("Exericse_16_15"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 17
Source File: NodeView.java    From PreferencesFX with Apache License 2.0 4 votes vote down vote up
private void layoutParts() {
  // VBox with values
  VBox valueBox = new VBox(
      welcomeLbl,
      brightnessLbl,
      nightModeLbl,
      scalingLbl,
      screenNameLbl,
      resolutionLbl,
      orientationLbl,
      favoritesLbl,
      fontSizeLbl,
      lineSpacingLbl,
      favoriteNumberLbl
  );
  valueBox.setSpacing(20);
  valueBox.setPadding(new Insets(20, 0, 0, 20));
  Button saveSettingsButton = new Button("Save Settings");
  saveSettingsButton.setOnAction(event -> preferencesFx.saveSettings());
  Button discardChangesButton = new Button("Discard Changes");
  discardChangesButton.setOnAction(event -> preferencesFx.discardChanges());
  // VBox with descriptions
  VBox descriptionBox = new VBox(
      new Label("Welcome Text:"),
      new Label("Brightness:"),
      new Label("Night mode:"),
      new Label("Scaling:"),
      new Label("Screen name:"),
      new Label("Resolution:"),
      new Label("Orientation:"),
      new Label("Favorites:"),
      new Label("Font Size:"),
      new Label("Line Spacing:"),
      new Label("Favorite Number:"),
      saveSettingsButton,
      discardChangesButton
  );
  descriptionBox.setSpacing(20);
  descriptionBox.setPadding(new Insets(20, 0, 0, 20));

  PreferencesFxView preferencesFxView = preferencesFx.getView();
  // Put everything together
  BorderPane pane = new BorderPane();
  HBox hBox = new HBox(descriptionBox, valueBox);
  pane.setLeft(hBox);
  hBox.setPadding(new Insets(0, 20, 0, 0));
  pane.setCenter(preferencesFxView);
  VBox.setVgrow(pane, Priority.ALWAYS);
  getChildren().addAll(
      pane
  );

  // Styling
  getStyleClass().add("demo-view");
  if (rootPane.nightMode.get()) {
    getStylesheets().add(AppStarter.class.getResource("darkTheme.css").toExternalForm());
  }
}
 
Example 18
Source File: HistogramWindow.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public HistogramWindow(ParameterSet parameters) {

    PeakList peakList =
        parameters.getParameter(HistogramParameters.peakList).getValue().getMatchingPeakLists()[0];

    this.setTitle("Histogram of " + peakList.getName());

    mainPane = new BorderPane();
    mainScene = new Scene(mainPane);

    // Use main CSS
    mainScene.getStylesheets()
        .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets());
    setScene(mainScene);

    RawDataFile rawDataFiles[] = parameters.getParameter(HistogramParameters.dataFiles).getValue();

    HistogramDataType dataType = parameters.getParameter(HistogramParameters.dataRange).getType();
    int numOfBins = parameters.getParameter(HistogramParameters.numOfBins).getValue();
    Range<Double> range = parameters.getParameter(HistogramParameters.dataRange).getValue();

    // setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    // setBackground(Color.white);

    // Creates plot and toolbar
    histogram = new HistogramChart();

    // Border one = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    // Border two = BorderFactory.createEmptyBorder(5, 5, 5, 5);

    // BorderPane pnlPlot = new BorderPane();
    // pnlPlot.setBorder(BorderFactory.createCompoundBorder(one, two));
    // pnlPlot.setBackground(Color.white);

    // pnlPlot.add(histogram, BorderLayout.CENTER);

    mainPane.setCenter(histogram);

    // Add the Windows menu
    WindowsMenu.addWindowsMenu(mainScene);

    // pack();

    // get the window settings parameter
    ParameterSet paramSet =
        MZmineCore.getConfiguration().getModuleParameters(HistogramVisualizerModule.class);
    WindowSettingsParameter settings = paramSet.getParameter(HistogramParameters.windowSettings);

    // update the window and listen for changes
    // settings.applySettingsToWindow(this);
    // this.addComponentListener(settings);

    setMinWidth(600.0);
    setMinHeight(400.0);

    if (peakList != null) {
      HistogramPlotDataset dataSet =
          new HistogramPlotDataset(peakList, rawDataFiles, numOfBins, dataType, range);
      histogram.addDataset(dataSet, dataType);
    }

  }
 
Example 19
Source File: DiagramTab.java    From JetUML with GNU General Public License v3.0 4 votes vote down vote up
/**
    * Constructs a diagram tab initialized with pDiagram.
    * @param pDiagram The initial diagram
 */
public DiagramTab(Diagram pDiagram)
{
	aDiagram = pDiagram;
	DiagramTabToolBar sideBar = new DiagramTabToolBar(pDiagram);
	UserPreferences.instance().addBooleanPreferenceChangeHandler(sideBar);
	aDiagramCanvas = new DiagramCanvas(pDiagram);
	UserPreferences.instance().addBooleanPreferenceChangeHandler(aDiagramCanvas);
	aDiagramCanvasController = new DiagramCanvasController(aDiagramCanvas, sideBar, this);
	aDiagramCanvas.setController(aDiagramCanvasController);
	aDiagramCanvas.paintPanel();
	
	BorderPane layout = new BorderPane();
	layout.setRight(sideBar);

	// We put the diagram in a fixed-size StackPane for the sole purpose of being able to
	// decorate it with CSS. The StackPane needs to have a fixed size so the border fits the 
	// canvas and not the parent container.
	StackPane pane = new StackPane(aDiagramCanvas);
	final int buffer = 12; // (border insets + border width + 1)*2
	pane.setMaxSize(aDiagramCanvas.getWidth() + buffer, aDiagramCanvas.getHeight() + buffer);
	final String cssDefault = "-fx-border-color: grey; -fx-border-insets: 4;"
			+ "-fx-border-width: 1; -fx-border-style: solid;";
	pane.setStyle(cssDefault);
	
	// We wrap pane within an additional, resizable StackPane that can grow to fit the parent
	// ScrollPane and thus center the decorated canvas.
	ScrollPane scroll = new ScrollPane(new StackPane(pane));
	
	// The call below is necessary to removes the focus highlight around the Canvas
	// See issue #250
	scroll.setStyle("-fx-focus-color: transparent; -fx-faint-focus-color: transparent;"); 

	scroll.setFitToWidth(true);
	scroll.setFitToHeight(true);
	layout.setCenter(scroll);
	
	setTitle();
	setContent(layout);

	setOnCloseRequest(pEvent -> 
	{
		pEvent.consume();
		EditorFrame editorFrame = (EditorFrame) getTabPane().getParent();
		editorFrame.close(this);
	});
}
 
Example 20
Source File: RollingBufferSortedTreeSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public BorderPane initComponents(Scene scene) {
    final BorderPane root = new BorderPane();
    generateData();
    initErrorDataSetRenderer(beamIntensityRenderer);
    initErrorDataSetRenderer(dipoleCurrentRenderer);

    final DefaultNumericAxis xAxis1 = new DefaultNumericAxis("time");
    xAxis1.setAutoRangeRounding(false);
    xAxis1.setTickLabelRotation(45);
    xAxis1.invertAxis(false);
    xAxis1.setTimeAxis(true);
    final DefaultNumericAxis yAxis1 = new DefaultNumericAxis("beam intensity", "ppp");
    final DefaultNumericAxis yAxis2 = new DefaultNumericAxis("dipole current", "A");
    yAxis2.setSide(Side.RIGHT);
    yAxis2.setAnimated(false);
    // N.B. it's important to set secondary axis on the 2nd renderer before
    // adding the renderer to the chart
    dipoleCurrentRenderer.getAxes().add(yAxis2);

    final XYChart chart = new XYChart(xAxis1, yAxis1);
    chart.legendVisibleProperty().set(true);
    chart.setAnimated(false);
    chart.getYAxis().setName(rollingBufferBeamIntensity.getName());
    chart.getRenderers().set(0, beamIntensityRenderer);
    chart.getRenderers().add(dipoleCurrentRenderer);
    chart.getPlugins().add(new EditAxis());

    beamIntensityRenderer.getDatasets().add(rollingBufferBeamIntensity);
    dipoleCurrentRenderer.getDatasets().add(rollingBufferDipoleCurrent);

    // set localised time offset
    if (xAxis1.isTimeAxis() && xAxis1.getAxisLabelFormatter() instanceof DefaultTimeFormatter) {
        final DefaultTimeFormatter axisFormatter = (DefaultTimeFormatter) xAxis1.getAxisLabelFormatter();

        axisFormatter.setTimeZoneOffset(ZoneOffset.UTC);
        axisFormatter.setTimeZoneOffset(ZoneOffset.ofHoursMinutes(5, 0));
    }

    yAxis1.setForceZeroInRange(true);
    yAxis2.setForceZeroInRange(true);
    yAxis1.setAutoRangeRounding(true);
    yAxis2.setAutoRangeRounding(true);

    root.setTop(getHeaderBar(scene));

    long startTime = ProcessingProfiler.getTimeStamp();
    ProcessingProfiler.getTimeDiff(startTime, "adding data to chart");

    startTime = ProcessingProfiler.getTimeStamp();
    root.setCenter(chart);

    ProcessingProfiler.getTimeDiff(startTime, "adding chart into StackPane");

    return root;
}