Java Code Examples for org.eclipse.swt.graphics.Color#getRed()
The following examples show how to use
org.eclipse.swt.graphics.Color#getRed() .
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: AnsiConsoleAttributes.java From tesb-studio-se with Apache License 2.0 | 6 votes |
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
Source File: Colors.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
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 3
Source File: Tester.java From ColorMixer with MIT License | 5 votes |
private void setResultColor(Color colorA, Color colorB, Composite resultColorComposite, Label resultColor){ KMColor mix = new KMColor(new java.awt.Color(colorA.getRed(), colorA.getGreen(), colorA.getBlue())); mix.mix(new java.awt.Color(colorB.getRed(), colorB.getGreen(), colorB.getBlue())); java.awt.Color result = mix.getColor(); resultColorComposite.setBackground(new Color(Display.getCurrent(), result.getRed(), result.getGreen(), result.getBlue())); resultColor.setText("R: " + result.getRed() + ", G: " + result.getGreen() + ", B: " + result.getBlue()); }
Example 4
Source File: ColorManager.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new <code>Color</code> that is a brighter version of the * specified color. * * @param c * the specified color value. */ public static Color brighter( Color c ) { if ( c == null ) { return null; } java.awt.Color color = new java.awt.Color( c.getRed( ), c.getGreen( ), c.getBlue( ) ); color = color.brighter( ); return getColor( color.getRed( ), color.getGreen( ), color.getBlue( ) ); }
Example 5
Source File: SWTHelper.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Return a color that contrasts optimally to the given color * * @param col * an SWT Color * @return black if col was rather bright, white if col was rather dark. */ public static Color getContrast(final Color col){ double val = col.getRed() * 0.56 + col.getGreen() * 0.33 + col.getBlue() * 0.11; if (val <= 110) { return UiDesk.getDisplay().getSystemColor(SWT.COLOR_WHITE); } return UiDesk.getDisplay().getSystemColor(SWT.COLOR_BLACK); }
Example 6
Source File: ThermometerFigure.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @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 7
Source File: GamaColors.java From gama with GNU General Public License v3.0 | 4 votes |
public static int luminanceOf(final Color color) { return (int) (0.299 * color.getRed() * color.getRed() / 255 + 0.587 * color.getGreen() * color.getGreen() / 255 + 0.114 * color.getBlue() * color.getBlue() / 255); // http://alienryderflex.com/hsp.html }
Example 8
Source File: GamaColors.java From gama with GNU General Public License v3.0 | 4 votes |
public static java.awt.Color toAwtColor(final Color color) { return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue()); }
Example 9
Source File: RedmondShelfRenderer.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static Color createNewReverseColor(Color c) { Color newColor = new Color(Display.getCurrent(), 255 - c.getRed(), 255 - c.getGreen(), 255 - c.getBlue()); return newColor; }
Example 10
Source File: CSSShelfRenderer.java From nebula with Eclipse Public License 2.0 | 4 votes |
private 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 File: GraphicUtils.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static Color createNewReverseColor(Color c) { Color newColor = new Color(Display.getCurrent(), 255 - c.getRed(), 255 - c.getGreen(), 255 - c.getBlue()); return newColor; }
Example 12
Source File: GamaColors.java From gama with GNU General Public License v3.0 | 4 votes |
public static GamaColor toGamaColor(final Color color) { return new GamaColor(color.getRed(), color.getGreen(), color.getBlue()); }
Example 13
Source File: ColorManager.java From birt with Eclipse Public License 1.0 | 3 votes |
/** * 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: SetColorEffect.java From nebula with Eclipse Public License 2.0 | 3 votes |
/** * <p> * Create a new effect on object control. * </p> * * <p> * Source and destination color will not be disposed during or after the * animation. All other temporary colors created by this effect will be * disposed automatically. * </p> * * @param control * @param src * @param dest * @param lengthMilli * @param movement * @param onStop * can be a Runnable or null * @param onCancel * can be a Runnable or null */ public SetColorEffect(IColoredObject control, Color src, Color dest, long lengthMilli, IMovement movement, Runnable onStop, Runnable onCancel) { super(lengthMilli, movement, onStop, onCancel); this.src = src; this.dest = dest; this.diffR = dest.getRed() - src.getRed(); this.diffG = dest.getGreen() - src.getGreen(); this.diffB = dest.getBlue() - src.getBlue(); this.control = control; easingFunction.init(0, 1, (int) lengthMilli); }
Example 15
Source File: Utils.java From tracecompass with Eclipse Public License 2.0 | 3 votes |
/** * Get the resulting color from a mix of two existing ones for a given * display. * * @param display * The display device (which might affect the color conversion) * @param c1 * The first color * @param c2 * The second color * @param w1 * The gamma level for color 1 * @param w2 * The gamma level for color 2 * @return The resulting color */ public static Color mixColors(Device display, Color c1, Color c2, int w1, int w2) { return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed()) / (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen()) / (w1 + w2), (w1 * c1.getBlue() + w2 * c2.getBlue()) / (w1 + w2)); }
Example 16
Source File: SWTUtils.java From ECG-Viewer with GNU General Public License v2.0 | 2 votes |
/** * 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
Source File: ZestContentViewer.java From gef with Eclipse Public License 2.0 | 2 votes |
/** * 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 18
Source File: SWTUtils.java From SIMVA-SoS with Apache License 2.0 | 2 votes |
/** * 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: GraphicsUtil.java From statecharts with Eclipse Public License 1.0 | 2 votes |
/** * Calculates a mixed color from two colors by interpolating the rgb parts * using a mix ratio. * * @param baseColor * @param mixinColor * @param ratio * a value from 0 to 255 that defines the mix ratio. Using 0 will * return the base color and 255 the mixin color. * @return */ public static Color mixColor(Color baseColor, Color mixinColor, int ratio) { return new Color(baseColor.getDevice(), baseColor.getRed() + (mixinColor.getRed() - baseColor.getRed()) * ratio / 255, baseColor.getGreen() + (mixinColor.getGreen() - baseColor.getGreen()) * ratio / 255, baseColor.getBlue() + (mixinColor.getBlue() - baseColor.getBlue()) * ratio / 255); }
Example 20
Source File: SWTUtils.java From openstock with GNU General Public License v3.0 | 2 votes |
/** * 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()); }