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


Java Color.getRGB方法代码示例

本文整理汇总了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);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:21,代码来源:AnnotationSetsView.java

示例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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:DefaultTreeCellRenderer.java

示例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);
}
 
开发者ID:domisum,项目名称:ExZiff,代码行数:19,代码来源:TestLauncher.java

示例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);
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:19,代码来源:ChangeableHighlightPainter.java

示例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);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ConvertToByteIndexedTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ShortcutCellPanel.java

示例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+"");
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:10,代码来源:UISettings.java

示例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;
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:13,代码来源:ImageDisplay.java

示例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;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:9,代码来源:OurPDFWriter.java

示例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);
			}
		}
	}
}
 
开发者ID:Betalord,项目名称:BHBot,代码行数:19,代码来源:MarvinImage.java

示例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));
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:13,代码来源:Guitilities.java

示例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;
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:9,代码来源:RandoresNameAlgorithm.java

示例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;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:12,代码来源:OurPDFWriter.java

示例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
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:10,代码来源:OurSyntaxWidget.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:MetaData.java


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