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

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

源代码1 项目: jdk8u-jdk   文件: DefaultTreeCellRenderer.java
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);
    }
}
 
源代码2 项目: jdk8u-dev-jdk   文件: DefaultTreeCellRenderer.java
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 项目: MyBox   文件: ImageQuantization.java
@Override
public Color operateColor(Color color) {
    if (color.getRGB() == 0) {
        return color;
    }
    int red, green, blue;

    int v = color.getRed();
    v = v - (v % redMod) + redOffset;
    red = Math.min(Math.max(v, 0), 255);

    v = color.getGreen();
    v = v - (v % greenMod) + greenOffset;
    green = Math.min(Math.max(v, 0), 255);

    v = color.getBlue();
    v = v - (v % blueMod) + blueOffset;
    blue = Math.min(Math.max(v, 0), 255);

    Color mappedColor = new Color(red, green, blue);
    countColor(mappedColor);
    return mappedColor;

}
 
源代码4 项目: binnavi   文件: CFadingColorGenerator.java
/**
 * Returns the next color for a given object.
 *
 * @param object The object whose next color is determined.
 *
 * @return The next color of the object.
 */
public Color next(final T object) {
  if (!m_objects.containsKey(object)) {
    m_objects.put(object, Color.GREEN);

    return Color.GREEN;
  }

  final Color oldColor = m_objects.get(object);

  final int newLowest = Math.min((oldColor.getRGB() & 0xFF) + 0x40, 0xFF) & 0xFF;

  final int newMiddle = Math.min((oldColor.getRGB() & 0xFF0000) + 0x400000, 0xFF0000) & 0xFF0000;

  final Color newColor = new Color((oldColor.getRGB() & 0x00FF00) + newMiddle + newLowest);

  if (newColor == Color.WHITE) {
    m_objects.remove(object);
  } else {
    m_objects.put(object, newColor);
  }

  return newColor;
}
 
源代码5 项目: openjdk-jdk8u   文件: DefaultTreeCellRenderer.java
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);
    }
}
 
源代码6 项目: jdk8u-jdk   文件: ColorCustomizationTest.java
void check(Color c) {
    SwingUtilities.updateComponentTreeUI(label);
    label.paint(g);
    if (label.getBackground().getRGB() != c.getRGB()) {
        System.err.println("Color mismatch!");
        System.err.println("   found: " + label.getBackground());
        System.err.println("   expected: " + c);
        throw new RuntimeException("Test failed");
    }
}
 
源代码7 项目: gcs   文件: BarcodeInter25.java
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    String bCode = keepNumbers(code);
    if (generateChecksum)
        bCode += getChecksum(bCode);
    int len = bCode.length();
    int nn = (int)n;
    int fullWidth = len * (3 + 2 * nn) + (6 + nn );
    byte bars[] = getBarsInter25(bCode);
    boolean print = true;
    int ptr = 0;
    int height = (int)barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
        int w = (bars[k] == 0 ? 1 : nn);
        int c = g;
        if (print)
            c = f;
        print = !print;
        for (int j = 0; j < w; ++j)
            pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
        System.arraycopy(pix, 0, pix, k, fullWidth); 
    }
    Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
    
    return img;
}
 
源代码8 项目: marvinproject   文件: MarvinImage.java
/**
 * Draws a rectangle in the image. It�s useful for debugging purposes.
 * @param x		rect�s start position in x-axis
 * @param y		rect�s start positioj in y-axis
 * @param w		rect�s width
 * @param h		rect�s height
 * @param c		rect�s color
 */
public void drawRect(int x, int y, int w, int h, Color c){
	int color = c.getRGB();
	for(int i=x; i<x+w; i++){
		setIntColor(i, y, color);
		setIntColor(i, y+(h-1), color);
	}
	
	for(int i=y; i<y+h; i++){
		setIntColor(x, i, color);
		setIntColor(x+(w-1), i, color);
	}
}
 
源代码9 项目: hottub   文件: ColorCustomizationTest.java
void check(Color c) {
    SwingUtilities.updateComponentTreeUI(label);
    label.paint(g);
    if (label.getBackground().getRGB() != c.getRGB()) {
        System.err.println("Color mismatch!");
        System.err.println("   found: " + label.getBackground());
        System.err.println("   expected: " + c);
        throw new RuntimeException("Test failed");
    }
}
 
源代码10 项目: seaglass   文件: SeaGlassTableUI.java
/**
 * DOCUMENT ME!
 *
 * @param  c DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private Color unwrap(Color c) {
    if (c instanceof UIResource) {
        return new Color(c.getRGB());
    }

    return c;
}
 
源代码11 项目: openjdk-jdk8u   文件: SynthTableUI.java
private Color unwrap(Color c) {
    if (c instanceof UIResource) {
        return new Color(c.getRGB());
    }
    return c;
}
 
源代码12 项目: TencentKona-8   文件: SynthTableUI.java
private Color unwrap(Color c) {
    if (c instanceof UIResource) {
        return new Color(c.getRGB());
    }
    return c;
}
 
源代码13 项目: jdk8u-dev-jdk   文件: ColorUIResource.java
public ColorUIResource(Color c) {
    super(c.getRGB(), (c.getRGB() & 0xFF000000) != 0xFF000000);
}
 
源代码14 项目: amodeus   文件: VirtualNetworkLayer.java
private static Color halfAlpha(Color color) {
    int rgb = color.getRGB() & 0xffffff;
    int alpha = color.getAlpha() / 2;
    return new Color(rgb | (alpha << 24), true);
}
 
源代码15 项目: jdk8u-jdk   文件: MetaData.java
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);
}
 
源代码16 项目: openjdk-8-source   文件: SynthTableUI.java
private Color unwrap(Color c) {
    if (c instanceof UIResource) {
        return new Color(c.getRGB());
    }
    return c;
}
 
源代码17 项目: dragonwell8_jdk   文件: ColorUIResource.java
public ColorUIResource(Color c) {
    super(c.getRGB(), (c.getRGB() & 0xFF000000) != 0xFF000000);
}
 
源代码18 项目: opentest   文件: ImageUtil.java
/**
 * Compare two images and return an image that shows the differences and the
 * similarity between them, as a percent.
 */
public static ImageCompareResult compare(BufferedImage templateImage, BufferedImage imageToCompare, Double maxPercentColorDistance, Color ignoredPixelsColor) {
    try {
        if (maxPercentColorDistance == null) {
            maxPercentColorDistance = 0.15;
        }

        BufferedImage diffImage = new BufferedImage(
                Math.min(templateImage.getWidth(), imageToCompare.getWidth()),
                Math.min(templateImage.getHeight(), imageToCompare.getHeight()),
                BufferedImage.TYPE_3BYTE_BGR);

        double maxColorDistance = Math.sqrt(
                Math.pow(255, 2)
                + Math.pow(255, 2)
                + Math.pow(255, 2));

        long diffPixelCount = 0;
        int red = Color.RED.getRGB();
        int gray = Color.LIGHT_GRAY.getRGB();
        int reallyLightGray = Color.decode("#FAFAFA").getRGB();

        for (int x = 0; x < diffImage.getWidth(); x++) {
            for (int y = 0; y < diffImage.getHeight(); y++) {
                int color1 = templateImage.getRGB(x, y);
                int red1 = (color1 >> 16) & 0x000000FF;
                int green1 = (color1 >> 8) & 0x000000FF;
                int blue1 = (color1) & 0x000000FF;
 
                int color2 = imageToCompare.getRGB(x, y);
                int red2 = (color2 >> 16) & 0x000000FF;
                int green2 = (color2 >> 8) & 0x000000FF;
                int blue2 = (color2) & 0x000000FF;
                
                if (ignoredPixelsColor != null) {
                    int ignoredColor = ignoredPixelsColor.getRGB();
                    if (color1 == ignoredColor || color2 == ignoredColor) {
                        diffImage.setRGB(x, y, reallyLightGray);
                        continue;
                    }
                }

                double colorDistance = Math.sqrt(
                        Math.pow(red1 - red2, 2)
                        + Math.pow(green1 - green2, 2)
                        + Math.pow(blue1 - blue2, 2));
                double percentDistance = colorDistance / maxColorDistance;

                // Make new color of the pixel either red or light gray,
                // depending on how different the actual screen capture was
                // from the reference image.
                if (percentDistance >= maxPercentColorDistance) {
                    diffPixelCount++;
                    diffImage.setRGB(x, y, red);
                } else if (percentDistance > 0.01) {
                    diffImage.setRGB(x, y, gray);
                } else {
                    diffImage.setRGB(x, y, reallyLightGray);
                }
            }
        }

        double similarity = 1 - ((double) diffPixelCount / (diffImage.getWidth() * diffImage.getHeight()));
        return new ImageCompareResult(diffImage, similarity, diffPixelCount);
    } catch (Exception exc) {
        throw new RuntimeException(exc);
    }
}
 
源代码19 项目: Bytecoder   文件: ColorUIResource.java
/**
 * Constructs a {@code ColorUIResource}.
 * @param c the color
 */
public ColorUIResource(Color c) {
    super(c.getRGB(), (c.getRGB() & 0xFF000000) != 0xFF000000);
}
 
源代码20 项目: openjdk-jdk9   文件: ColorUIResource.java
/**
 * Constructs a {@code ColorUIResource}.
 * @param c the color
 */
public ColorUIResource(Color c) {
    super(c.getRGB(), (c.getRGB() & 0xFF000000) != 0xFF000000);
}