use of javafx.scene.paint.Color in project cryptomator by cryptomator.
the class PasswordStrengthUtil method getBackgroundWithStrengthColor.
public Background getBackgroundWithStrengthColor(Number score) {
Color c = this.getStrengthColor(score);
BackgroundFill fill = new BackgroundFill(c, CornerRadii.EMPTY, Insets.EMPTY);
return new Background(fill);
}
use of javafx.scene.paint.Color in project JFoenix by jfoenixadmin.
the class JFXRadioButtonSkin method updateAnimation.
private void updateAnimation() {
Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor();
Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor();
timeline = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(dot.scaleXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(dot.scaleYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(radio.strokeProperty(), unSelectedColor, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(200), new KeyValue(dot.scaleXProperty(), 0.6, Interpolator.EASE_BOTH), new KeyValue(dot.scaleYProperty(), 0.6, Interpolator.EASE_BOTH), new KeyValue(radio.strokeProperty(), selectedColor, Interpolator.EASE_BOTH)));
}
use of javafx.scene.paint.Color in project JFoenix by jfoenixadmin.
the class JFXRadioButtonSkin method initializeComponents.
private void initializeComponents(final double x, final double y, final double w, final double h) {
Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor();
Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor();
radio.setStroke(unSelectedColor);
rippler.setRipplerFill(getSkinnable().isSelected() ? selectedColor : unSelectedColor);
updateAnimation();
playAnimation();
}
use of javafx.scene.paint.Color in project fxexperience2 by EricCanull.
the class DerivationController method updateReverse.
private void updateReverse() {
Color desiredColor = desiredColorPicker.getColor();
final Color base = baseColorPicker.getColor();
// System.out.println("base = " + base);
double desiredBrightness = desiredColor.getBrightness();
// System.out.println("desiredBrightness = " + desiredBrightness);
// double desiredSaturation = desiredColor.getSaturation();
// System.out.println("desiredSaturation = " + desiredSaturation);
double derivation = 0, max = 1, min = -1;
Color derivedColor = Color.WHITE;
for (int i = 0; i < 100; i++) {
// System.out.println("---------- "+i+" ----------------");
// System.out.println("derivation = " + derivation);
// System.out.println("max = " + max);
// System.out.println("min = " + min);
derivedColor = ColorEncoder.deriveColor(base, derivation);
double derivedBrightness = derivedColor.getBrightness();
// System.out.println("derivedBrightness = " + derivedBrightness);
// double derivedSaturation = derivedColor.getSaturation();
// System.out.println("derivedSaturation = " + derivedSaturation);
// double saturationDifference = Math.abs(derivedSaturation-desiredSaturation);
// System.out.println("saturationDifference = " + saturationDifference);
double difference = Math.abs(derivedBrightness - desiredBrightness);
// System.out.println("brightness difference = " + difference);
if (difference < 0.0001) {
// GOOD ENOUGH
break;
} else if (min == 1 || max == -1) {
// TO DIFFERENT
break;
} else if (derivedBrightness > desiredBrightness) {
// TO BRIGHT
// System.out.println("NEED DARKER");
max = derivation;
derivation = derivation + ((min - derivation) / 2);
} else {
// TO DARK
// System.out.println("NEED BRIGHTER");
min = derivation;
derivation = derivation + ((max - derivation) / 2);
}
}
// System.out.println("\nFINAL \nderivation = " + derivation+"\n\n");
reverseDerivationLabel.setText(String.format("%3.3f%%", derivation));
reverseResultLabel.setText(getColorString(derivedColor));
reverseResultColor.setStyle("-fx-border-color: black; " + "-fx-background-color: " + getWebColor(derivedColor) + ";");
alert.setVisible(!getWebColor(desiredColor).equals(getWebColor(derivedColor)));
}
use of javafx.scene.paint.Color in project fxexperience2 by EricCanull.
the class ColorPickerControl method initialize.
/**
* Private
*/
private void initialize() {
final FXMLLoader loader = new FXMLLoader();
//NOI18N
loader.setLocation(ColorPickerControl.class.getResource("/fxml/FXMLColorPicker.fxml"));
loader.setController(this);
loader.setRoot(this);
try {
loader.load();
} catch (IOException ex) {
Logger.getLogger(ColorPickerControl.class.getName()).log(Level.SEVERE, null, ex);
}
assert hue_slider != null;
assert picker_region != null;
assert hue_textfield != null;
assert saturation_textfield != null;
assert brightness_textfield != null;
assert alpha_textfield != null;
assert red_textfield != null;
assert green_textfield != null;
assert blue_textfield != null;
assert alpha_slider != null;
// Make the grad for hue slider
hue_slider.setStyle(makeHueSliderCSS());
// Investigate why height + width listeners do not work
// Indeed, the picker_handle_stackpane bounds may still be null at this point
// UPDATE BELOW TO BE CALLED ONCE ONLY AT DISPLAY TIME
picker_region.boundsInParentProperty().addListener((ov, oldb, newb) -> {
picker_scrollpane.setHvalue(0.5);
picker_scrollpane.setVvalue(0.5);
// Init time only
final Paint paint = paintPickerController.getPaintProperty();
if (paint instanceof Color) {
updateUI((Color) paint);
} else if (paint instanceof LinearGradient || paint instanceof RadialGradient) {
final GradientPicker gradientPicker = paintPickerController.getGradientPicker();
final GradientPickerStop gradientPickerStop = gradientPicker.getSelectedStop();
// Update the color preview with the color of the selected stop
if (gradientPickerStop != null) {
updateUI(gradientPickerStop.getColor());
}
}
});
final ChangeListener<Boolean> onHSBFocusedChange = (ov, oldValue, newValue) -> {
if (newValue == false) {
// Update UI
final Color color = updateUI_OnHSBChange();
// Update model
setPaintProperty(color);
}
};
final ChangeListener<Boolean> onRGBFocusedChange = (ov, oldValue, newValue) -> {
if (newValue == false) {
// Update UI
final Color color = updateUI_OnRGBChange();
// Update model
setPaintProperty(color);
}
};
final ChangeListener<Boolean> onHexaFocusedChange = (ov, oldValue, newValue) -> {
if (newValue == false) {
try {
// Update UI
final Color color = updateUI_OnHexaChange();
// Update model
setPaintProperty(color);
} catch (IllegalArgumentException iae) {
handleHexaException();
}
}
};
// TextField ON FOCUS LOST event handler
hue_textfield.focusedProperty().addListener(onHSBFocusedChange);
saturation_textfield.focusedProperty().addListener(onHSBFocusedChange);
brightness_textfield.focusedProperty().addListener(onHSBFocusedChange);
alpha_textfield.focusedProperty().addListener(onHSBFocusedChange);
red_textfield.focusedProperty().addListener(onRGBFocusedChange);
green_textfield.focusedProperty().addListener(onRGBFocusedChange);
blue_textfield.focusedProperty().addListener(onRGBFocusedChange);
hexa_textfield.focusedProperty().addListener(onHexaFocusedChange);
// Slider ON VALUE CHANGE event handler
hue_slider.valueProperty().addListener((ov, oldValue, newValue) -> {
if (updating == true) {
return;
}
double hue = newValue.doubleValue();
// retrieve HSB TextFields values
double saturation = Double.valueOf(saturation_textfield.getText()) / 100.0;
double brightness = Double.valueOf(brightness_textfield.getText()) / 100.0;
double alpha = Double.valueOf(alpha_textfield.getText());
// Update UI
final Color color = updateUI(hue, saturation, brightness, alpha);
// Update model
setPaintProperty(color);
});
alpha_slider.valueProperty().addListener((ov, oldValue, newValue) -> {
if (updating == true) {
return;
}
double alpha = newValue.doubleValue();
// retrieve HSB TextFields values
double hue = Double.valueOf(hue_textfield.getText());
double saturation = Double.valueOf(saturation_textfield.getText()) / 100.0;
double brightness = Double.valueOf(brightness_textfield.getText()) / 100.0;
// Update UI
final Color color = updateUI(hue, saturation, brightness, alpha);
// Update model
setPaintProperty(color);
});
final ChangeListener<Boolean> liveUpdateListener = (ov, oldValue, newValue) -> paintPickerController.setLiveUpdate(newValue);
picker_region.pressedProperty().addListener(liveUpdateListener);
hue_slider.pressedProperty().addListener(liveUpdateListener);
alpha_slider.pressedProperty().addListener(liveUpdateListener);
}
Aggregations