java.awt.Color#getBlue ( )源码实例Demo

下面列出了java.awt.Color#getBlue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MeteoInfo   文件: ColorUtil.java
/**
 * Create color from start and end color
 *
 * @param sColor Start color
 * @param eColor End color
 * @param p Proportion
 * @return Color
 */
public static Color createColor(Color sColor, Color eColor, float p) {
    int sR, sG, sB, eR, eG, eB, r, g, b;
    
    sR = sColor.getRed();
    sG = sColor.getGreen();
    sB = sColor.getBlue();
    eR = eColor.getRed();
    eG = eColor.getGreen();
    eB = eColor.getBlue();
    r = (int) (sR + (eR - sR) * p);
    g = (int) (sG + (eG - sG) * p);
    b = (int) (sB + (eB - sB) * p);        
    
    return new Color(r, g, b);
}
 
源代码2 项目: netbeans   文件: FixPlatform.java
@NonNull
private static String getHtmlColor(@NonNull final Color c) {
    final int r = c.getRed();
    final int g = c.getGreen();
    final int b = c.getBlue();
    final StringBuilder result = new StringBuilder();
    result.append ("#");        //NOI18N
    final String rs = Integer.toHexString (r);
    final String gs = Integer.toHexString (g);
    final String bs = Integer.toHexString (b);
    if (r < 0x10)
        result.append('0');
    result.append(rs);
    if (g < 0x10)
        result.append ('0');
    result.append(gs);
    if (b < 0x10)
        result.append ('0');
    result.append(bs);
    return result.toString();
}
 
源代码3 项目: birt   文件: SVGGraphics2D.java
/**
 * @returns the color definition in a string with the format: #RRGGBBAA:
 *          RRGGBB are the color components in hexa in the range 00..FF AA
 *          is the transparency value in hexa in the range 00..FF ex: Solid
 *          light gray : #777777
 */
protected String serializeToString( Color color )
{

	String r = Integer.toHexString( color.getRed( ) );
	if ( color.getRed( ) <= 0xF )
		r = "0" + r; //$NON-NLS-1$
	String g = Integer.toHexString( color.getGreen( ) );
	if ( color.getGreen( ) <= 0xF )
		g = "0" + g; //$NON-NLS-1$
	String b = Integer.toHexString( color.getBlue( ) );
	if ( color.getBlue( ) <= 0xF )
		b = "0" + b; //$NON-NLS-1$

	String ret = "#" + r + g + b; //$NON-NLS-1$
	return ret;
}
 
源代码4 项目: Pixelitor   文件: LayerBlendingModesTest.java
private static Color invert(Color in) {
    return new Color(
            255 - in.getRed(),
            255 - in.getGreen(),
            255 - in.getBlue(),
            in.getAlpha()
    );
}
 
源代码5 项目: HolographicDisplays   文件: ImageMessage.java
private double getDistance(Color c1, Color c2) {
    double rmean = (c1.getRed() + c2.getRed()) / 2.0;
    double r = c1.getRed() - c2.getRed();
    double g = c1.getGreen() - c2.getGreen();
    int b = c1.getBlue() - c2.getBlue();
    double weightR = 2 + rmean / 256.0;
    double weightG = 4.0;
    double weightB = 2 + (255 - rmean) / 256.0;
    return weightR * r * r + weightG * g * g + weightB * b * b;
}
 
源代码6 项目: PyramidShader   文件: GradientSlider.java
private static Color tween( Color c1, Color c2, float p) {
	if(p==0)
		return c1;
	if(p==1)
		return c2;
	
	return new Color(
			(int)(c1.getRed()*(1-p)+c2.getRed()*(p)),
			(int)(c1.getGreen()*(1-p)+c2.getGreen()*(p)),
			(int)(c1.getBlue()*(1-p)+c2.getBlue()*(p)),
			(int)(c1.getAlpha()*(1-p)+c2.getAlpha()*(p))
	);
}
 
源代码7 项目: JDKSourceCode1.8   文件: CSSBorder.java
/**
 * Return the color with brightness adjusted by the specified factor.
 *
 * The factor values are between 0.0 (no change) and 1.0 (turn into white).
 * Negative factor values decrease brigthness (ie, 1.0 turns into black).
 */
static Color getAdjustedColor(Color c, double factor) {
    double f = 1 - Math.min(Math.abs(factor), 1);
    double inc = (factor > 0 ? 255 * (1 - f) : 0);
    return new Color((int) (c.getRed() * f + inc),
                     (int) (c.getGreen() * f + inc),
                     (int) (c.getBlue() * f + inc));
}
 
源代码8 项目: hortonmachine   文件: ColorUtilities.java
/**
 * Convert a color to its hex representation.
 * 
 * @param color the color to convert.
 * @return the hex.
 */
public static String asHexWithAlpha( Color color ) {
    int r = color.getRed();
    int g = color.getGreen();
    int b = color.getBlue();
    int a = color.getAlpha();

    String hex = String.format("#%02x%02x%02x%02x", r, g, b, a);
    return hex;
}
 
源代码9 项目: openjdk-8-source   文件: CSSBorder.java
/**
 * Return the color with brightness adjusted by the specified factor.
 *
 * The factor values are between 0.0 (no change) and 1.0 (turn into white).
 * Negative factor values decrease brigthness (ie, 1.0 turns into black).
 */
static Color getAdjustedColor(Color c, double factor) {
    double f = 1 - Math.min(Math.abs(factor), 1);
    double inc = (factor > 0 ? 255 * (1 - f) : 0);
    return new Color((int) (c.getRed() * f + inc),
                     (int) (c.getGreen() * f + inc),
                     (int) (c.getBlue() * f + inc));
}
 
源代码10 项目: knopflerfish.org   文件: Util.java
static Color rgbInterpolate2(Color c1, Color c2, double k)
{

  if (c1 == null || c2 == null) {
    return Color.gray;
  }

  if (k == 0.0) {
    return c1;
  }
  if (k == 1.0) {
    return c2;
  }

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

  final int r = (int) (r1 + (double) (r2 - r1));
  final int g = (int) (g1 + (double) (g2 - g1));
  final int b = (int) (b1 + (double) (b2 - b1));

  final Color c = new Color(r, g, b);
  return c;
}
 
源代码11 项目: filthy-rich-clients   文件: ColorTintFilter.java
/**
 * <p>Creates a new color mixer filter. The specified color will be used
 * to tint the source image, with a mixing strength defined by
 * <code>mixValue</code>.</p>
 *
 * @param mixColor the solid color to mix with the source image
 * @param mixValue the strength of the mix, between 0.0 and 1.0; if the
 *   specified value lies outside this range, it is clamped
 * @throws IllegalArgumentException if <code>mixColor</code> is null
 */
public ColorTintFilter(Color mixColor, float mixValue) {
    if (mixColor == null) {
        throw new IllegalArgumentException("mixColor cannot be null");
    }

    this.mixColor = mixColor;
    if (mixValue < 0.0f) {
        mixValue = 0.0f;
    } else if (mixValue > 1.0f) {
        mixValue = 1.0f;
    }
    this.mixValue = mixValue;
    
    int mix_r = (int) (mixColor.getRed()   * mixValue);
    int mix_g = (int) (mixColor.getGreen() * mixValue);
    int mix_b = (int) (mixColor.getBlue()  * mixValue);
    
    // Since we use only lookup tables to apply the filter, this filter
    // could be implemented as a LookupOp.
    float factor = 1.0f - mixValue;
    preMultipliedRed   = new int[256];
    preMultipliedGreen = new int[256];
    preMultipliedBlue  = new int[256];

    for (int i = 0; i < 256; i++) {
        int value = (int) (i * factor);
        preMultipliedRed[i]   = value + mix_r;
        preMultipliedGreen[i] = value + mix_g;
        preMultipliedBlue[i]  = value + mix_b;
    }
}
 
源代码12 项目: openjdk-jdk9   文件: PaletteBuilder.java
protected int getBranchIndex(Color aColor, int aLevel) {
    if (aLevel > MAXLEVEL || aLevel < 0) {
        throw new IllegalArgumentException("Invalid octree node depth: " +
                                           aLevel);
    }

    int shift = MAXLEVEL - aLevel;
    int red_index = 0x1 & ((0xff & aColor.getRed()) >> shift);
    int green_index = 0x1 & ((0xff & aColor.getGreen()) >> shift);
    int blue_index = 0x1 & ((0xff & aColor.getBlue()) >> shift);
    int index = (red_index << 2) | (green_index << 1) | blue_index;
    return index;
}
 
源代码13 项目: gcs   文件: PDPageContentStream.java
/**
 * Set the stroking color using an AWT color. Conversion uses the default sRGB color space.
 *
 * @param color The color to set.
 * @throws IOException If an IO error occurs while writing to the stream.
 */
public void setStrokingColor(Color color) throws IOException
{
    float[] components = new float[] {
            color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f };
    PDColor pdColor = new PDColor(components, PDDeviceRGB.INSTANCE);
    setStrokingColor(pdColor);
}
 
源代码14 项目: cncgcodecontroller   文件: Tools.java
public static Color setAlpha(Color c,double a){
    return new Color(c.getRed(), c.getGreen(), c.getBlue(),(int)(255*a));
}
 
源代码15 项目: triplea   文件: TerritoryOverLayDrawable.java
TerritoryOverLayDrawable(
    final Color color, final String name, final int alpha, final Operation operation) {
  this.color = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
  territoryName = name;
  this.operation = operation;
}
 
源代码16 项目: chipster   文件: WaitGlassPane.java
@Override
public void setBackground(Color background) {
	super.setBackground(background);
	Color messageBackground = new Color(background.getRed(), background.getGreen(), background.getBlue(), MSG_ALPHA);
	messageLabel.setBackground(messageBackground);
}
 
源代码17 项目: netbeans   文件: DebuggingViewComponent.java
static int luminance(Color c) {
    return (299*c.getRed() + 587*c.getGreen() + 114*c.getBlue()) / 1000;
}
 
源代码18 项目: hottub   文件: XComponentPeer.java
static int[] getRGBvals(Color c) {

        int rgbvals[] = new int[3];

        rgbvals[0] = c.getRed();
        rgbvals[1] = c.getGreen();
        rgbvals[2] = c.getBlue();

        return rgbvals;
    }
 
源代码19 项目: jdk8u_jdk   文件: XComponentPeer.java
static int[] getRGBvals(Color c) {

        int rgbvals[] = new int[3];

        rgbvals[0] = c.getRed();
        rgbvals[1] = c.getGreen();
        rgbvals[2] = c.getBlue();

        return rgbvals;
    }
 
源代码20 项目: SPIM_Registration   文件: Color3f.java
/**
 * Sets the r,g,b values of this Color3f object to those of the specified
 * AWT Color object. No conversion is done on the color to compensate for
 * gamma correction.
 * 
 * @param color
 *            the AWT color to copy into this Color3f object
 * 
 * @since vecmath 1.2
 */
public final void set( Color color )
{
	x = (float) color.getRed() / 255.0f;
	y = (float) color.getGreen() / 255.0f;
	z = (float) color.getBlue() / 255.0f;
}