当前位置: 首页>>代码示例>>Java>>正文


Java Color.RGBtoHSB方法代码示例

本文整理汇总了Java中java.awt.Color.RGBtoHSB方法的典型用法代码示例。如果您正苦于以下问题:Java Color.RGBtoHSB方法的具体用法?Java Color.RGBtoHSB怎么用?Java Color.RGBtoHSB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Color的用法示例。


在下文中一共展示了Color.RGBtoHSB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setBrightness

import java.awt.Color; //导入方法依赖的package包/类
private void setBrightness(int brightness) {
    String[] colours = new String[keyCount];
    colours = getColoursFromVirtualKeyboard();
    float[] hsb = new float[3];
    Color colour;
    for (int i = 0; i < keyCount; i++) {
        colour = IOOperations.getColourFromHexString(colours[i]);
        Color.RGBtoHSB(colour.getRed(), colour.getGreen(), colour.getBlue(), hsb);
        if (brightness == 0) {
            hsb[2] = (float) 10 / 100;
        } else {
            hsb[2] = (float) brightness / 100;
        }
        colours[i] = String.format("%06X", (0xFFFFFF & Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])));
    }
    loadColours(colours);
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:18,代码来源:G610OrionUSQWERTY.java

示例2: transformColor

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Transforms the given color in regard to the scope. If the scope is {@code null} the given
 * color will be returned.
 *
 * @param color
 *            the color which should be transformed
 * @param scope
 *            the purpose of the the color
 * @return the transformed color
 */
private static Color transformColor(Color color, ColorScope scope) {
	if (color == null || scope == null) {
		return color;
	}
	float hsb[] = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
	float sFactor = 1;
	float vFactor = 1;
	switch (scope) {
		case BORDER:
			sFactor = 3f;
			vFactor = .6f;
			break;
		case CONTENT:
			sFactor = 1.5f;
			vFactor = .8f;
			break;
		case HOVER:
			vFactor = .95f;
			break;
		case BACKGROUND:
		default:
	}
	return Color.getHSBColor(hsb[0], Math.min(sFactor * hsb[1], 1f), vFactor * hsb[2]);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:AttributeGuiTools.java

示例3: test

import java.awt.Color; //导入方法依赖的package包/类
private static void test(Color[] colors) {
    JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label

    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(label);

    float[] hsb = new float[3];
    for (int i = 0; i < colors.length; i++) {
        Color color = colors[i];
        // Make sure sure that there wasn't a regression
        // in java.awt.Color and the conversion methods
        Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
        if (!color.equals(Color.getHSBColor(hsb[0], hsb[1], hsb[2]))) {
            throw new Error("color conversion is failed");
        }
        // 4193384 regression test
        if (!color.equals(new JColorChooser(color).getColor())) {
            throw new Error("constructor sets incorrect initial color");
        }
        // 4200976 regression test
        chooser.setColor(color);
        if (!color.equals(label.getForeground())) {
            throw new Error("a custom preview panel doesn't handle colors");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:Test4193384.java

示例4: isDarkTheme

import java.awt.Color; //导入方法依赖的package包/类
private static boolean isDarkTheme() {
    if(isDark != null) {
        return isDark;
    }
    // Based on tests with different LAFs and color combinations, a light
    // theme can be reliably detected by observing the brightness value of
    // the HSB Values of Table.background and Table.foreground
    //
    // Results from the test (Theme / Foreground / Background)
    // Gtk - Numix (light) / 0.2 / 0.97
    // Gtk - BlackMATE (dark) / 1.0 / 0.24
    // Gtk - Clearlooks (light) / 0.1 / 1.0
    // Gtk - ContrastHighInverse (dark) / 1.0 / 0.0
    // Gtk - DustSand (light) / 0.19 / 1.0
    // Gtk - TraditionalOkTest (light) / 0.0 / 0.74
    // Gtk - Menta (light) / 0.17 / 0.96
    // DarkNimbus (dark) / 0.9 / 0.19
    // DarkMetal (dark) / 0.87 / 0.19
    // CDE (light) / 0.0 / 0.76
    // Nimbus (light) / 0.0 / 1.0
    // Metall (light) / 0.2 / 1.0
    // Windows (light) / 0.0 / 1.0
    // Windows Classic (light) / 0.0 / 1.0
    // Windows HighContrast Black (dark) / 1.0 / 0
    Color foreground = UIManager.getColor("Table.foreground");
    Color background = UIManager.getColor("Table.background");
    float foreground_brightness = Color.RGBtoHSB(
            foreground.getRed(),
            foreground.getGreen(), 
            foreground.getBlue(), 
            null)[2];
    float background_brightness = Color.RGBtoHSB(
            background.getRed(),
            background.getGreen(), 
            background.getBlue(), 
            null)[2];
    isDark = background_brightness < foreground_brightness;
    return isDark;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:ColorHelper.java

示例5: reduceColorBrightness

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Returns the original color, just slightly less bright.
 *
 * @param color
 * @return
 */
public static Color reduceColorBrightness(Color color) {
	// lower brightness to 85% and saturation to 85%
	int r, g, b;
	float[] hsb = new float[3];
	r = color.getRed();
	g = color.getGreen();
	b = color.getBlue();
	Color.RGBtoHSB(r, g, b, hsb);
	// brightness
	hsb[2] *= 0.80f;
	// saturation
	hsb[1] *= 0.85f;
	return Color.getHSBColor(hsb[0], hsb[1], hsb[2]);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:ColorProvider.java

示例6: getAverageBrightness

import java.awt.Color; //导入方法依赖的package包/类
private int getAverageBrightness() {
    int brightness = 50;
    String[] colours = new String[keyCount];
    colours = convertStandardKeyColourMapToG910ColourMap(gKeyboard.getKeyColourMap());
    int sum = 0;
    float[] hsb = new float[3];
    Color colour;
    for (int i = 0; i < keyCount; i++) {
        colour = IOOperations.getColourFromHexString(colours[i]);
        Color.RGBtoHSB(colour.getRed(), colour.getGreen(), colour.getBlue(), hsb);
        sum += Math.round(100 * Double.parseDouble(new Float(hsb[2]).toString()));
    }
    brightness = sum / keyCount;
    return brightness;
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:16,代码来源:G910SparkUSQWERTY.java

示例7: getAverageBrightness

import java.awt.Color; //导入方法依赖的package包/类
private int getAverageBrightness() {
    int brightness = 50;
    String[] colours = new String[keyCount];
    colours = convertStandardKeyColourMapToG910UKQWERTYColourMap(gKeyboard.getKeyColourMap());
    int sum = 0;
    float[] hsb = new float[3];
    Color colour;
    for (int i = 0; i < keyCount; i++) {
        colour = IOOperations.getColourFromHexString(colours[i]);
        Color.RGBtoHSB(colour.getRed(), colour.getGreen(), colour.getBlue(), hsb);
        sum += Math.round(100 * Double.parseDouble(new Float(hsb[2]).toString()));
    }
    brightness = sum / keyCount;
    return brightness;
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:16,代码来源:G910SparkUKQWERTY.java

示例8: getAverageBrightness

import java.awt.Color; //导入方法依赖的package包/类
private int getAverageBrightness() {
    int brightness = 50;
    String[] colours = new String[keyCount];
    colours = convertStandardKeyColourMapToG810ColourMap(gKeyboard.getKeyColourMap());
    int sum = 0;
    float[] hsb = new float[3];
    Color colour;
    for (int i = 0; i < keyCount; i++) {
        colour = IOOperations.getColourFromHexString(colours[i]);
        Color.RGBtoHSB(colour.getRed(), colour.getGreen(), colour.getBlue(), hsb);
        sum += Math.round(100 * Double.parseDouble(new Float(hsb[2]).toString()));
    }
    brightness = sum / keyCount;
    return brightness;
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:16,代码来源:G810SpectrumUSQWERTY.java

示例9: getCodeBackgroundColor

import java.awt.Color; //导入方法依赖的package包/类
private String getCodeBackgroundColor() {
	Color tooltipBackground = UIManager.getColor("ToolTip.background");
	float[] hsb = new float[3];
	hsb = Color.RGBtoHSB(tooltipBackground.getRed(), tooltipBackground.getGreen(), tooltipBackground.getBlue(), hsb);
	hsb[2] = hsb[2] * 0.95f;
	Color codeBackground = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]));
	String hexColor = Integer.toHexString(codeBackground.getRGB() & 0xffffff);
	return hexColor;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:10,代码来源:GraphManager.java

示例10: deriveColor

import java.awt.Color; //导入方法依赖的package包/类
/** Derives color from specified with saturation multiplied by given ratio.
 */
static Color deriveColor (Color c, float saturationR) {
    Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbVals);
    hsbVals[1] = Math.min(1.0f, hsbVals[1] * saturationR);
    return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:EdgeWidget.java

示例11: brightnessContrast

import java.awt.Color; //导入方法依赖的package包/类
public static Color brightnessContrast(Color c) {
    float[] hsb = new float[3];
    Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsb);
    return new Color(Color.HSBtoRGB(hsb[0], hsb[1], ((hsb[2] > .5f) ? 0.0f : 1.0f)));
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:6,代码来源:ColorTools.java

示例12: getColorForValue

import java.awt.Color; //导入方法依赖的package包/类
@Override
public Color getColorForValue(double value) {
	if (Double.isNaN(value)) {
		return Color.LIGHT_GRAY;
	}

	// map value to [0,1]
	if (minValue == maxValue) {
		value = 0.5;
	} else if (value < minValue) {
		Color minColor;
		if (useGrayForOutliers) {
			minColor = Color.GRAY;
		} else {
			minColor = this.minColor;
		}
		if (alpha < 255) {
			minColor = DataStructureUtils.setColorAlpha(minColor, alpha);
		}
		return minColor;
	} else if (value > maxValue) {
		Color maxColor;
		if (useGrayForOutliers) {
			maxColor = Color.GRAY;
		} else {
			maxColor = this.maxColor;
		}
		if (alpha < 255) {
			maxColor = DataStructureUtils.setColorAlpha(maxColor, alpha);
		}
		return maxColor;
	} else if (logarithmic) {
		value = (Math.log(value) - Math.log(minValue)) / (Math.log(maxValue) - Math.log(minValue));
	} else {
		value = (value - minValue) / (maxValue - minValue);
	}

	Color MIN_LEGEND_COLOR = getMinColor();
	Color MAX_LEGEND_COLOR = getMaxColor();
	float[] minCol = Color.RGBtoHSB(MIN_LEGEND_COLOR.getRed(), MIN_LEGEND_COLOR.getGreen(), MIN_LEGEND_COLOR.getBlue(),
			null);
	float[] maxCol = Color.RGBtoHSB(MAX_LEGEND_COLOR.getRed(), MAX_LEGEND_COLOR.getGreen(), MAX_LEGEND_COLOR.getBlue(),
			null);
	double hColorDiff = maxCol[0] - minCol[0];
	double sColorDiff = maxCol[1] - minCol[1];
	double bColorDiff = maxCol[2] - minCol[2];

	Color color = new Color(Color.HSBtoRGB((float) (minCol[0] + hColorDiff * value), (float) (minCol[1] + value
			* sColorDiff), (float) (minCol[2] + value * bColorDiff)));

	if (alpha < 255) {
		color = DataStructureUtils.setColorAlpha(color, alpha);
	}
	return color;

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:57,代码来源:ContinuousColorProvider.java

示例13: paint

import java.awt.Color; //导入方法依赖的package包/类
@Override
public void paint( Object oa, Graphics2D g2, PanMouseAdaptor ma ) {
			
	ColorRGBA col = (ColorRGBA)oa;
	
	int r = (int)(col.r * 255), 
		g = (int)(col.g * 255), 
		b = (int)(col.b * 255);
	
	float[] hsb = Color.RGBtoHSB( r,g,b, null );
	
	g2.setColor(new Color(r,g,b) );
	
	g2.drawRect( ma.toX( hsb[0] * 10), ma.toY( hsb[2] * 10), ma.toZoom( 0.1 ), ma.toZoom( 0.1 )  );
	
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:17,代码来源:ColorRGBAPainter.java

示例14: compare

import java.awt.Color; //导入方法依赖的package包/类
@Override
public int compare(Color c1, Color c2) {

    int r1 = c1.getRed(), g1 = c1.getGreen(), b1 = c1.getBlue();
    int r2 = c2.getRed(), g2 = c2.getGreen(), b2 = c2.getBlue();

    if ((r1 == g1) && (g1 == b1)) {     // Si c1 est gris
        if ((r2 == g2) && (g2 == b2)) { // si c2 est gris aussi
            if (r1 > r2) {
                return 1;
            }
            if (r1 < r2) {
                return -1;
            }
            return 0;
        }
        return 1;
    }

    float[] hsb1 = new float[3];
    float[] hsb2 = new float[3];

    Color.RGBtoHSB(r1, g1, b1, hsb1);
    Color.RGBtoHSB(r2, g2, b2, hsb2);

    if (hsb1[0] > hsb2[0]) {
        return 1;
    }
    if (hsb1[0] < hsb2[0]) {
        return -1;
    }
    if (hsb1[2] > hsb2[2]) {
        return 1;
    }
    if (hsb1[2] < hsb2[2]) {
        return -1;
    }
    if (hsb1[1] > hsb2[1]) {
        return 1;
    }
    if (hsb1[1] < hsb2[1]) {
        return -1;
    }
    return 0;
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:46,代码来源:ColorTools.java

示例15: apply

import java.awt.Color; //导入方法依赖的package包/类
@Override
public int apply(int color) {
	float[] hsb = Color.RGBtoHSB((color >> 16) & 255, (color >> 8) & 255, color & 255, null);
	
	int idx = mode.getIdx();
	
	hsb[idx] = level*value + (1-level)*hsb[idx];
	
	return Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:11,代码来源:HSBFilter.java


注:本文中的java.awt.Color.RGBtoHSB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。