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

The following examples show how to use org.eclipse.swt.graphics.Color#getGreen() . 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
Source File: Gradient.java    From arx with 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 2
Source File: AnsiConsoleAttributes.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
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 3
Source File: Colors.java    From BiglyBT with 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 File: ConfigSectionInterfaceColorSWT.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
@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 5
Source File: TypeInfoViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 6
Source File: ColorManager.java    From birt with 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 7
Source File: ThermometerFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @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 File: ViewableModel.java    From erflute with 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 File: SharedProjectFileDecorator.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/** 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 10
Source File: GamaColors.java    From gama with 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 11
Source File: GamaColors.java    From gama with 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 12
Source File: GraphicUtils.java    From nebula with 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 13
Source File: ColorManager.java    From birt with 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 File: SWTUtils.java    From ECG-Viewer with 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 15
Source File: SWTUtils.java    From astor with 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 16
Source File: ZestContentViewer.java    From gef with 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 17
Source File: SWTUtils.java    From SIMVA-SoS with 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 18
Source File: SWTUtils.java    From buffer_bci with GNU General Public License v3.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 19
Source File: PaletteColorFactory.java    From ice with 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 20
Source File: SWTUtils.java    From astor with 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());
}