Java Code Examples for org.eclipse.swt.graphics.Color#getBlue()
The following examples show how to use
org.eclipse.swt.graphics.Color#getBlue() .
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: ConfigSectionInterfaceColorSWT.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
@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 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: ViewableModel.java From erflute with Apache License 2.0 | 5 votes |
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 5
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 6
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 7
Source File: TypeInfoViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 8
Source File: Colors.java From BiglyBT with GNU General Public License v2.0 | 4 votes |
private void allocateBlues() { int r = COConfigurationManager.getIntParameter("Color Scheme.red"); int g = COConfigurationManager.getIntParameter("Color Scheme.green"); int b = COConfigurationManager.getIntParameter("Color Scheme.blue"); try { boolean bGrayScale = (r == b) && (b == g); HSLColor hslDefault = new HSLColor(); hslDefault.initHSLbyRGB(0, 128, 255); HSLColor hslScheme = new HSLColor(); hslScheme.initHSLbyRGB(r, g, b); diffHue = hslScheme.getHue() - hslDefault.getHue(); diffSatPct = hslScheme.getSaturation() == 0 ? 0 : (float) hslDefault.getSaturation() / hslScheme.getSaturation(); diffLumPct = hslScheme.getLuminence() == 0 ? 0 : (float) hslDefault.getLuminence() / hslScheme.getLuminence(); HSLColor hslColor = new HSLColor(); Color colorTables = Colors.getSystemColor(display, SWT.COLOR_LIST_BACKGROUND); int tR = colorTables.getRed(); int tG = colorTables.getGreen(); int tB = colorTables.getBlue(); // 0 == window background (white) // [blues.length-1] == rgb // in between == blend for (int i = 0; i < blues.length; i++) { hslColor.initHSLbyRGB(r, g, b); float blendBy = (i == 0) ? 1 : (float) 1.0 - ((float) i / (float) (blues.length - 1)); hslColor.blend(tR, tG, tB, blendBy); blues[i] = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()); int iSat = hslColor.getSaturation(); int luminence = hslColor.getLuminence(); if (luminence < 20) { if (iSat > 10) { hslColor.setSaturation(iSat / 2); hslColor.brighten(1.25f); } else if (bGrayScale) { // gray hslColor.brighten(1.2f); } } else { if (iSat > 10) { hslColor.setSaturation(iSat / 2); hslColor.brighten(0.75f); } else if (bGrayScale) { // gray hslColor.brighten(0.8f); } } faded[i] = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()); } if (bGrayScale) { if (b > 200) b -= 20; else b += 20; } hslColor.initHSLbyRGB(r, g, b); hslColor.reverseColor(); colorInverse = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()); hslColor.initHSLbyRGB(r, g, b); hslColor.setHue(hslColor.getHue() + 25); colorShiftRight = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()); hslColor.initHSLbyRGB(r, g, b); hslColor.setHue(hslColor.getHue() - 25); colorShiftLeft = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()); } catch (Exception e) { Logger.log(new LogEvent(LOGID, "Error allocating colors", e)); } }
Example 9
Source File: ERDiagram.java From erflute with Apache License 2.0 | 4 votes |
public void setDefaultColor(Color color) { this.defaultColor = new int[3]; this.defaultColor[0] = color.getRed(); this.defaultColor[1] = color.getGreen(); this.defaultColor[2] = color.getBlue(); }
Example 10
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 11
Source File: SWTAppearance.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
public UIColorModel createColorModel(int style1, int style2) { Color c1 = this.display.getSystemColor(style1); Color c2 = this.display.getSystemColor(style2); return new UIColorModel(((c1.getRed() + c2.getRed()) / 2), ((c1.getGreen() + c2.getGreen()) / 2), ((c1.getBlue() + c2.getBlue()) / 2)); }
Example 12
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 13
Source File: PropsUI.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GUIResource gui = GUIResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( new PaintListener() { @Override public void paintControl( PaintEvent paintEvent ) { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } } ); } font = null; // GUIResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GUIResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GUIResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GUIResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 14
Source File: PropsUi.java From hop with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GuiResource gui = GuiResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( paintEvent -> { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } ); } font = null; // GuiResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GuiResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GuiResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GuiResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 15
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 16
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()); }
Example 17
Source File: SWTUtils.java From astor 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 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: SWTUtils.java From astor 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 20
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()); }