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


Java Color.getRed方法代码示例

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


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

示例1: getHtmlColor

import java.awt.Color; //导入方法依赖的package包/类
@NonNull
private static String getHtmlColor(@NullAllowed final Color _c, @NonNull final Color defaultColor) {
    Color c = _c == null ? defaultColor : _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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SnippetNodes.java

示例2: blockESPBox

import java.awt.Color; //导入方法依赖的package包/类
public static void blockESPBox(IBlockPos IBlockPos, Color c) {
	RenderUtils.fixDarkLight();
	GlStateManager.resetColor();
	float red = c.getRed(), green = c.getGreen(), blue = c.getBlue();
	double x = IBlockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
	double y = IBlockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
	double z = IBlockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
	GL11.glBlendFunc(770, 771);
	GL11.glEnable(3042);
	GL11.glLineWidth(1.0F);
	GL11.glDisable(3553);
	GL11.glDisable(2929);
	GL11.glDepthMask(false);
	GL11.glColor4f(red, green, blue, 0.15F);
	drawColorBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D), 0.0F, 1.0F, 0.0F, 0.15F);
	GL11.glColor4d(0.0D, 0.0D, 0.0D, 0.5D);
	drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D));
	GL11.glEnable(3553);
	GL11.glEnable(2929);
	GL11.glDepthMask(true);
	GL11.glDisable(3042);
	GlStateManager.resetColor();
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:24,代码来源:RenderUtils.java

示例3: makeImageBlackWhite

import java.awt.Color; //导入方法依赖的package包/类
private void makeImageBlackWhite(MarvinImage input, Color black, Color white) {
	int[] map = input.getIntColorArray();
	int white_rgb = white.getRGB();
	int black_rgb = black.getRGB();
	for (int i = 0; i < map.length; i++) {
		Color c = new Color(map[i], true);
		int r = c.getRed();
		int g = c.getGreen();
		int b = c.getBlue();
		int max = Misc.max(r, g, b);
		int min = Misc.min(r, g, b); 
		//int diff = (max-r) + (max-g) + (max-b);
		int diff = max - min;
		if (diff >= 90 || (diff==0 && max==254)) { // it's a number color
			map[i] = white_rgb;
		} else { // it's a blackish background
			map[i] = black_rgb;
		}
	}
	input.setIntColorArray(map);
	input.update(); // must be called! Or else things won't work...
}
 
开发者ID:Betalord,项目名称:BHBot,代码行数:23,代码来源:MainThread.java

示例4: shade

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Shades a color by some factor, where a higher factor results in a darker
 * shade.
 *
 * @param color
 *        The color.
 *
 * @param shadeFactor
 *        The factor.
 *
 *        Values should range from 0.0 to 1.0.
 *
 * @return
 *        The shaded color.
 *
 * @throws NullPointerException
 *         If the color is null.
 */
public static Color shade(final @NonNull Color color, double shadeFactor) {
    if (shadeFactor > 1.0) {
        shadeFactor = 1.0;
    }

    if (shadeFactor < 0.0) {
        shadeFactor = 0.0;
    }

    final int a = color.getAlpha();
    int r = color.getRed();
    int g = color.getGreen();
    int b = color.getBlue();

    r *= (1 - shadeFactor);
    g *= (1 - shadeFactor);
    b *= (1 - shadeFactor);

    return new Color(r, g, b, a);
}
 
开发者ID:Valkryst,项目名称:VTerminal,代码行数:39,代码来源:ColorFunctions.java

示例5: reAlpha

import java.awt.Color; //导入方法依赖的package包/类
public static int reAlpha(int color, float alpha) {
	Color c = new Color(color);
	float r = ((float) 1 / 255) * c.getRed();
	float g = ((float) 1 / 255) * c.getGreen();
	float b = ((float) 1 / 255) * c.getBlue();
	return new Color(r, g, b, alpha).getRGB();
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:8,代码来源:RenderUtils.java

示例6: brighter

import java.awt.Color; //导入方法依赖的package包/类
private static Color brighter(Color c) {
    int r = c.getRed();
    int g = c.getGreen();
    int b = c.getBlue();

    int i = (int)(1.0/(1.0-FACTOR));
    if ( r > 0 && r < i ) r = i;
    if ( g > 0 && g < i ) g = i;
    if ( b > 0 && b < i ) b = i;

    return new Color(Math.min((int)(r/FACTOR), 255),
                     Math.min((int)(g/FACTOR), 255),
                     Math.min((int)(b/FACTOR), 255));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:BarRenderer.java

示例7: getColorMarker

import java.awt.Color; //导入方法依赖的package包/类
/** Returns a colour specification for a given colour. */
private static Duo<String> getColorMarker(ColorType type, Color color) {
    String colorString;
    if (type == ColorType.RGB) {
        colorString =
            "\\color[RGB]{" + color.getRed() + "," + color.getGreen() + "," + color.getBlue()
                + "}";
    } else {
        colorString = colorMap.get(type);
    }
    return Duo.newDuo("{" + colorString, "}");
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:13,代码来源:TeXLineFormat.java

示例8: setColor

import java.awt.Color; //导入方法依赖的package包/类
public void setColor(Color color) {
    this.color = new Color(
            color.getRed(),
            color.getGreen(),
            color.getBlue(),
            (int) (this.opacity * 255));
}
 
开发者ID:mcdcorp,项目名称:opentest,代码行数:8,代码来源:Highlighter.java

示例9: getAdjustedColor

import java.awt.Color; //导入方法依赖的package包/类
/**
 * 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));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:CSSBorder.java

示例10: menuDeselected

import java.awt.Color; //导入方法依赖的package包/类
public void menuDeselected(MenuEvent e) {
	JMenu wm = (JMenu) e.getSource();

	// Cleans Windows if not visible
	if(wm.getText().matches("Windows") || wm.getText().matches("Window")) {
	wm.removeAll();
	System.gc();
	}

	/* When user first imports menu item the background is set to another color to catch user attention.
	 * After user interaction will set the background color back.
	 */
	if(wm.getText().matches("My Layer Sessions")) {
		JMenu selectSessionMenu = (JMenu) wm;
		try {
			JMenuItem selectSessionMenuChild = (JMenuItem) selectSessionMenu.getMenuComponent(0);
			Color currentColor = selectSessionMenu.getBackground();
			Color defaultColor = selectSessionMenuChild.getBackground();
			if(currentColor.getRed() + currentColor.getGreen() + currentColor.getBlue() == 586) {
				selectSessionMenu.setBackground(defaultColor);
				selectSessionMenu.revalidate();	
		}
		} catch (Exception ex) {
			//don't do anything if menu component and cannot be cast as a JMenuItem 
			//(eg if it is a separator bar)
		}
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:29,代码来源:MapApp.java

示例11: color2hex

import java.awt.Color; //导入方法依赖的package包/类
public static String color2hex(Color color) {
	return
		(color.getRed()<16?"0":"")+
		Integer.toHexString(color.getRed())+
		(color.getGreen()<16?"0":"")+
		Integer.toHexString(color.getGreen())+
		(color.getBlue()<16?"0":"")+
		Integer.toHexString(color.getBlue());
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:10,代码来源:Department.java

示例12: getColorValues

import java.awt.Color; //导入方法依赖的package包/类
public static float[] getColorValues(Color c) {
	return new float[] { c.getRed() / 255f, c.getGreen() / 255f, c.getGreen() / 255f };
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:4,代码来源:RenderUtils.java

示例13: alpha

import java.awt.Color; //导入方法依赖的package包/类
public static Color alpha(Color c, int a) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), Math.min(255, Math.max(0, a)));
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:4,代码来源:ColorTools.java

示例14: luminance

import java.awt.Color; //导入方法依赖的package包/类
private static int luminance(Color c) {
    return (299 * c.getRed() + 587 * c.getGreen() + 114 * c.getBlue()) / 1000;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:OutputOptions.java

示例15: onRun

import java.awt.Color; //导入方法依赖的package包/类
@Override
public void onRun() {
    if (image == null) {
        cancel();
        return;
    }
    Location location = getLocation();
    location.add(0, 2, 0);
    if (!lockedYaw) {
        yaw = location.getYaw();
        lockedYaw = true;
    }

    for (int y = 0; y < image.getHeight(); y++) {
        for (int x = 0; x < image.getWidth(); x++) {
            int rgb = image.getRGB(x, y);
            Color clr = (new Color(rgb));
            boolean prio = false;
            for (Color c : priority) {
                if (c.getRed() == clr.getRed() && c.getGreen() == clr.getGreen() && c.getBlue() == clr.getBlue()) {
                    prio = true;
                    break;
                }
            }
            if (!prio & Math.random() > density)
                continue;
            Vector v = new Vector((float) image.getWidth() / 2 - x, (float) image.getHeight() / 2 - y, 0).multiply(size);
            VectorUtils.rotateAroundAxisY(v, -yaw * MathUtils.degreesToRadians);
            if (enableRotation) {
                double rotX = 0;
                double rotY = 0;
                double rotZ = 0;
                switch (plane) {
                    case X:
                        rotX = angularVelocityX * currRotationStep;
                        break;
                    case Y:
                        rotY = angularVelocityY * currRotationStep;
                        break;
                    case Z:
                        rotZ = angularVelocityZ * currRotationStep;
                        break;
                    case XY:
                        rotX = angularVelocityX * currRotationStep;
                        rotY = angularVelocityY * currRotationStep;
                        break;
                    case XZ:
                        rotX = angularVelocityX * currRotationStep;
                        rotZ = angularVelocityZ * currRotationStep;
                        break;
                    case XYZ:
                        rotX = angularVelocityX * currRotationStep;
                        rotY = angularVelocityY * currRotationStep;
                        rotZ = angularVelocityZ * currRotationStep;
                        break;
                    case YZ:
                        rotY = angularVelocityY * currRotationStep;
                        rotZ = angularVelocityZ * currStep;
                        break;
                }
                VectorUtils.rotateVector(v, rotX, rotY, rotZ);
            }
            int r = clr.getRed();
            int g = clr.getGreen();
            int b = clr.getBlue();
            location.add(v);
            if (!(r == 123 && g == 123 && b == 123)) {
                display(particle, location, org.bukkit.Color.fromRGB(r, g, b));
            }
            location.subtract(v);
        }
    }
    currRotationStep++;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:75,代码来源:ColoredImageEffect.java


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