Java Code Examples for org.eclipse.swt.graphics.Color#getGreen()

The following examples show how to use org.eclipse.swt.graphics.Color#getGreen() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static Color hiliteRgbColor(Color c) {
    if (c == null)
        return new Color(null, new RGB(0xff, 0xff, 0xff));
    int red = c.getRed() * 2;
    int green = c.getGreen() * 2;
    int blue = c.getBlue() * 2;

    if (red > 0xff)
        red = 0xff;
    if (green > 0xff)
        green = 0xff;
    if (blue > 0xff)
        blue = 0xff;

    return new Color(null, new RGB(red, green, blue)); // here
}
 
Example 2
@Override
public int[] getValue(ColorSwtParameter p) {
	String key = p.getParamID();
	Color existing;

	boolean is_override = COConfigurationManager.getStringParameter(
			key).length() > 0;
	if (!is_override) {
		return getDefaultValue(p);
	}

	// getSchemedColor will return white when it can't find a key starting with "config."
	// but we just checked that above, so we are ok
	existing = ColorCache.getSchemedColor(display, key);

	return existing == null ? null : new int[] {
		existing.getRed(),
		existing.getGreen(),
		existing.getBlue()
	};
}
 
Example 3
Source Project: BiglyBT   File: Colors.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static boolean
isBlackTextReadable(
	Color	forBG )
{
	if (forBG == null || forBG.isDisposed()) {
		return true;
	}

	int red = forBG.getRed();
	int green = forBG.getGreen();
	int blue = forBG.getBlue();

	double brightness = Math.sqrt(
			red * red * 0.299 + green * green * 0.587 + blue * blue * 0.114);
	
	return brightness >= 130;
}
 
Example 4
Source Project: arx   File: Gradient.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the color array
 * @param colors
 * @param steps
 * @return
 */
private final Color[] getGradient(int steps) {
            
    Color[] colors = new Color[] {  new Color(display, 0, 0, 255),
                                    new Color(display, 0, 255, 255),
                                    new Color(display, 0, 200, 0),
                                    new Color(display, 255, 255, 0),
                                    new Color(display, 255, 69, 0),
                                    new Color(display, 255, 0, 0) };

    java.awt.Color[] awtcolor = new java.awt.Color[colors.length];
    for (int i=0; i<colors.length; i++){
        Color color = colors[i];
        awtcolor[i] = new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue());
    }
    Color[] result = getGradient(awtcolor, steps);
    for (Color c : colors) {
        c.dispose();
    }
    return result;
}
 
Example 5
/** Returns null, if the image is not a RGB image with 8 Bit per color value */
private static Image tintImage(Image image, Color color) {
  ImageData data = image.getImageData();
  int red = color.getRed();
  int green = color.getGreen();
  int blue = color.getBlue();

  if (data.depth < 24 || !data.palette.isDirect) return null;

  int rs = data.palette.redShift;
  int gs = data.palette.greenShift;
  int bs = data.palette.blueShift;
  int rm = data.palette.redMask;
  int gm = data.palette.greenMask;
  int bm = data.palette.blueMask;

  if (rs < 0) rs = ~rs + 1;

  if (gs < 0) gs = ~gs + 1;

  if (bs < 0) bs = ~bs + 1;

  for (int x = 0; x < data.width; x++) {
    for (int y = 0; y < data.height; y++) {
      int p = data.getPixel(x, y);
      int r = (p & rm) >>> rs;
      int g = (p & gm) >>> gs;
      int b = (p & bm) >>> bs;
      r = (r * red) / 255;
      g = (g * green) / 255;
      b = (b * blue) / 255;
      data.setPixel(x, y, (r << rs) | (g << gs) | (b << bs));
    }
  }

  return new Image(image.getDevice(), data);
}
 
Example 6
private Color computeDashLineColor() {
	Color fg= fTable.getForeground();
	int fGray= (int)(0.3*fg.getRed() + 0.59*fg.getGreen() + 0.11*fg.getBlue());
	Color bg= fTable.getBackground();
	int bGray= (int)(0.3*bg.getRed() + 0.59*bg.getGreen() + 0.11*bg.getBlue());
	int gray= (int)((fGray + bGray) * 0.66);
	return new Color(fDisplay, gray, gray, gray);
}
 
Example 7
/**
 * @param fillColor the fillColor to set
 */
public void setFillColor(Color fillColor) {
	if(this.fillColor != null && this.fillColor.equals(fillColor))
		return;
	this.fillColor = fillColor;		
	int blue = 255 - fillColor.getBlue();
	int green = 255 - fillColor.getGreen();
	int red = fillColor.getRed();
	this.contrastFillColor = XYGraphMediaFactory.getInstance().getColor(
			new RGB(red, green, blue));
	repaint();
}
 
Example 8
Source Project: erflute   File: ViewableModel.java    License: Apache License 2.0 5 votes vote down vote up
public void setColor(Color color) {
    this.color = new int[3];
    this.color[0] = color.getRed();
    this.color[1] = color.getGreen();
    this.color[2] = color.getBlue();

    firePropertyChange(PROPERTY_CHANGE_COLOR, null, null);
}
 
Example 9
Source Project: birt   File: ColorManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new <code>Color</code> that is a darker version of the
 * specified color.
 * 
 * @param c
 *            the specified color value.
 */
public static Color darker( Color c )
{
	if ( c == null )
	{
		return null;
	}

	java.awt.Color color = new java.awt.Color( c.getRed( ),
			c.getGreen( ),
			c.getBlue( ) );

	color = color.darker( );
	return getColor( color.getRed( ), color.getGreen( ), color.getBlue( ) );
}
 
Example 10
Source Project: nebula   File: GraphicUtils.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public static Color createNewReverseColor(Color c)
{
    Color newColor = new Color(Display.getCurrent(), 255 - c.getRed(), 255 - c.getGreen(),
                               255 - c.getBlue());
    return newColor;
}
 
Example 11
Source Project: gama   File: GamaColors.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static java.awt.Color toAwtColor(final Color color) {
	return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue());
}
 
Example 12
Source Project: gama   File: GamaColors.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static GamaColor toGamaColor(final Color color) {
	return new GamaColor(color.getRed(), color.getGreen(), color.getBlue());
}
 
Example 13
Source Project: birt   File: ColorManager.java    License: Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates a new <code>Color</code> that is a darker version of this
 * <code>Color</code>.
 * <p>
 * This method applies an arbitrary scale factor to each of the three RGB
 * components of this <code>Color</code> to create a darker version of
 * this <code>Color</code>. Although <code>brighter</code> and
 * <code>darker</code> are inverse operations, the results of a series of
 * invocations of these two methods might be inconsistent because of
 * rounding errors.
 * 
 * @param origColor
 *            initial color.
 * @param darkColor
 *            the target dark color.
 * @return a new <code>Color</code> object that is a darker version of
 *         this <code>Color</code>.
 */
public static Color darker( Color origColor, Color darkColor )
{
	double redFactor = darkColor.getRed( ) / 255.0;
	double greenFactor = darkColor.getGreen( ) / 255.0;
	double blueFactor = darkColor.getBlue( ) / 255.0;

	return getColor( Math.max( (int) ( origColor.getRed( ) * redFactor ), 0 ),
			Math.max( (int) ( origColor.getGreen( ) * greenFactor ), 0 ),
			Math.max( (int) ( origColor.getBlue( ) * blueFactor ), 0 ) );
}
 
Example 14
Source Project: ice   File: PaletteColorFactory.java    License: Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Adds the specified color to the map of colors.
 * 
 * @param color
 *            The color to add.
 */
private void addColor(Color color) {
	int hex = color.getRed() << 16 | color.getGreen() << 8
			| color.getBlue();
	colorMap.put(hex, color);
}
 
Example 15
/**
 * Creates an awt color instance to match the rgb values
 * of the specified swt color.
 *
 * @param color The swt color to match.
 * @return an awt color abject.
 */
public static java.awt.Color toAwtColor(Color color) {
    return new java.awt.Color(color.getRed(), color.getGreen(),
            color.getBlue());
}
 
Example 16
Source Project: astor   File: SWTUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates an awt color instance to match the rgb values 
 * of the specified swt color.
 * 
 * @param color The swt color to match.
 * @return an awt color abject.
 */
public static java.awt.Color toAwtColor(Color color) {
    return new java.awt.Color(color.getRed(), color.getGreen(), 
            color.getBlue());
}
 
Example 17
/**
 * Creates an awt color instance to match the rgb values
 * of the specified swt color.
 *
 * @param color The swt color to match.
 * @return an awt color abject.
 */
public static java.awt.Color toAwtColor(Color color) {
    return new java.awt.Color(color.getRed(), color.getGreen(),
            color.getBlue());
}
 
Example 18
Source Project: gef   File: ZestContentViewer.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Converts the given {@link Color} into a CSS string:
 * <code>"rgb(red,green,blue)"</code>.
 *
 * @param color The {@link Color} to convert.
 * @return The corresponding CSS string.
 */
protected String toCssRgb(Color color) {
	return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
}
 
Example 19
Source Project: SIMVA-SoS   File: SWTUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates an awt color instance to match the rgb values
 * of the specified swt color.
 *
 * @param color The swt color to match.
 * @return an awt color abject.
 */
public static java.awt.Color toAwtColor(Color color) {
    return new java.awt.Color(color.getRed(), color.getGreen(),
            color.getBlue());
}
 
Example 20
Source Project: astor   File: SWTUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates an awt color instance to match the rgb values
 * of the specified swt color.
 *
 * @param color The swt color to match.
 * @return an awt color abject.
 */
public static java.awt.Color toAwtColor(Color color) {
    return new java.awt.Color(color.getRed(), color.getGreen(),
            color.getBlue());
}