javafx.scene.control.ColorPicker Java Examples
The following examples show how to use
javafx.scene.control.ColorPicker.
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: ColorTableCell.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
public ColorTableCell(TableColumn<T, Color> column) { colorPicker = new ColorPicker(); colorPicker.editableProperty().bind(column.editableProperty()); colorPicker.disableProperty().bind(column.editableProperty().not()); colorPicker.setOnShowing(event -> { final TableView<T> tableView = getTableView(); tableView.getSelectionModel().select(getTableRow().getIndex()); tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column); }); colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> { if (isEditing()) { commitEdit(newValue); } }); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); }
Example #2
Source File: RFXColorPickerTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void getText() { ColorPicker colorPicker = (ColorPicker) getPrimaryStage().getScene().getRoot().lookup(".color-picker"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); Platform.runLater(() -> { RFXColorPicker rfxColorPicker = new RFXColorPicker(colorPicker, null, null, lr); colorPicker.setValue(Color.rgb(234, 156, 44)); rfxColorPicker.focusLost(null); text.add(rfxColorPicker._getText()); }); new Wait("Waiting for color picker text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("#ea9c2c", text.get(0)); }
Example #3
Source File: PlotConfigDialog.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private int addTraceContent(final GridPane layout, int row, final Trace<?> trace) { Label label = new Label(trace.getName()); layout.add(label, 5, row); final ColorPicker color = createPicker(trace.getColor()); color.setOnAction(event -> { trace.setColor(color.getValue()); plot.requestUpdate(); }); layout.add(color, 6, row); final CheckBox visible = new CheckBox(Messages.PlotConfigVisible); visible.setSelected(trace.isVisible()); visible.setOnAction(event -> { trace.setVisible(visible.isSelected()); plot.requestUpdate(); }); layout.add(visible, 7, row++); return row; }
Example #4
Source File: ColorPropertyControl.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void createComponents(@NotNull HBox container) { super.createComponents(container); colorPicker = new ColorPicker(); colorPicker.prefWidthProperty() .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); FxControlUtils.onColorChange(colorPicker, this::updateValue); FxUtils.addClass(colorPicker, CssClasses.PROPERTY_CONTROL_COLOR_PICKER); FxUtils.addChild(container, colorPicker); }
Example #5
Source File: ColorPickerPreference.java From Quelea with GNU General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void initializeParts() { super.initializeParts(); node = new StackPane(); node.getStyleClass().add("simple-text-control"); colorPicker = new ColorPicker(initialValue); colorPicker.setMaxWidth(Double.MAX_VALUE); colorPicker.setOnAction(event -> { if (!field.valueProperty().getValue().equals(getColorString(colorPicker.getValue()))) field.valueProperty().setValue(getColorString(colorPicker.getValue())); }); field.valueProperty().setValue(getColorString(colorPicker.getValue())); }
Example #6
Source File: ColorTableCell.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public ColorTableCell(TableColumn<T, Color> column) { colorPicker = new ColorPicker(); colorPicker.editableProperty().bind(column.editableProperty()); colorPicker.disableProperty().bind(column.editableProperty().not()); colorPicker.setOnShowing(event -> { final TableView<T> tableView = getTableView(); tableView.getSelectionModel().select(getTableRow().getIndex()); tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column); }); colorPicker.valueProperty() .addListener((observable, oldValue, newValue) -> { commitEdit(newValue); }); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); }
Example #7
Source File: SimpleColorPickerControl.java From PreferencesFX with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void initializeParts() { super.initializeParts(); node = new StackPane(); node.getStyleClass().add("simple-text-control"); colorPicker = new ColorPicker(initialValue); colorPicker.setMaxWidth(Double.MAX_VALUE); colorPicker.setOnAction(event -> { if (!field.valueProperty().getValue().equals(colorPicker.getValue().toString())) { field.valueProperty().setValue(colorPicker.getValue().toString()); } }); field.valueProperty().setValue(colorPicker.getValue().toString()); fieldLabel = new Label(field.labelProperty().getValue()); }
Example #8
Source File: ColorPickerApp.java From oim-fx with MIT License | 6 votes |
public Parent createContent() { final ColorPicker colorPicker = new ColorPicker(Color.GREEN); final Label coloredText = new Label("Colors"); Font font = new Font(53); coloredText.setFont(font); final Button coloredButton = new Button("Colored Control"); Color c = colorPicker.getValue(); coloredText.setTextFill(c); coloredButton.setStyle(createRGBString(c)); colorPicker.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { Color newColor = colorPicker.getValue(); coloredText.setTextFill(newColor); coloredButton.setStyle(createRGBString(newColor)); } }); VBox outerVBox = new VBox(coloredText, coloredButton, colorPicker); outerVBox.setAlignment(Pos.CENTER); outerVBox.setSpacing(20); outerVBox.setMaxSize(VBox.USE_PREF_SIZE, VBox.USE_PREF_SIZE); return outerVBox; }
Example #9
Source File: FontSpecsComponent.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public FontSpecsComponent() { fontLabel = new Label(); fontSelectButton = new Button("Select font"); fontSelectButton.setOnAction(e -> { var dialog = new FontSelectorDialog(currentFont); var result = dialog.showAndWait(); if (result.isPresent()) setFont(result.get()); }); colorPicker = new ColorPicker(Color.BLACK); getChildren().addAll(fontLabel, fontSelectButton, colorPicker); }
Example #10
Source File: DemoUtil.java From RadialFx with GNU Lesser General Public License v3.0 | 6 votes |
public void addColorControl(final String title, final ObjectProperty<Paint> paintProperty) { final ColorPicker colorPicker = ColorPickerBuilder.create() .value((Color) paintProperty.get()).build(); paintProperty.bind(colorPicker.valueProperty()); final VBox box = new VBox(); final Text titleText = new Text(title); titleText.textProperty().bind(new StringBinding() { { super.bind(colorPicker.valueProperty()); } @Override protected String computeValue() { return title + " : " + colorPicker.getValue().toString(); } }); box.getChildren().addAll(titleText, colorPicker); getChildren().add(box); }
Example #11
Source File: JFXColorPickerSkin.java From JFoenix with Apache License 2.0 | 5 votes |
private void initColor() { final ColorPicker colorPicker = (ColorPicker) getSkinnable(); Color color = colorPicker.getValue(); Color circleColor = color == null ? Color.WHITE : color; // update picker box color colorBox.setBackground(new Background(new BackgroundFill(circleColor, new CornerRadii(3), Insets.EMPTY))); // update label color displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf( "rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)")); if (colorLabelVisible.get()) { displayNode.setText(JFXNodeUtils.colorToHex(circleColor)); } else { displayNode.setText(""); } }
Example #12
Source File: JFXColorPickerSkin.java From JFoenix with Apache License 2.0 | 5 votes |
private void updateColor() { final ColorPicker colorPicker = (ColorPicker) getSkinnable(); Color color = colorPicker.getValue(); Color circleColor = color == null ? Color.WHITE : color; // update picker box color if (((JFXColorPicker) getSkinnable()).isDisableAnimation()) { JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, circleColor); } else { Circle colorCircle = new Circle(); colorCircle.setFill(circleColor); colorCircle.setManaged(false); colorCircle.setLayoutX(colorBox.getWidth() / 4); colorCircle.setLayoutY(colorBox.getHeight() / 2); colorBox.getChildren().add(colorCircle); Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(colorCircle.radiusProperty(), 200, Interpolator.EASE_BOTH))); animateColor.setOnFinished((finish) -> { JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill()); colorBox.getChildren().remove(colorCircle); }); animateColor.play(); } // update label color displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf( "rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)")); if (colorLabelVisible.get()) { displayNode.setText(JFXNodeUtils.colorToHex(circleColor)); } else { displayNode.setText(""); } }
Example #13
Source File: JFXColorPickerBehavior.java From JFoenix with Apache License 2.0 | 5 votes |
/************************************************************************** * * * Mouse Events handling (when losing focus) * * * *************************************************************************/ @Override public void onAutoHide() { ColorPicker colorPicker = (ColorPicker) getControl(); JFXColorPickerSkin cpSkin = (JFXColorPickerSkin) colorPicker.getSkin(); cpSkin.syncWithAutoUpdate(); if (!colorPicker.isShowing()) { super.onAutoHide(); } }
Example #14
Source File: PropertyPanel.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Helper for CellValueFactory to create the picker for a color * Cell value factory should then use picker.setOnAction() to * handle edits. * @param color * @return */ static ColorPicker createPicker(final Color color) { final ColorPicker picker = new ColorPicker(color); picker.getCustomColors().setAll(RGBFactory.PALETTE); picker.setStyle("-fx-color-label-visible: false ;"); return picker; }
Example #15
Source File: BezierOffsetSnippet.java From gef with Eclipse Public License 2.0 | 5 votes |
public HBox ToggleButtonColor(String text, ObjectProperty<Color> colorProperty, BooleanProperty toggledProperty, boolean isToggled) { HBox hbox = new HBox(); ToggleButton toggleButton = new ToggleButton(text); toggleButton.setOnAction((ae) -> { refreshAll(); }); ColorPicker colorPicker = new ColorPicker(colorProperty.get()); colorProperty.bind(colorPicker.valueProperty()); hbox.getChildren().addAll(toggleButton, colorPicker); toggledProperty.bind(toggleButton.selectedProperty()); toggleButton.setSelected(isToggled); return hbox; }
Example #16
Source File: ColorChooser.java From LogFX with GNU General Public License v3.0 | 5 votes |
public ColorChooser( String initialColor, String tooltipText ) { this.colorPicker = new ColorPicker(); colorPicker.setTooltip( new Tooltip( tooltipText ) ); box = new HBox( 2 ); try { colorPicker.setValue( Color.valueOf( initialColor ) ); } catch ( IllegalArgumentException e ) { log.warn( "Unable to set color picker's initial color to invalid color: {}", initialColor ); } manualEditor = new ManualEditor( colorPicker.getValue(), tooltipText, colorPicker::setValue ); addListener( ( observable -> { // only update the text if the currently visible control is the color picker if ( box.getChildren().get( 0 ) == colorPicker ) { manualEditor.colorField.setText( colorPicker.getValue().toString() ); } } ) ); ToggleButton editButton = AwesomeIcons.createToggleButton( AwesomeIcons.PENCIL, 10 ); box.getChildren().addAll( colorPicker, editButton ); editButton.setOnAction( event -> { ObservableList<Node> children = box.getChildren(); if ( children.get( 0 ) == manualEditor ) { box.getChildren().set( 0, colorPicker ); } else { box.getChildren().set( 0, manualEditor ); manualEditor.colorField.requestFocus(); manualEditor.colorField.selectAll(); } } ); }
Example #17
Source File: ColorPropertyEditorControl.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FxThread protected void createComponents() { super.createComponents(); colorPicker = new ColorPicker(); colorPicker.prefWidthProperty() .bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); FxControlUtils.onColorChange(colorPicker, this::change); FxUtils.addClass(colorPicker, CssClasses.PROPERTY_CONTROL_COLOR_PICKER); FxUtils.addChild(this, colorPicker); }
Example #18
Source File: ParetoTest.java From charts with Apache License 2.0 | 5 votes |
public void updateBarColorPicker(){ menu.getChildren().removeAll(barColors); barColors.clear(); for(ParetoBar bar: paretoPanel.getParetoModel().getData()){ ColorPicker temp = new ColorPicker(bar.getFillColor()); barColors.add(temp); bar.fillColorProperty().bindBidirectional(temp.valueProperty()); } menu.getChildren().addAll(barColors); }
Example #19
Source File: ParetoTest.java From charts with Apache License 2.0 | 5 votes |
private void initParts(){ paretoPanel = new ParetoPanel(createTestData1()); circleColor = new ColorPicker(); circleColor.setValue(Color.BLUE); graphColor = new ColorPicker(); graphColor.setValue(Color.BLACK); fontColor = new ColorPicker(); fontColor.setValue(Color.BLACK); smoothing = new CheckBox("Smoothing"); realColor = new CheckBox("AutoSubColor"); showSubBars = new CheckBox("ShowSubBars"); singeSubBarCentered = new CheckBox("SingleSubBarCenterd"); circleSize = new Slider(1,60,20); valueHeight = new Slider(0,80,20); textHeight = new Slider(0,80,40); barSpacing = new Slider(1,50,5); pathHeight = new Slider(0,80,65); barColors = new ArrayList<>(); backButton = new Button("Back to last layer"); exampeColorTheme = createRandomColorTheme(20); paretoPanel.addColorTheme("example",exampeColorTheme); colorTheme = new ComboBox<>(); colorTheme.getItems().addAll(paretoPanel.getColorThemeKeys()); mainBox = new HBox(); menu = new VBox(); pane = new Pane(); }
Example #20
Source File: ShapePropertyCustomiser.java From latexdraw with GNU General Public License v3.0 | 5 votes |
protected void addColorPropBinding(final @NotNull ColorPicker picker, final @NotNull ShapeProperties<Color> prop) { final var basePickerBinder = colorPickerBinder() .on(picker) .end(() -> update()); basePickerBinder .toProduce(i -> createModShProp(ShapeFactory.INST.createColorFX(i.getWidget().getValue()), prop)) .when(handActiv) .bind(); basePickerBinder .toProduce(i -> firstPropPen(ShapeFactory.INST.createColorFX(i.getWidget().getValue()), prop)) .when(pencilActiv) .bind(); }
Example #21
Source File: PlotConfigDialog.java From phoebus with Eclipse Public License 1.0 | 5 votes |
static ColorPicker createPicker(final Color color) { final ColorPicker picker = new ColorPicker(color); picker.getCustomColors().setAll(RGBFactory.PALETTE); picker.setStyle("-fx-color-label-visible: false ;"); return picker; }
Example #22
Source File: ColorMapDialog.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @param section Segment of the color map * @return ColorPicker that updates this segment in #color_sections */ private ColorPicker createColorPicker(final ColorSection section) { final Color color = section.color; final int index = color_sections.indexOf(section); if (index < 0) throw new IllegalArgumentException("Cannot locate color section " + section); final ColorPicker picker = new ColorPicker(color); picker.setOnAction(event -> { color_sections.set(index, new ColorSection(section.value, picker.getValue())); updateMapFromSections(); }); return picker; }
Example #23
Source File: ColorParameter.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public ColorPicker createEditingComponent() { ColorPicker colorComponent = new ColorPicker(value); // colorComponent.setBorder(BorderFactory.createCompoundBorder(colorComponent.getBorder(), // BorderFactory.createEmptyBorder(0, 4, 0, 0))); return colorComponent; }
Example #24
Source File: ImageBackground.java From Quelea with GNU General Public License v3.0 | 5 votes |
@Override public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundImgLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) { backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("image.theme.label")); backgroundImgLocation.setText(imageName); backgroundColorPicker.setValue(Color.BLACK); backgroundColorPicker.fireEvent(new ActionEvent()); backgroundVidLocation.clear(); vidHueSlider.setValue(0); vidStretchCheckbox.setSelected(false); }
Example #25
Source File: VideoBackground.java From Quelea with GNU General Public License v3.0 | 5 votes |
@Override public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundImgLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) { backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("video.theme.label")); backgroundVidLocation.setText(getVideoFile().getName()); vidHueSlider.setValue(hue); vidStretchCheckbox.setSelected(stretch); backgroundColorPicker.setValue(Color.BLACK); backgroundColorPicker.fireEvent(new ActionEvent()); backgroundImgLocation.clear(); }
Example #26
Source File: RFXColorPickerTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void colorChooserWithColorName() { ColorPicker colorPicker = (ColorPicker) getPrimaryStage().getScene().getRoot().lookup(".color-picker"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { RFXColorPicker rfxColorPicker = new RFXColorPicker(colorPicker, null, null, lr); colorPicker.setValue(Color.RED); rfxColorPicker.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("#ff0000", recording.getParameters()[0]); }
Example #27
Source File: JavaFXElementFactory.java From marathonv5 with Apache License 2.0 | 5 votes |
public static void reset() { add(Node.class, JavaFXElement.class); add(TextInputControl.class, JavaFXTextInputControlElement.class); add(HTMLEditor.class, JavaFXHTMLEditor.class); add(CheckBox.class, JavaFXCheckBoxElement.class); add(ToggleButton.class, JavaFXToggleButtonElement.class); add(Slider.class, JavaFXSliderElement.class); add(Spinner.class, JavaFXSpinnerElement.class); add(SplitPane.class, JavaFXSplitPaneElement.class); add(ProgressBar.class, JavaFXProgressBarElement.class); add(ChoiceBox.class, JavaFXChoiceBoxElement.class); add(ColorPicker.class, JavaFXColorPickerElement.class); add(ComboBox.class, JavaFXComboBoxElement.class); add(DatePicker.class, JavaFXDatePickerElement.class); add(TabPane.class, JavaFXTabPaneElement.class); add(ListView.class, JavaFXListViewElement.class); add(TreeView.class, JavaFXTreeViewElement.class); add(TableView.class, JavaFXTableViewElement.class); add(TreeTableView.class, JavaFXTreeTableViewElement.class); add(CheckBoxListCell.class, JavaFXCheckBoxListCellElement.class); add(ChoiceBoxListCell.class, JavaFXChoiceBoxCellElement.class); add(ComboBoxListCell.class, JavaFXComboBoxCellElement.class); add(CheckBoxTreeCell.class, JavaFXCheckBoxTreeCellElement.class); add(ChoiceBoxTreeCell.class, JavaFXChoiceBoxCellElement.class); add(ComboBoxTreeCell.class, JavaFXComboBoxCellElement.class); add(TableCell.class, JavaFXTableViewCellElement.class); add(CheckBoxTableCell.class, JavaFXCheckBoxTableCellElement.class); add(ChoiceBoxTableCell.class, JavaFXChoiceBoxCellElement.class); add(ComboBoxTableCell.class, JavaFXComboBoxCellElement.class); add(TreeTableCell.class, JavaFXTreeTableCellElement.class); add(CheckBoxTreeTableCell.class, JavaFXCheckBoxTreeTableCell.class); add(ChoiceBoxTreeTableCell.class, JavaFXChoiceBoxCellElement.class); add(ComboBoxTreeTableCell.class, JavaFXComboBoxCellElement.class); add(WebView.class, JavaFXWebViewElement.class); add(GenericStyledArea.GENERIC_STYLED_AREA_CLASS, RichTextFXGenericStyledAreaElement.class); }
Example #28
Source File: ColourBackground.java From Quelea with GNU General Public License v3.0 | 5 votes |
@Override public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) { backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("color.theme.label")); backgroundColorPicker.setValue(getColour()); backgroundLocation.clear(); backgroundVidLocation.clear(); vidHueSlider.setValue(0); vidStretchCheckbox.setSelected(false); }
Example #29
Source File: JavaFXColorPickerElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public boolean marathon_select(String value) { ColorPicker colorPicker = (ColorPicker) getComponent(); if (!value.equals("")) { try { colorPicker.setValue(Color.valueOf(value)); Event.fireEvent(colorPicker, new ActionEvent()); return true; } catch (Throwable t) { throw new IllegalArgumentException("Invalid value for '" + value + "' for color-picker '"); } } return false; }
Example #30
Source File: ColorTableCell.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public ColorTableCell(TableColumn<T, Color> column) { colorPicker = new ColorPicker(); colorPicker.editableProperty().bind(column.editableProperty()); colorPicker.disableProperty().bind(column.editableProperty().not()); colorPicker.setOnShowing(event -> { final TableView<T> tableView = getTableView(); tableView.getSelectionModel().select(getTableRow().getIndex()); tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column); }); colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> { commitEdit(newValue); }); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); }