/** * Get the image for when all other fallbacks have failed. This is an image * drawn on the canvas, a square with a red X. * * @param display the device to render the image to * @return the missing image */ public static SwtUniversalImage getMissingImage( Display display ) { Image img = new Image( display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE ); GC gc = new GC( img ); gc.setForeground( new Color( display, 0, 0, 0 ) ); gc.drawRectangle( 4, 4, ConstUI.ICON_SIZE - 8, ConstUI.ICON_SIZE - 8 ); gc.setForeground( new Color( display, 255, 0, 0 ) ); gc.drawLine( 4, 4, ConstUI.ICON_SIZE - 4, ConstUI.ICON_SIZE - 4 ); gc.drawLine( ConstUI.ICON_SIZE - 4, 4, 4, ConstUI.ICON_SIZE - 4 ); gc.dispose(); return new SwtUniversalImageBitmap( img ); }
public void getData() { fixedFontData = props.getFixedFont(); fixedFont = new Font( display, fixedFontData ); graphFontData = props.getGraphFont(); graphFont = new Font( display, graphFontData ); noteFontData = props.getNoteFont(); noteFont = new Font( display, noteFontData ); backgroundRGB = props.getBackgroundRGB(); if ( backgroundRGB == null ) { backgroundRGB = display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ).getRGB(); } background = new Color( display, backgroundRGB ); graphColorRGB = props.getGraphColorRGB(); graphColor = new Color( display, graphColorRGB ); tabColorRGB = props.getTabColorRGB(); tabColor = new Color( display, tabColorRGB ); }
/** * Free the managed resource if it hasn't already been done and if this is not a system color * */ public void dispose() { // System color and already disposed off colors don't need to be disposed! if ( !systemColor && !color.isDisposed() ) { color.dispose(); } }
/** * Build a 1x1 px gray image to be used as separator. This color, halfway * between white and black, looks good both in Classic and in Dark Theme */ private Image getSeparatorBgImage() { Image backgroundImage = new Image(Display.getDefault(), 1, 1); GC gc = new GC(backgroundImage); gc.setBackground(new Color(dialog.getDisplay(), 127, 127, 127)); gc.fillRectangle(0, 0, 1, 1); gc.dispose(); return backgroundImage; }
Object object = objects[index]; if ( object instanceof Color ) { if ( ( (Color) object ).isDisposed() ) { return; gc.setBackground( (Color) object ); gc.fillRectangle( canvas.getClientArea() ); return; if ( ( (Font) object ).isDisposed() ) { return; gc.setFont( (Font) object ); FontData[] array = gc.getFont().getFontData(); String string = ""; String lf = text.getLineDelimiter(); if ( ( (Image) object ).isDisposed() ) { return;
e.gc.drawImage( kettle_image, 0, 0 ); fullVersionText = fullVersionText + " " + buildVersion; e.gc.setFont( verFont ); e.gc.setForeground( new Color( display, 65, 65, 65 ) ); e.gc.drawText( fullVersionText, 290, 205, true ); e.gc.setFont( licFont ); e.gc.setForeground( new Color( display, 65, 65, 65 ) ); licFontSize--; if ( licFont != null ) { licFont.dispose(); licFont = new Font( e.display, "Helvetica", licFontSize, SWT.NORMAL ); e.gc.setFont( licFont ); e.gc.setForeground( new Color( display, 65, 65, 65 ) ); e.gc.drawText( version, 290, 235, true ); e.gc.drawText( buildDate, 290, 250, true );
void initializeColors() { Display display = Display.getDefault(); colors = new Color[] { new Color( display, new RGB( 0, 0, 0 ) ), // black new Color( display, new RGB( 63, 127, 95 ) ), // red new Color( display, new RGB( 0, 0, 192 ) ), // green new Color( display, new RGB( 127, 0, 85 ) ), // blue new Color( display, new RGB( 255, 102, 0 ) ) // Kettle Functions / Orange }; tokenColors = new int[MAXIMUM_TOKEN]; tokenColors[WORD] = 0; tokenColors[WHITE] = 0; tokenColors[KEY] = 3; tokenColors[COMMENT] = 1; tokenColors[STRING] = 2; tokenColors[OTHER] = 0; tokenColors[NUMBER] = 0; tokenColors[FUNCTIONS] = 4; }
private void drawVersionWarning( GC gc, Display display ) { gc.setBackground( versionWarningBackgroundColor ); gc.setForeground( new Color( display, 65, 65, 65 ) ); // gc.fillRectangle(290, 231, 367, 49); // gc.drawRectangle(290, 231, 367, 49); gc.drawImage( exclamation_image, 304, 243 ); gc.setFont( devWarningFont ); gc.drawText( BaseMessages.getString( PKG, "SplashDialog.DevelopmentWarning" ), 335, 241, true ); }
static Image createNewTransparentImg(Display d, int w, int h) { final Color white = d.getSystemColor(SWT.COLOR_WHITE); final Color black = d.getSystemColor(SWT.COLOR_BLACK); final PaletteData palette = new PaletteData(new RGB[] { white.getRGB(), black.getRGB() }); final ImageData sourceData = new ImageData(w, h, 1, palette); sourceData.transparentPixel = 0; return new Image(d, sourceData); }
private Color getDisabledColor() { Device device = Display.getCurrent(); return new Color( device, 188, 188, 188 ); }
Color getInterpolatedColor(Color color1, Color color2, float color1Likeness) { if (color1.equals(color2)) return color1; if (color1Likeness == 1.0) return color1; if (color1Likeness == 0.0) return color2; return new Color(Display.getDefault(), getInterpolatedRGB(color1, color2, color1Likeness)); } }
Color color2 = new Color(display, 255, 255, 255); try { gc.setForeground(color1); gc.setBackground(color2); gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true); } finally { color2.dispose(); color1.dispose(); oldImage.dispose(); imageGradient.dispose();
private void initializeDefaultColors() { // TODO This is temporary. // These should be initialized by the workbench theme, but not yet. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133731 Display display = Display.getCurrent(); colorRegistry.put(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()); colorRegistry.put(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR, display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB()); } }
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the receiver */ @Override public String toString () { if (isDisposed()) return "Color {*DISPOSED*}"; return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + ", " + getAlpha() +"}"; }
public void widgetSelected( SelectionEvent e ) { ColorDialog cd = new ColorDialog( shell ); cd.setText( BaseMessages.getString( PKG, "NotePadDialog.Font.Color.Dialog.Label" ) ); cd.setRGB( wBorderColor.getBackground().getRGB() ); RGB newColor = cd.open(); if ( newColor == null ) { return; } borderColor.dispose(); borderColor = new Color( shell.getDisplay(), newColor ); wBorderColor.setBackground( borderColor ); } } );
private void putColor(String property, RGB setting) { Color oldColor = fColorTable.get(property); if (oldColor != null) { if (oldColor.getRGB().equals(setting)) return; oldColor.dispose(); } fColorTable.put(property, new Color(Display.getCurrent(), setting)); }
@Override public void widgetDisposed(DisposeEvent event) { if (fStatusTextFont != null && !fStatusTextFont.isDisposed()) fStatusTextFont.dispose(); fStatusTextFont= null; if (fStatusTextForegroundColor != null && !fStatusTextForegroundColor.isDisposed()) fStatusTextForegroundColor.dispose(); fStatusTextForegroundColor= null; fTextFont= null; fShell= null; fText= null; }