modules/controls/src/main/java/com/sun/javafx/scene/control/CustomColorDialog.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

*** 21,32 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.javafx.scene.control.skin; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.beans.property.*; import javafx.event.EventHandler; import javafx.scene.Scene; --- 21,36 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.javafx.scene.control; + import com.sun.javafx.scene.control.IntegerField; + import com.sun.javafx.scene.control.WebColorField; + import com.sun.javafx.scene.control.skin.IntegerFieldSkin; + import com.sun.javafx.scene.control.skin.WebColorFieldSkin; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.beans.property.*; import javafx.event.EventHandler; import javafx.scene.Scene;
*** 46,60 **** import javafx.geometry.Rectangle2D; import javafx.scene.input.KeyEvent; import javafx.stage.Screen; import javafx.stage.WindowEvent; - import static com.sun.javafx.scene.control.skin.ColorPickerSkin.getString; - /** * - * @author paru */ public class CustomColorDialog extends HBox { private final Stage dialog = new Stage(); private ColorRectPane colorRectPane; --- 50,61 ----
*** 70,80 **** private Scene customScene; public CustomColorDialog(Window owner) { getStyleClass().add("custom-color-dialog"); if (owner != null) dialog.initOwner(owner); ! dialog.setTitle(getString("customColorDialogTitle")); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initStyle(StageStyle.UTILITY); dialog.setResizable(false); colorRectPane = new ColorRectPane(); controlsPane = new ControlsPane(); --- 71,81 ---- private Scene customScene; public CustomColorDialog(Window owner) { getStyleClass().add("custom-color-dialog"); if (owner != null) dialog.initOwner(owner); ! dialog.setTitle(Properties.getColorPickerString("customColorDialogTitle")); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initStyle(StageStyle.UTILITY); dialog.setResizable(false); colorRectPane = new ColorRectPane(); controlsPane = new ControlsPane();
*** 106,128 **** public void setCurrentColor(Color currentColor) { this.currentColorProperty.set(currentColor); } ! Color getCurrentColor() { return currentColorProperty.get(); } ! ObjectProperty<Color> customColorProperty() { return customColorProperty; } ! void setCustomColor(Color color) { customColorProperty.set(color); } ! Color getCustomColor() { return customColorProperty.get(); } public Runnable getOnSave() { return onSave; --- 107,129 ---- public void setCurrentColor(Color currentColor) { this.currentColorProperty.set(currentColor); } ! public final Color getCurrentColor() { return currentColorProperty.get(); } ! public final ObjectProperty<Color> customColorProperty() { return customColorProperty; } ! public final void setCustomColor(Color color) { customColorProperty.set(color); } ! public final Color getCustomColor() { return customColorProperty.get(); } public Runnable getOnSave() { return onSave;
*** 150,160 **** public void setOnHidden(EventHandler<WindowEvent> onHidden) { dialog.setOnHidden(onHidden); } ! Stage getDialog() { return dialog; } public void show() { if (dialog.getOwner() != null) { --- 151,161 ---- public void setOnHidden(EventHandler<WindowEvent> onHidden) { dialog.setOnHidden(onHidden); } ! public Stage getDialog() { return dialog; } public void show() { if (dialog.getOwner() != null) {
*** 522,542 **** @Override protected Background computeValue() { return new Background(new BackgroundFill(customColorProperty.get(), CornerRadii.EMPTY, Insets.EMPTY)); } }); ! currentColorLabel = new Label(getString("currentColor")); ! newColorLabel = new Label(getString("newColor")); whiteBox = new Region(); whiteBox.getStyleClass().add("customcolor-controls-background"); ! hsbButton = new ToggleButton(getString("colorType.hsb")); hsbButton.getStyleClass().add("left-pill"); ! rgbButton = new ToggleButton(getString("colorType.rgb")); rgbButton.getStyleClass().add("center-pill"); ! webButton = new ToggleButton(getString("colorType.web")); webButton.getStyleClass().add("right-pill"); final ToggleGroup group = new ToggleGroup(); hBox = new HBox(); hBox.setAlignment(Pos.CENTER); --- 523,543 ---- @Override protected Background computeValue() { return new Background(new BackgroundFill(customColorProperty.get(), CornerRadii.EMPTY, Insets.EMPTY)); } }); ! currentColorLabel = new Label(Properties.getColorPickerString("currentColor")); ! newColorLabel = new Label(Properties.getColorPickerString("newColor")); whiteBox = new Region(); whiteBox.getStyleClass().add("customcolor-controls-background"); ! hsbButton = new ToggleButton(Properties.getColorPickerString("colorType.hsb")); hsbButton.getStyleClass().add("left-pill"); ! rgbButton = new ToggleButton(Properties.getColorPickerString("colorType.rgb")); rgbButton.getStyleClass().add("center-pill"); ! webButton = new ToggleButton(Properties.getColorPickerString("colorType.web")); webButton.getStyleClass().add("right-pill"); final ToggleGroup group = new ToggleGroup(); hBox = new HBox(); hBox.setAlignment(Pos.CENTER);
*** 630,640 **** settingsPane.add(sliders[i], 2, row); settingsPane.add(fields[i], 3, row); settingsPane.add(units[i], 4, row); } ! set(3, getString("opacity_colon"), 100, colorRectPane.alpha); hsbButton.setToggleGroup(group); rgbButton.setToggleGroup(group); webButton.setToggleGroup(group); group.selectedToggleProperty().addListener((observable, oldValue, newValue) -> { --- 631,641 ---- settingsPane.add(sliders[i], 2, row); settingsPane.add(fields[i], 3, row); settingsPane.add(units[i], 4, row); } ! set(3, Properties.getColorPickerString("opacity_colon"), 100, colorRectPane.alpha); hsbButton.setToggleGroup(group); rgbButton.setToggleGroup(group); webButton.setToggleGroup(group); group.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
*** 653,680 **** group.selectToggle(hsbButton); buttonBox = new HBox(); buttonBox.setId("buttons-hbox"); ! Button saveButton = new Button(getString("Save")); saveButton.setDefaultButton(true); saveButton.setOnAction(t -> { if (onSave != null) { onSave.run(); } dialog.hide(); }); ! Button useButton = new Button(getString("Use")); useButton.setOnAction(t -> { if (onUse != null) { onUse.run(); } dialog.hide(); }); ! Button cancelButton = new Button(getString("Cancel")); cancelButton.setCancelButton(true); cancelButton.setOnAction(e -> { customColorProperty.set(getCurrentColor()); if (onCancel != null) { onCancel.run(); --- 654,681 ---- group.selectToggle(hsbButton); buttonBox = new HBox(); buttonBox.setId("buttons-hbox"); ! Button saveButton = new Button(Properties.getColorPickerString("Save")); saveButton.setDefaultButton(true); saveButton.setOnAction(t -> { if (onSave != null) { onSave.run(); } dialog.hide(); }); ! Button useButton = new Button(Properties.getColorPickerString("Use")); useButton.setOnAction(t -> { if (onUse != null) { onUse.run(); } dialog.hide(); }); ! Button cancelButton = new Button(Properties.getColorPickerString("Cancel")); cancelButton.setCancelButton(true); cancelButton.setOnAction(e -> { customColorProperty.set(getCurrentColor()); if (onCancel != null) { onCancel.run();
*** 685,707 **** getChildren().addAll(currentAndNewColor, settingsPane, buttonBox); } private void showHSBSettings() { ! set(0, getString("hue_colon"), 360, colorRectPane.hue); ! set(1, getString("saturation_colon"), 100, colorRectPane.sat); ! set(2, getString("brightness_colon"), 100, colorRectPane.bright); } private void showRGBSettings() { ! set(0, getString("red_colon"), 255, colorRectPane.red); ! set(1, getString("green_colon"), 255, colorRectPane.green); ! set(2, getString("blue_colon"), 255, colorRectPane.blue); } private void showWebSettings() { ! labels[0].setText(getString("web_colon")); } private Property<Number>[] bindedProperties = new Property[4]; private void set(int row, String caption, int maxValue, Property<Number> prop) { --- 686,708 ---- getChildren().addAll(currentAndNewColor, settingsPane, buttonBox); } private void showHSBSettings() { ! set(0, Properties.getColorPickerString("hue_colon"), 360, colorRectPane.hue); ! set(1, Properties.getColorPickerString("saturation_colon"), 100, colorRectPane.sat); ! set(2, Properties.getColorPickerString("brightness_colon"), 100, colorRectPane.bright); } private void showRGBSettings() { ! set(0, Properties.getColorPickerString("red_colon"), 255, colorRectPane.red); ! set(1, Properties.getColorPickerString("green_colon"), 255, colorRectPane.green); ! set(2, Properties.getColorPickerString("blue_colon"), 255, colorRectPane.blue); } private void showWebSettings() { ! labels[0].setText(Properties.getColorPickerString("web_colon")); } private Property<Number>[] bindedProperties = new Property[4]; private void set(int row, String caption, int maxValue, Property<Number> prop) {