Java Code Examples for javafx.scene.paint.Color#getBrightness()

The following examples show how to use javafx.scene.paint.Color#getBrightness() . 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: AlarmAreaView.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void updateItem(final String item_name)
{
    final Label view_item = itemViewMap.get(item_name);
    if (view_item == null)
    {
        logger.log(Level.WARNING, "Cannot update unknown alarm area item " + item_name);
        return;
    }
    final SeverityLevel severity = areaFilter.getSeverity(item_name);
    final Color color = AlarmUI.getColor(severity);
    view_item.setBackground(new Background(new BackgroundFill(color, radii, Insets.EMPTY)));
    if (color.getBrightness() >= 0.5)
        view_item.setTextFill(Color.BLACK);
    else
        view_item.setTextFill(Color.WHITE);
}
 
Example 2
Source File: StyleManager.java    From PDF4Teachers with Apache License 2.0 5 votes vote down vote up
public static Color convertColor(Color color){
    if(DEFAULT_STYLE == jfxtras.styles.jmetro.Style.DARK){
        if(color.getBrightness() <= 0.4){
            return Color.WHITE;
        }else return color;
    }else{
        if(color.getBrightness() >= 0.9){
            return Color.BLACK;
        }else return color;
    }
}
 
Example 3
Source File: Helper.java    From OEE-Designer with MIT License 5 votes vote down vote up
public static final Color[] createColorVariations(final Color COLOR, final int NO_OF_COLORS) {
	int noOfColors = clamp(1, 12, NO_OF_COLORS);
	double step = 0.8 / noOfColors;
	double hue = COLOR.getHue();
	double brg = COLOR.getBrightness();
	Color[] colors = new Color[noOfColors];
	for (int i = 0; i < noOfColors; i++) {
		colors[i] = Color.hsb(hue, 0.2 + i * step, brg);
	}
	return colors;
}
 
Example 4
Source File: FxmlColor.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static int compareColor(Color o1, Color o2) {
    double diff = o2.getHue() - o1.getHue();
    if (diff > 0) {
        return 1;
    } else if (diff < 0) {
        return -1;
    } else {
        diff = o2.getSaturation() - o1.getSaturation();
        if (diff > 0) {
            return 1;
        } else if (diff < 0) {
            return -1;
        } else {
            diff = o2.getBrightness() - o1.getBrightness();
            if (diff > 0) {
                return 1;
            } else if (diff < 0) {
                return -1;
            } else {
                diff = o2.getOpacity() - o1.getOpacity();
                if (diff > 0) {
                    return 1;
                } else if (diff < 0) {
                    return -1;
                } else {
                    return 0;
                }
            }
        }
    }
}
 
Example 5
Source File: Helper.java    From charts with Apache License 2.0 5 votes vote down vote up
public static final Color[] getColorRangeMinMax(final Color COLOR, final int STEPS) {
    double hue            = COLOR.getHue();
    double saturation     = COLOR.getSaturation();
    double brightness     = COLOR.getBrightness();
    double saturationStep = saturation / STEPS;
    double brightnessStep = brightness / STEPS;
    double halfSteps      = STEPS / 2;
    Color fromColor       = COLOR.hsb(hue, saturation, clamp(0, 1, brightness + brightnessStep * halfSteps));
    Color toColor         = COLOR.hsb(hue, saturation, clamp(0, 1, brightness - brightnessStep * halfSteps));
    return new Color[] { fromColor, toColor };
}
 
Example 6
Source File: Helper.java    From charts with Apache License 2.0 5 votes vote down vote up
public static final List<Color> createColorVariations(final Color COLOR, final int NO_OF_COLORS) {
    int    noOfColors  = clamp(1, 5, NO_OF_COLORS);
    double step        = 0.8 / noOfColors;
    double hue         = COLOR.getHue();
    double brg         = COLOR.getBrightness();
    List<Color> colors = new ArrayList<>(noOfColors);
    for (int i = 0 ; i < noOfColors ; i++) { colors.add(Color.hsb(hue, 0.2 + i * step, brg)); }
    return colors;
}
 
Example 7
Source File: Helper.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public static final Color[] createColorVariations(final Color COLOR, final int NO_OF_COLORS) {
    int    noOfColors = clamp(1, 12, NO_OF_COLORS);
    double step       = 0.8 / noOfColors;
    double hue        = COLOR.getHue();
    double brg        = COLOR.getBrightness();
    Color[] colors = new Color[noOfColors];
    for (int i = 0 ; i < noOfColors ; i++) { colors[i] = Color.hsb(hue, 0.2 + i * step, brg); }
    return colors;
}
 
Example 8
Source File: Helper.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static final Color getContrastColor(final Color COLOR) {
	return COLOR.getBrightness() > 0.5 ? Color.BLACK : Color.WHITE;
}
 
Example 9
Source File: Helper.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public static final Color getContrastColor(final Color COLOR) {
    return COLOR.getBrightness() > 0.5 ? Color.BLACK : Color.WHITE;
}