Java Code Examples for javafx.scene.control.RadioButton#setToggleGroup()

The following examples show how to use javafx.scene.control.RadioButton#setToggleGroup() . 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: RadioButtons.java    From marathonv5 with Apache License 2.0 7 votes vote down vote up
public RadioButtons() {
    super(400,100);
    ToggleGroup tg = new ToggleGroup();
    VBox vbox = new VBox();
    vbox.setSpacing(5);
    RadioButton rb1 = new RadioButton("Hello");
    rb1.setToggleGroup(tg);

    RadioButton rb2 = new RadioButton("Bye");
    rb2.setToggleGroup(tg);
    rb2.setSelected(true);

    RadioButton rb3 = new RadioButton("Disabled");
    rb3.setToggleGroup(tg);
    rb3.setSelected(false);
    rb3.setDisable(true);

    vbox.getChildren().add(rb1);
    vbox.getChildren().add(rb2);
    vbox.getChildren().add(rb3);
    getChildren().add(vbox);
}
 
Example 2
Source File: TransactionTypeNodeProvider.java    From constellation with Apache License 2.0 6 votes vote down vote up
private VBox addFilter() {
    filterText.setPromptText("Filter transaction types");
    final ToggleGroup toggleGroup = new ToggleGroup();
    startsWithRb.setToggleGroup(toggleGroup);
    startsWithRb.setPadding(new Insets(0, 0, 0, 5));
    startsWithRb.setSelected(true);
    final RadioButton containsRadioButton = new RadioButton("Contains");
    containsRadioButton.setToggleGroup(toggleGroup);
    containsRadioButton.setPadding(new Insets(0, 0, 0, 5));

    toggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
        populateTree();
    });

    filterText.textProperty().addListener((observable, oldValue, newValue) -> {
        populateTree();
    });

    final HBox headerBox = new HBox(new Label("Filter: "), filterText, startsWithRb, containsRadioButton);
    headerBox.setAlignment(Pos.CENTER_LEFT);
    headerBox.setPadding(new Insets(5));

    final VBox box = new VBox(schemaLabel, headerBox, treeView);
    VBox.setVgrow(treeView, Priority.ALWAYS);
    return box;
}
 
Example 3
Source File: RadioButtonDrivenTextFieldsPane.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public void addRow(RadioButton radio, Region field, Text helpIcon) {
    requireNotNullArg(radio, "Cannot add a null radio");
    requireNotNullArg(field, "Cannot add a null field");
    GridPane.setValignment(radio, VPos.BOTTOM);
    GridPane.setValignment(field, VPos.BOTTOM);
    GridPane.setHalignment(radio, HPos.LEFT);
    GridPane.setHalignment(field, HPos.LEFT);
    GridPane.setFillWidth(field, true);
    field.setPrefWidth(300);
    field.setDisable(true);
    radio.selectedProperty().addListener((o, oldVal, newVal) -> {
        field.setDisable(!newVal);
        if (newVal) {
            field.requestFocus();
        }
    });
    radio.setToggleGroup(group);
    add(radio, 0, rows);
    add(field, 1, rows);
    if (nonNull(helpIcon)) {
        add(helpIcon, 2, rows);
    }
    rows++;

}
 
Example 4
Source File: SimpleRadioButtonControl.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * This method creates radio buttons and adds them to radioButtons
 * and is used when the itemsProperty on the field changes.
 */
private void createRadioButtons() {
  node.getChildren().clear();
  radioButtons.clear();

  for (int i = 0; i < field.getItems().size(); i++) {
    RadioButton rb = new RadioButton();

    rb.setText(field.getItems().get(i).toString());
    rb.setToggleGroup(toggleGroup);

    radioButtons.add(rb);
  }

  if (field.getSelection() != null) {
    radioButtons.get(field.getItems().indexOf(field.getSelection())).setSelected(true);
  }

  node.getChildren().addAll(radioButtons);
}
 
Example 5
Source File: NodePropertiesSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private RadioButton createRadioButton(final Node rect, String name, final boolean toFront, ToggleGroup tg) {
    final RadioButton radioButton = new RadioButton(name);
    radioButton.setToggleGroup(tg);
    radioButton.selectedProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (radioButton.isSelected()) {
                if (toFront) {
                    rect.toFront();
                } else {
                    rect.toBack();
                }
            }
        }
    });

    return radioButton;
}
 
Example 6
Source File: RadioButtons.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public RadioButtons() {
    super(400,100);
    ToggleGroup tg = new ToggleGroup();
    VBox vbox = new VBox();
    vbox.setSpacing(5);
    RadioButton rb1 = new RadioButton("Hello");
    rb1.setToggleGroup(tg);

    RadioButton rb2 = new RadioButton("Bye");
    rb2.setToggleGroup(tg);
    rb2.setSelected(true);

    RadioButton rb3 = new RadioButton("Disabled");
    rb3.setToggleGroup(tg);
    rb3.setSelected(false);
    rb3.setDisable(true);

    vbox.getChildren().add(rb1);
    vbox.getChildren().add(rb2);
    vbox.getChildren().add(rb3);
    getChildren().add(vbox);
}
 
Example 7
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, RadioButton, RadioButton> addTopLabelRadioButtonRadioButton(GridPane gridPane,
                                                                                        int rowIndex,
                                                                                        ToggleGroup toggleGroup,
                                                                                        String title,
                                                                                        String radioButtonTitle1,
                                                                                        String radioButtonTitle2,
                                                                                        double top) {
    RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
    radioButton1.setToggleGroup(toggleGroup);
    radioButton1.setPadding(new Insets(6, 0, 0, 0));

    RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
    radioButton2.setToggleGroup(toggleGroup);
    radioButton2.setPadding(new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(radioButton1, radioButton2);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);

    return new Tuple3<>(topLabelWithVBox.first, radioButton1, radioButton2);
}
 
Example 8
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple4<Label, TextField, RadioButton, RadioButton> addTopLabelTextFieldRadioButtonRadioButton(GridPane gridPane,
                                                                                                            int rowIndex,
                                                                                                            ToggleGroup toggleGroup,
                                                                                                            String title,
                                                                                                            String textFieldTitle,
                                                                                                            String radioButtonTitle1,
                                                                                                            String radioButtonTitle2,
                                                                                                            double top) {
    TextField textField = new BisqTextField();
    textField.setPromptText(textFieldTitle);

    RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
    radioButton1.setToggleGroup(toggleGroup);
    radioButton1.setPadding(new Insets(6, 0, 0, 0));

    RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
    radioButton2.setToggleGroup(toggleGroup);
    radioButton2.setPadding(new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(textField, radioButton1, radioButton2);

    final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);

    return new Tuple4<>(labelVBoxTuple2.first, textField, radioButton1, radioButton2);
}
 
Example 9
Source File: CurlExporter.java    From milkman with MIT License 5 votes vote down vote up
@Override
public Node getRoot(RequestContainer request, Templater templater) {
	this.request = request;
	textArea = new TextArea();
	textArea.setEditable(false);
	
	HBox osSelection = new HBox();
	
	ToggleGroup group = new ToggleGroup();
	RadioButton windowsTgl = new RadioButton("Windows");
	windowsTgl.setToggleGroup(group);
	windowsTgl.setSelected(isWindows);
	RadioButton unixTgl = new RadioButton("Unix");
	unixTgl.setSelected(!isWindows);
	unixTgl.setToggleGroup(group);
	
	
	windowsTgl.selectedProperty().addListener((obs, o, n) -> {
		if (n != null) {
			isWindows = n;
			refreshCommand(templater);
		}
	});

	osSelection.getChildren().add(windowsTgl);
	osSelection.getChildren().add(unixTgl);
	
	VBox root = new VBox();
	root.getChildren().add(osSelection);
	root.getChildren().add(textArea);
	VBox.setVgrow(textArea, Priority.ALWAYS);
	refreshCommand(templater);
	return 	root;
}
 
Example 10
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public RadioButton getRadioButton(String text, VBox vbox, ToggleGroup group)
{
  RadioButton button = new RadioButton(text);
  vbox.getChildren().add(button);
  button.setToggleGroup(group);
  button.setDisable(true);
  return button;
}
 
Example 11
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static RadioButton addRadioButton(GridPane gridPane, int rowIndex, ToggleGroup toggleGroup, String title) {
    RadioButton radioButton = new AutoTooltipRadioButton(title);
    radioButton.setToggleGroup(toggleGroup);
    GridPane.setRowIndex(radioButton, rowIndex);
    gridPane.getChildren().add(radioButton);
    return radioButton;
}
 
Example 12
Source File: Exercise_16_06.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Set properties for text fields
	tfTextField.setText("JavaFX");
	tfTextField.setAlignment(Pos.BOTTOM_CENTER);
	tfColumnSize.setAlignment(Pos.BOTTOM_RIGHT);
	tfColumnSize.setPrefColumnCount(3);
	tfTextField.setPrefColumnCount(12);
	tfColumnSize.setText("12");

	// Create three radio buttions
	RadioButton rbLeft = new RadioButton("Left");
	RadioButton rbCenter = new RadioButton("Center");
	RadioButton rbRight = new RadioButton("Right");
	rbCenter.setSelected(true);

	// Create a toggle group
	ToggleGroup group = new ToggleGroup();
	rbLeft.setToggleGroup(group);
	rbCenter.setToggleGroup(group);
	rbRight.setToggleGroup(group);
	
	// Create four hbox
	HBox paneForRadioButtons = new HBox(5);
	paneForRadioButtons.getChildren().addAll(rbLeft, rbCenter, rbRight);
	paneForRadioButtons.setAlignment(Pos.BOTTOM_LEFT);

	HBox paneForColumnSize = new HBox(5);
	paneForColumnSize.getChildren().addAll(
		new Label("Colum Size"), tfColumnSize);

	HBox paneForTextField = new HBox(5);
	paneForTextField.setAlignment(Pos.CENTER);
	paneForTextField.getChildren().addAll(
		new Label("Text Field"), tfTextField);

	HBox hbox = new HBox(10);
	hbox.getChildren().addAll(paneForRadioButtons, paneForColumnSize);

	// Create a vBox and place nodes in it
	VBox pane = new VBox(10);
	pane.setPadding(new Insets(5, 5, 5, 5));
	pane.getChildren().addAll(paneForTextField, hbox);

	// Create and register the handlers 
	rbLeft.setOnAction(e -> {
		if (rbLeft.isSelected()) {
			tfTextField.setAlignment(Pos.BOTTOM_LEFT);
		}
	});

	rbCenter.setOnAction(e -> {
		if (rbCenter.isSelected()) {
			tfTextField.setAlignment(Pos.BOTTOM_CENTER);
		}
	});

	rbRight.setOnAction(e -> {
		if (rbRight.isSelected()) {
			tfTextField.setAlignment(Pos.BOTTOM_RIGHT);
		}
	});

	tfColumnSize.setOnKeyPressed(e -> {
		if (e.getCode() == KeyCode.ENTER) {
			tfTextField.setPrefColumnCount(Integer.parseInt(
				tfColumnSize.getText()));
		}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_16_06"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 13
Source File: Exercise_16_01.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the stage method in the Application class
public void start(Stage primaryStage) {
	HBox paneForButtons = new HBox(20);
	Button btLeft = new Button("<=");
	Button btRight = new Button("=>");
	paneForButtons.getChildren().addAll(btLeft, btRight);
	paneForButtons.setAlignment(Pos.CENTER);
	BorderPane pane = new BorderPane();
	pane.setBottom(paneForButtons);

	HBox paneForRadioButtons = new HBox(20);
	RadioButton rbRed = new RadioButton("Red");
	RadioButton rbYellow = new RadioButton("Yellow");
	RadioButton rbBlack = new RadioButton("Black");
	RadioButton rbOrange = new RadioButton("Orange");
	RadioButton rbGreen = new RadioButton("Green");
	paneForRadioButtons.getChildren().addAll(rbRed, rbYellow, 
		rbBlack, rbOrange, rbGreen);

	ToggleGroup group = new ToggleGroup();
	rbRed.setToggleGroup(group);
	rbYellow.setToggleGroup(group);
	rbBlack.setToggleGroup(group);
	rbOrange.setToggleGroup(group);
	rbGreen.setToggleGroup(group);

	Pane paneForText = new Pane();
	paneForText.setStyle("-fx-border-color: black");
	paneForText.getChildren().add(text);
	pane.setCenter(paneForText);
	pane.setTop(paneForRadioButtons);

	btLeft.setOnAction(e -> text.setX(text.getX() - 10));
	btRight.setOnAction(e -> text.setX(text.getX() + 10));

	rbRed.setOnAction(e -> {
		if (rbRed.isSelected()) {
			text.setFill(Color.RED);
		}
	});

	rbYellow.setOnAction(e -> {
		if (rbYellow.isSelected()) {
			text.setFill(Color.YELLOW);
		}
	});

	rbBlack.setOnAction(e -> {
		if (rbBlack.isSelected()) {
			text.setFill(Color.BLACK);
		}
	});

	rbOrange.setOnAction(e -> {
		if (rbOrange.isSelected()) {
			text.setFill(Color.ORANGE);
		}
	});

	rbGreen.setOnAction(e -> {
		if (rbGreen.isSelected()) {
			text.setFill(Color.GREEN);
		}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 450, 150);
	primaryStage.setTitle("Exercise_16_01"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 14
Source File: JavaFxSelectionComponentFactory.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
ProxySetting(
    final ClientSetting<HttpProxy.ProxyChoice> proxyChoiceClientSetting,
    final ClientSetting<String> proxyHostClientSetting,
    final ClientSetting<Integer> proxyPortClientSetting) {
  this.proxyChoiceClientSetting = proxyChoiceClientSetting;
  this.proxyHostClientSetting = proxyHostClientSetting;
  this.proxyPortClientSetting = proxyPortClientSetting;

  final HttpProxy.ProxyChoice proxyChoice = proxyChoiceClientSetting.getValueOrThrow();
  noneButton = new RadioButton("None");
  noneButton.setSelected(proxyChoice == HttpProxy.ProxyChoice.NONE);
  systemButton = new RadioButton("Use System Settings");
  systemButton.setSelected(proxyChoice == HttpProxy.ProxyChoice.USE_SYSTEM_SETTINGS);
  userButton = new RadioButton("Use These Settings:");
  userButton.setSelected(proxyChoice == HttpProxy.ProxyChoice.USE_USER_PREFERENCES);
  hostText = new TextField(proxyHostClientSetting.getValue().orElse(""));
  portText = new TextField(proxyPortClientSetting.getValue().map(Object::toString).orElse(""));
  final VBox radioPanel = new VBox();
  radioPanel
      .getChildren()
      .addAll(
          noneButton,
          systemButton,
          userButton,
          new Label("Proxy Host: "),
          hostText,
          new Label("Proxy Port: "),
          portText);
  hostText.disableProperty().bind(Bindings.not(userButton.selectedProperty()));
  portText.disableProperty().bind(Bindings.not(userButton.selectedProperty()));

  final ToggleGroup toggleGroup = new ToggleGroup();
  noneButton.setToggleGroup(toggleGroup);
  systemButton.setToggleGroup(toggleGroup);
  userButton.setToggleGroup(toggleGroup);
  toggleGroup
      .selectedToggleProperty()
      .addListener(
          (observable, oldValue, newValue) -> {
            if (!userButton.isSelected()) {
              hostText.clear();
              portText.clear();
            }
          });

  getChildren().add(radioPanel);
}
 
Example 15
Source File: ChooseCameraControllerSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage){

  try {

    // create stack pane and JavaFX app scene
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);
    fxScene.getStylesheets().add(getClass().getResource("/choose_camera_controller/style.css").toExternalForm());

    // set title, size, and add JavaFX scene to stage
    stage.setTitle("Choose Camera Controller Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(fxScene);
    stage.show();

    // create a scene and add a basemap to it
    ArcGISScene scene = new ArcGISScene();
    scene.setBasemap(Basemap.createImagery());

    // set the scene to a scene view
    sceneView = new SceneView();
    sceneView.setArcGISScene(scene);

    // add base surface for elevation data
    Surface surface = new Surface();
    ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource("https://elevation3d.arcgis" +
            ".com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
    surface.getElevationSources().add(elevationSource);
    scene.setBaseSurface(surface);

    // create a graphics overlay for the scene
    GraphicsOverlay sceneGraphicsOverlay = new GraphicsOverlay();
    sceneView.getGraphicsOverlays().add(sceneGraphicsOverlay);

    // create a graphic with a ModelSceneSymbol of a plane to add to the scene
    String modelURI = new File(System.getProperty("data.dir"), "./samples-data/bristol/Collada/Bristol.dae").getAbsolutePath();
    ModelSceneSymbol plane3DSymbol = new ModelSceneSymbol(modelURI, 1.0);
    plane3DSymbol.loadAsync();
    plane3DSymbol.setHeading(45);
    Graphic plane3D = new Graphic(new Point(-109.937516, 38.456714, 5000, SpatialReferences.getWgs84()), plane3DSymbol);
    sceneGraphicsOverlay.getSceneProperties().setSurfacePlacement(LayerSceneProperties.SurfacePlacement.ABSOLUTE);
    sceneGraphicsOverlay.getGraphics().add(plane3D);

    // create a camera and set it as the viewpoint for when the scene loads
    Camera camera = new Camera(38.459291, -109.937576, 5500, 150.0, 20.0, 0.0);
    sceneView.setViewpointCamera(camera);

    // instantiate a new camera controller which orbits the plane at a set distance
    OrbitGeoElementCameraController orbitPlaneCameraController = new OrbitGeoElementCameraController(plane3D, 100.0);
    orbitPlaneCameraController.setCameraPitchOffset(30);
    orbitPlaneCameraController.setCameraHeadingOffset(150);

    // instantiate a new camera controller which orbits a target location
    Point locationPoint = new Point(-109.929589, 38.437304, 1700, SpatialReferences.getWgs84());
    OrbitLocationCameraController orbitLocationCameraController = new OrbitLocationCameraController(locationPoint, 5000);
    orbitLocationCameraController.setCameraPitchOffset(3);
    orbitLocationCameraController.setCameraHeadingOffset(150);

    // create radio buttons for choosing camera controller
    RadioButton orbitPlane = new RadioButton("ORBIT CAMERA AROUND PLANE");
    RadioButton orbitLocation = new RadioButton("ORBIT CAMERA AROUND CRATER");
    RadioButton globeCamera = new RadioButton("FREE PAN ROUND THE GLOBE");
    globeCamera.setSelected(true);

    // set the buttons to a toggle group
    ToggleGroup toggleGroup = new ToggleGroup();
    orbitPlane.setToggleGroup(toggleGroup);
    orbitLocation.setToggleGroup(toggleGroup);
    globeCamera.setToggleGroup(toggleGroup);

    // set the radio buttons to choose which camera controller is active
    orbitPlane.setOnAction(event -> sceneView.setCameraController(orbitPlaneCameraController));

    orbitLocation.setOnAction(event -> sceneView.setCameraController(orbitLocationCameraController));

    globeCamera.setOnAction(event -> sceneView.setCameraController(new GlobeCameraController()));

    // create a control panel
    VBox controlsVBox = new VBox(10);
    controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0, 0, 0, 0.3)"), CornerRadii.EMPTY, Insets.EMPTY)));
    controlsVBox.setPadding(new Insets(10.0));
    controlsVBox.setMaxSize(300, 80);
    controlsVBox.getStyleClass().add("panel-region");
    // add radio buttons to the control panel
    controlsVBox.getChildren().addAll(orbitPlane, orbitLocation, globeCamera);

    // add scene view, label and control panel to the stack pane
    stackPane.getChildren().addAll(sceneView, controlsVBox);
    StackPane.setAlignment(controlsVBox, Pos.TOP_LEFT);
    StackPane.setMargin(controlsVBox, new Insets(60, 0, 0, 20));

  } catch (Exception e) {
    // on any exception, print the stack trace
    e.printStackTrace();
  }
}
 
Example 16
Source File: ForceDirectedGraphTest.java    From charts with Apache License 2.0 4 votes vote down vote up
private void initializeParts(){
    dataGenerator = new DataGenerator();
    dataGenerator.generateGraphWithMinimalInformation();

    nodeEdgeModel = new NodeEdgeModel(dataGenerator.getNodes(), dataGenerator.getEdges());
    nodeEdgeModel.addColorTheme(createExampleColorTheme(),"Example_1");
    nodeEdgeModel.addColorTheme(createExampleColorTheme2(), "Example_2");
    nodeEdgeModel.setCurrentColorThemeKey("Kelly Color");
    graphPanel = new GraphPanel(nodeEdgeModel);


    sliderBox = new VBox();

    nodeSizeFactor  = new Slider(5,30,10);
    edgeWidthFactor = new Slider(0.5,10,5);

    groupComboBox = new ComboBox<>();
    nodeValueComboBox = new ComboBox<>();
    edgeForceValueComboBox = new ComboBox<>();
    edgeWidthValueComboBox = new ComboBox<>();

    colorSchemeComboBox = new ComboBox<>();
    colorSchemeComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getColorThemeKeys());

    normalizeGroup = new ToggleGroup();
    alwaysNormalize = new RadioButton("Always Normalize");
    neverNormalize = new RadioButton("Never Normalize");
    normalizeIfBetweenZeroAndOne = new RadioButton("Normalize if Between 0 and 1");
    alwaysNormalize.setToggleGroup(normalizeGroup);
    neverNormalize.setToggleGroup(normalizeGroup);
    normalizeIfBetweenZeroAndOne.setToggleGroup(normalizeGroup);
    alwaysNormalize.setSelected(true);
    physic = new CheckBox("Disable Physics");
    physic.selectedProperty().setValue(true);
    invertedForce = new CheckBox("inverted");

    calculateDegreeCentrality = new Button("Calculate Degreecentrality");
    calculateClosenessCentrality = new Button("Calculate ClossenessCentrality");
    calculateBetweennessCentrality = new Button("Calculate BetweennessCentrality");
    restartAnimation = new Button("Restart Animation");

    borderColorPicker = new ColorPicker();
    edgeColorPicker = new ColorPicker();
    edgeColorPicker.setValue(Color.LIGHTGRAY);

    groupComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getStringAttributeKeysOfNodes());
    nodeValueComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getNumericAttributeKeysOfNodes());
    edgeForceValueComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getNumericAttributeKeysOfEdges());
    edgeWidthValueComboBox.getItems().addAll(graphPanel.getNodeEdgeModel().getNumericAttributeKeysOfEdges());

    //edgeForceValueComboBox.getItems().addAll(nodeEdgeModel)

    dataChanger = new ComboBox<>();
    dataChanger.getItems().addAll("D3Example","FoodExport");

    colors = new VBox();




    refreshColorPickers();


}
 
Example 17
Source File: ActionsDialog.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** @return Sub-pane for OpenDisplay action */
private GridPane createOpenDisplayDetails()
{
    final InvalidationListener update = whatever ->
    {
        if (updating  ||  selected_action_index < 0)
            return;
        actions.set(selected_action_index, getOpenDisplayAction());
    };

    final GridPane open_display_details = new GridPane();
    // open_display_details.setGridLinesVisible(true);
    open_display_details.setHgap(10);
    open_display_details.setVgap(10);

    open_display_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    open_display_description.textProperty().addListener(update);
    open_display_details.add(open_display_description, 1, 0);
    GridPane.setHgrow(open_display_description, Priority.ALWAYS);

    open_display_details.add(new Label(Messages.ActionsDialog_DisplayPath), 0, 1);
    open_display_path.textProperty().addListener(update);
    final Button select = new Button("...");
    select.setOnAction(event ->
    {
        try
        {
            final String path = FilenameSupport.promptForRelativePath(widget, open_display_path.getText());
            if (path != null)
                open_display_path.setText(path);
            FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
        }
        catch (Exception ex)
        {
            logger.log(Level.WARNING, "Cannot prompt for filename", ex);
        }
    });
    final HBox path_box = new HBox(open_display_path, select);
    HBox.setHgrow(open_display_path, Priority.ALWAYS);
    open_display_details.add(path_box, 1, 1);

    final HBox modes_box = new HBox(10);
    open_display_targets = new ToggleGroup();
    final Target[] modes = Target.values();
    for (int i=0; i<modes.length; ++i)
    {
        // Suppress deprecated legacy mode which is handled as WINDOW
        if (modes[i] == Target.STANDALONE)
            continue;

        final RadioButton target = new RadioButton(modes[i].toString());
        target.setToggleGroup(open_display_targets);
        target.selectedProperty().addListener(update);
        modes_box.getChildren().add(target);

        if (modes[i] == Target.TAB)
            open_display_pane.disableProperty().bind(target.selectedProperty().not());
    }
    open_display_pane.textProperty().addListener(update);
    open_display_details.add(modes_box, 0, 2, 2, 1);

    open_display_details.add(new Label("Pane:"), 0, 3);
    open_display_details.add(open_display_pane, 1, 3);

    open_display_macros = new MacrosTable(new Macros());
    open_display_macros.addListener(update);
    open_display_details.add(open_display_macros.getNode(), 0, 4, 2, 1);
    GridPane.setHgrow(open_display_macros.getNode(), Priority.ALWAYS);
    GridPane.setVgrow(open_display_macros.getNode(), Priority.ALWAYS);

    return open_display_details;
}
 
Example 18
Source File: Exercise_16_02.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Set shape properties
	circle.setStroke(Color.BLACK);
	circle.setFill(Color.WHITE);
	rectangle.setStroke(Color.BLACK);
	rectangle.setWidth(150);
	rectangle.setFill(Color.WHITE);
	rectangle.setHeight(100);
	ellipse.setFill(Color.WHITE);
	ellipse.setStroke(Color.BLACK);
	ellipse.setRadiusX(100);
	ellipse.setRadiusY(50);

	// Create a hbox to hold buttons
	HBox paneForButtons = new HBox(5);
	paneForButtons.setAlignment(Pos.CENTER);
	RadioButton rbCircle = new RadioButton("Circle"); 
	RadioButton rbRectangle = new RadioButton("Rectangle"); 
	RadioButton rbEllipse = new RadioButton("Ellipse"); 

	// Create a toggle group for shapes
	ToggleGroup group = new ToggleGroup();
	rbCircle.setToggleGroup(group);
	rbRectangle.setToggleGroup(group);
	rbEllipse.setToggleGroup(group);

	// Create a check box
	CheckBox chkFill = new CheckBox("Fill");

	// Place buttons in the hbox
	paneForButtons.getChildren().addAll(rbCircle, 
		rbRectangle, rbEllipse, chkFill);

	// Create a stack pane to hold the shapes
	StackPane paneForShapes = new StackPane();
	paneForShapes.setStyle("-fx-border-color: black");

	// Create a border pane to hold nodes
	BorderPane pane = new BorderPane();
	pane.setBottom(paneForButtons);
	pane.setCenter(paneForShapes);

	// Create and register handlers
	rbCircle.setOnAction(e -> {
		if (rbCircle.isSelected()) {
			paneForShapes.getChildren().clear();
			paneForShapes.getChildren().add(circle);
		}
	});

	rbRectangle.setOnAction(e -> {
		if (rbRectangle.isSelected()) {
			paneForShapes.getChildren().clear();
			paneForShapes.getChildren().add(rectangle);
		}
	});

	rbEllipse.setOnAction(e -> {
		if (rbEllipse.isSelected()) {
			paneForShapes.getChildren().clear();
			paneForShapes.getChildren().add(ellipse);
		}
	});

	chkFill.setOnAction(e -> {
		if (chkFill.isSelected()) {
			circle.setFill(Color.BLACK);
			rectangle.setFill(Color.BLACK);
			ellipse.setFill(Color.BLACK);
		} else {
			circle.setFill(Color.WHITE);
			rectangle.setFill(Color.WHITE);
			ellipse.setFill(Color.WHITE);			}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 400, 150);
	primaryStage.setTitle("Exercise_16_02"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 19
Source File: Exercise_16_03.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application calss
public void start(Stage primaryStage) {
	// Create a vbox
	VBox paneForCircles = new VBox(5);
	paneForCircles.setAlignment(Pos.CENTER);

	// Create three circles
	Circle c1 = getCircle();
	Circle c2 = getCircle();
	Circle c3 = getCircle();
	c1.setFill(Color.RED);

	// Place circles in vbox
	paneForCircles.getChildren().addAll(c1, c2, c3);

	// Create a rectangle
	Rectangle rectangle = new Rectangle();
	rectangle.setFill(Color.WHITE);
	rectangle.setWidth(30);
	rectangle.setHeight(100);
	rectangle.setStroke(Color.BLACK);
	rectangle.setStrokeWidth(2);
	StackPane stopSign = new StackPane(rectangle, paneForCircles);

	// Create a hbox
	HBox paneForRadioButtons = new HBox(5);
	paneForRadioButtons.setAlignment(Pos.CENTER);

	// Create radio buttons
	RadioButton rbRed = new RadioButton("Red");
	RadioButton rbYellow = new RadioButton("Yellow");
	RadioButton rbGreen = new RadioButton("Green");

	// Create a toggle group
	ToggleGroup group = new ToggleGroup();
	rbRed.setToggleGroup(group);
	rbYellow.setToggleGroup(group);
	rbGreen.setToggleGroup(group);
	rbRed.setSelected(true);
	paneForRadioButtons.getChildren().addAll(rbRed, rbYellow, rbGreen);

	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setCenter(stopSign);
	pane.setBottom(paneForRadioButtons);

	// Create and register handlers
	rbRed.setOnAction(e -> {
		if (rbRed.isSelected()) {
			c1.setFill(Color.RED);
			c2.setFill(Color.WHITE);
			c3.setFill(Color.WHITE);
		}
	});

	rbYellow.setOnAction(e -> {
		if (rbYellow.isSelected()) {
			c1.setFill(Color.WHITE);
			c2.setFill(Color.YELLOW);
			c3.setFill(Color.WHITE);
		}
	});

	rbGreen.setOnAction(e -> {
		if (rbGreen.isSelected()) {
			c1.setFill(Color.WHITE);
			c2.setFill(Color.WHITE);
			c3.setFill(Color.GREEN);
		}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 150);
	primaryStage.setTitle("Exercise_16_03"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 20
Source File: TSpectrumSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
private ToolBar getTopToolBar() {
    ToolBar toolBar = new ToolBar();
    ToggleGroup radioGroup = new ToggleGroup();

    RadioButton bbqButton1 = new RadioButton("LHC BBQ spectrum");
    bbqButton1.setSelected(true);
    bbqButton1.setToggleGroup(radioGroup);
    toolBar.getItems().add(bbqButton1);
    bbqButton1.selectedProperty().addListener((ch, o, n) -> {
        if (Boolean.FALSE.equals(n)) {
            return;
        }
        demoDataSet.set(readDemoData(SOURCE1));
    });

    RadioButton bbqButton2 = new RadioButton("CPS BBQ spectrum");
    bbqButton2.setToggleGroup(radioGroup);
    toolBar.getItems().add(bbqButton2);
    bbqButton2.selectedProperty().addListener((ch, o, n) -> {
        if (Boolean.FALSE.equals(n)) {
            return;
        }

        demoDataSet.set(new MathDataSet(null, DataSetMath::magnitudeSpectrumDecibel, readDemoData(SOURCE2)));
    });

    RadioButton bbqButton3 = new RadioButton("LHC injection BBQ spectrum");
    bbqButton3.setToggleGroup(radioGroup);
    toolBar.getItems().add(bbqButton3);
    bbqButton3.selectedProperty().addListener((ch, o, n) -> {
        if (Boolean.FALSE.equals(n)) {
            return;
        }
        demoDataSet.set(new MathDataSet(null, DataSetMath::magnitudeSpectrumDecibel, readDemoData(SOURCE3)));
    });

    RadioButton synthButton = new RadioButton("synthetic spectrum");
    Slider slider = new Slider(10, 8192, 512);
    slider.setBlockIncrement(10);
    slider.valueProperty().addListener((ch, o, n) -> {
        if (synthButton.isSelected()) {
            demoDataSet.set(generateDemoSineWaveData(n.intValue()));
        }
    });

    synthButton.setToggleGroup(radioGroup);
    toolBar.getItems().add(synthButton);
    synthButton.selectedProperty().addListener((ch, o, n) -> {
        if (Boolean.FALSE.equals(n)) {
            return;
        }
        demoDataSet.set(generateDemoSineWaveData((int) slider.getValue()));
    });
    toolBar.getItems().add(slider);

    return toolBar;
}