本文整理汇总了Java中java.awt.Color.getRGB方法的典型用法代码示例。如果您正苦于以下问题:Java Color.getRGB方法的具体用法?Java Color.getRGB怎么用?Java Color.getRGB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Color
的用法示例。
在下文中一共展示了Color.getRGB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveColor
import java.awt.Color; //导入方法依赖的package包/类
protected void saveColor(String annotationSet, String annotationType, Color colour){
Map<String, String> colourMap = Gate.getUserConfig()
.getMap(AnnotationSetsView.class.getName()+".colours");
int rgb = colour.getRGB();
int alpha = colour.getAlpha();
int rgba = rgb | (alpha << 24);
String defaultValue = colourMap.get(annotationType);
String newValue = String.valueOf(rgba);
if (newValue.equals(defaultValue)) {
colourMap.remove(annotationSet+"."+annotationType);
}
else {
colourMap.put(annotationSet+"."+annotationType, newValue);
}
Gate.getUserConfig().put(
AnnotationSetsView.class.getName()+".colours", colourMap);
}
示例2: paintFocus
import java.awt.Color; //导入方法依赖的package包/类
private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
Color bsColor = getBorderSelectionColor();
if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
g.setColor(bsColor);
g.drawRect(x, y, w - 1, h - 1);
}
if (drawDashedFocusIndicator && notColor != null) {
if (treeBGColor != notColor) {
treeBGColor = notColor;
focusBGColor = new Color(~notColor.getRGB());
}
g.setColor(focusBGColor);
BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
}
}
示例3: generateInfluenceMapImage
import java.awt.Color; //导入方法依赖的package包/类
public static BufferedImage generateInfluenceMapImage(BedrockRegionMap bedrockRegionMap)
{
int[][] pixels = new int[bedrockRegionMap.getRegionIdMap().getHeight()][bedrockRegionMap.getRegionIdMap().getWidth()];
for(int y = 0; y < bedrockRegionMap.getRegionIdMap().getHeight(); y++)
{
for(int x = 0; x < bedrockRegionMap.getRegionIdMap().getWidth(); x++)
{
Color color = getColorAt(bedrockRegionMap, x, y);
pixels[y][x] = color.getRGB();
}
System.out.println("y: "+y);
}
return ImageUtil.getImageFromPixels(pixels);
}
示例4: writeObject
import java.awt.Color; //导入方法依赖的package包/类
/**
* Serializes this painter.
*
* @param s The stream to write to.
* @throws IOException If an IO error occurs.
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
int rgb = -1; // No Paint -> Use JTextComponent's selection color
if (paint!=null) {
// NOTE: We cheat and always serialize the Paint as a Color.
// This is (practically) always the case anyway.
Color c = (paint instanceof Color) ? ((Color)paint) :
SystemColor.textHighlight;
rgb = c.getRGB();
}
s.writeInt(rgb);
}
示例5: ConvertToByteIndexed
import java.awt.Color; //导入方法依赖的package包/类
public static void ConvertToByteIndexed(Color color, int srcType) {
// setup source image and graphics for conversion.
BufferedImage srcImage = new BufferedImage(width, height, srcType);
Graphics2D srcG2D = srcImage.createGraphics();
srcG2D.setColor(color);
srcG2D.fillRect(0, 0, width, height);
// setup destination image and graphics for conversion.
int dstType = BufferedImage.TYPE_BYTE_INDEXED;
BufferedImage dstImage = new BufferedImage(width, height, dstType);
Graphics2D dstG2D = (Graphics2D)dstImage.getGraphics();
// draw source image into Byte Indexed destination
dstG2D.drawImage(srcImage, 0, 0, null);
// draw into ARGB image to verify individual pixel value.
BufferedImage argbImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D argbG2D = (Graphics2D)argbImage.getGraphics();
argbG2D.drawImage(dstImage, 0, 0, null);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if (color.getRGB() != argbImage.getRGB(i, j)) {
throw new RuntimeException("Conversion from " +
TYPE_TABLE.get(srcType) + " to BYTE_INDEXED is not"
+ " done properly for " + color);
}
}
}
}
示例6: paintComponent
import java.awt.Color; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
Color c = getBackground();
if (c instanceof UIResource) {
// Nimbus LaF: if the color is a UIResource, it will paint
// the leftover area with default JPanel color which is gray, which looks ugly
super.setBackground(new Color(c.getRGB()));
}
super.paintComponent(g);
super.setBackground(c);
}
示例7: saveVisualizer
import java.awt.Color; //导入方法依赖的package包/类
private static void saveVisualizer(){
String out = "";
for(Color c : pianoColors){
out += c.getRGB()+" ";
}
prop.setProperty("pianocolors", out);
prop.setProperty("colorblindmode", colorBlindMode+"");
prop.setProperty("allgreen", allGreen+"");
}
示例8: TintFilter
import java.awt.Color; //导入方法依赖的package包/类
/**
* Constructs an image filter for tinting colors in an image.
* @param color the tint color
*/
public TintFilter(Color color)
{
canFilterIndexColorModel = true;
int rgb = color.getRGB();
tintR = (rgb >> 16) & 0xff;
tintG = (rgb >> 8) & 0xff;
tintB = rgb & 0xff;
}
示例9: setColor
import java.awt.Color; //导入方法依赖的package包/类
/** Changes the color for subsequent graphical drawing. */
public OurPDFWriter setColor(Color color) {
int rgb = color.getRGB() & 0xFFFFFF, r = (rgb>>16), g = (rgb>>8) & 0xFF, b = (rgb & 0xFF);
if (this.color == rgb) return this; else this.color = rgb; // no need to change
buf.writes(r/255.0).writes(g/255.0).writes(b/255.0).write("RG\n");
buf.writes(r/255.0).writes(g/255.0).writes(b/255.0).write("rg\n");
return this;
}
示例10: fillRect
import java.awt.Color; //导入方法依赖的package包/类
/**
* Fills a rectangle in the image.
* @param x rect's start position in x-axis
* @param y rect's start position in y-axis
* @param w rect's width
* @param h rect's height
* @param c rect's color
*/
public void fillRect(int x, int y, int w, int h, Color c){
int color = c.getRGB();
for(int i=x; i<x+w; i++){
for(int j=y; j<y+h; j++){
if(i < width && j < height){
setIntColor(i,j,color);
}
}
}
}
示例11: makeColorTransparent
import java.awt.Color; //导入方法依赖的package包/类
public static Image makeColorTransparent(Image image, final Color color) {
ImageFilter filter = new RGBImageFilter() {
public int markerRGB = color.getRGB()|0xFF000000;
@Override
public final int filterRGB(int x, int y, int rgb) {
if((rgb|0xFF000000)==markerRGB)
return 0x00FFFFFF & rgb;
else return rgb;
}
};
return Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(image.getSource(), filter));
}
示例12: name
import java.awt.Color; //导入方法依赖的package包/类
public static String name(Color color) {
Random random = new Random(color.getRGB());
String res = RandoresNameAlgorithm.name(random);
while (Randores.containsOffensiveWord(res.toLowerCase())) {
res = RandoresNameAlgorithm.name(random);
}
return res;
}
示例13: setColor
import java.awt.Color; //导入方法依赖的package包/类
/** Changes the color for subsequent graphical drawing. */
public OurPDFWriter setColor(Color color) {
int rgb = color.getRGB() & 0xFFFFFF, r = (rgb >> 16), g = (rgb >> 8) & 0xFF, b = (rgb & 0xFF);
if (this.color == rgb)
return this;
else
this.color = rgb; // no need to change
buf.writes(r / 255.0).writes(g / 255.0).writes(b / 255.0).write("RG\n");
buf.writes(r / 255.0).writes(g / 255.0).writes(b / 255.0).write("rg\n");
return this;
}
示例14: shade
import java.awt.Color; //导入方法依赖的package包/类
/** Shade the range of text from start (inclusive) to end (exclusive). */
void shade(Color color, int start, int end) {
int c = color.getRGB() & 0xFFFFFF;
if (painter == null || (painter.color.getRGB() & 0xFFFFFF) != c)
painter = new OurHighlighter(color);
try {
pane.getHighlighter().addHighlight(start, end, painter);
} catch (Throwable ex) {} // exception is okay
}
示例15: instantiate
import java.awt.Color; //导入方法依赖的package包/类
protected Expression instantiate(Object oldInstance, Encoder out) {
Color color = (Color) oldInstance;
Object[] args = new Object[] {color.getRGB()};
return new Expression(color, ColorUIResource.class, "new", args);
}