Java Code Examples for org.eclipse.swt.graphics.Color#dispose()
The following examples show how to use
org.eclipse.swt.graphics.Color#dispose() .
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: SwtRendererImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
private final void fillPathColor( Path path, ColorDefinition g ) throws ChartException { // skip full transparency for optimization. if ( !( g.isSetTransparency( ) && g.getTransparency( ) == 0 ) ) { final Color cBG = (Color) _ids.getColor( g ); final Color cPreviousBG = _gc.getBackground( ); _gc.setBackground( cBG ); R31Enhance.setAlpha( _gc, g ); _gc.fillPath( path ); cBG.dispose( ); _gc.setBackground( cPreviousBG ); } }
Example 2
Source File: XYChartLegendImageProvider.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public Image getLegendImage(int imageHeight, int imageWidth, @NonNull Long id) { /* * If series exists in chart, then image legend match that series. Image will * make sense if series exists in chart. If it does not exists, an image will * still be created. */ OutputElementStyle appearance = fChartViewer.getSeriesStyle(id); BaseXYPresentationProvider presProvider = fChartViewer.getPresentationProvider2(); RGBAColor rgb = presProvider.getColorStyleOrDefault(appearance, StyleProperties.COLOR, DEFAULT_COLOR); Color lineColor = new Color(Display.getDefault(), rgb.getRed(), rgb.getGreen(), rgb.getBlue()); Color background = Display.getDefault().getSystemColor(SWT.COLOR_WHITE); PaletteData palette = new PaletteData(background.getRGB(), lineColor.getRGB()); ImageData imageData = new ImageData(imageWidth, imageHeight, 8, palette); imageData.transparentPixel = 0; Image image = new Image(Display.getDefault(), imageData); GC gc = new GC(image); gc.setBackground(background); gc.fillRectangle(0, 0, imageWidth, imageHeight); drawStyleLine(gc, lineColor, imageWidth, imageHeight, appearance); drawStyledDot(gc, lineColor, imageWidth, imageHeight, appearance); gc.dispose(); lineColor.dispose(); return image; }
Example 3
Source File: SwtGc.java From hop with Apache License 2.0 | 5 votes |
public void dispose() { gc.dispose(); if ( transform != null && transform.isDisposed() == false ) { transform.dispose(); } for ( Color color : colors ) { color.dispose(); } for ( Font font : fonts ) { font.dispose(); } }
Example 4
Source File: SwtGc.java From hop with Apache License 2.0 | 5 votes |
private Color getColor( int r, int g, int b ) { Color color = new Color( PropsUi.getDisplay(), new RGB( r, g, b ) ); int index = colors.indexOf( color ); if ( index < 0 ) { colors.add( color ); } else { color.dispose(); color = colors.get( index ); } return color; }
Example 5
Source File: DisplayOverlay.java From gama with GNU General Public License v3.0 | 5 votes |
/** * @param left2 * @param createColor */ private void setForeground(final Label label, final Color color) { if (label == null || label.isDisposed()) { return; } final Color c = label.getForeground(); label.setForeground(color); if (c != IGamaColors.WHITE.color() && c != color) { c.dispose(); } }
Example 6
Source File: SWTResourceManager.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Dispose of all the cached {@link Color}'s. */ public static void disposeColors(){ for (Color color : m_colorMap.values()) { color.dispose(); } m_colorMap.clear(); }
Example 7
Source File: SetColorEffect.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.nebula.animation.effects.AbstractEffect#applyEffect(long) */ public void applyEffect(final long currentTime) { Color currentColor = control.getColor(); // Get the next color values int nextRed = (int) (src.getRed() + diffR * easingFunction.getValue(currentTime)); int nextGreen = (int) (src.getGreen() + diffG * easingFunction.getValue(currentTime)); int nextBlue = (int) (src.getBlue() + diffB * easingFunction.getValue(currentTime)); RGB nextRGB = new RGB(nextRed, nextGreen, nextBlue); if (currentColor == null || !nextRGB.equals(currentColor.getRGB())) { Color nextColor = new Color(Display.getCurrent(), nextRed, nextGreen, nextBlue); // If this is the destination color, dispose the newly created color // and use the destination one instead. if (dest.getRGB().equals(nextColor.getRGB())) { nextColor.dispose(); nextColor = dest; } control.setColor(nextColor); // If the previous color is not the source or destination one, // dispose it. if (currentColor != null && !currentColor.isDisposed()) { if (dest != currentColor && src != currentColor) { currentColor.dispose(); } } } }
Example 8
Source File: SWTGC.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private Color getColor( int r, int g, int b ) { Color color = new Color( PropsUI.getDisplay(), new RGB( r, g, b ) ); int index = colors.indexOf( color ); if ( index < 0 ) { colors.add( color ); } else { color.dispose(); color = colors.get( index ); } return color; }
Example 9
Source File: ListItemRenderer.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void freeDropShadowsColors() { // Free colors : { Iterator<Color> i = this.dropShadowsColors.iterator(); while (i.hasNext()) { Color c = i.next(); if (c != null && !c.isDisposed()) c.dispose(); } } }
Example 10
Source File: ChoiceWidget.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Draw the composite */ private void drawComposite() { final Rectangle rect = getClientArea(); final Image newImage = new Image(getDisplay(), Math.max(1, rect.width), Math.max(1, rect.height)); final GC gc = new GC(newImage); final boolean inside = insideComposite || insideImage || insideInstruction || insideText; if (!inside && !selection) { gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); gc.drawRectangle(rect.x, rect.y, rect.width, rect.height); } else { // The mouse is over OR the item is selected final Color gradientColor = inside ? new Color(getDisplay(), 220, 231, 243) : new Color(getDisplay(), 241, 241, 241); final Color borderColor = inside ? new Color(getDisplay(), 35, 107, 178) : new Color(getDisplay(), 192, 192, 192); gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); gc.setBackground(gradientColor); gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true); gc.setForeground(borderColor); gc.drawRoundRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1, 2, 2); gradientColor.dispose(); borderColor.dispose(); } gc.dispose(); setBackgroundImage(newImage); if (oldImage != null) { oldImage.dispose(); } oldImage = newImage; }
Example 11
Source File: SharedProjectFileDecorator.java From saros with GNU General Public License v2.0 | 5 votes |
private void initializeImageDescriptors() { Image tintImage = ImageManager.getImage(IMAGE_PATH); for (int i = 0; i <= SarosAnnotation.SIZE; i++) { Color tintColor = SarosAnnotation.getUserColor(i); Image tintedImage = tintImage(tintImage, tintColor); imageDescriptors[i] = new MemoryImageDescriptor(tintedImage.getImageData()); tintColor.dispose(); tintedImage.dispose(); } tintImage.dispose(); }
Example 12
Source File: GridItem_Test.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Test( expected = IllegalArgumentException.class ) public void testSetForegroundByIndex_DisposedFont() { createGridColumns( grid, 3, SWT.NONE ); GridItem item = new GridItem( grid, SWT.NONE ); Color foreground = new Color( display, 0, 0, 255 ); foreground.dispose(); item.setForeground( 1, foreground ); }
Example 13
Source File: JavaColorManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void dispose(Display display) { Map<RGB, Color> colorTable= fDisplayTable.get(display); if (colorTable != null) { Iterator<Color> e= colorTable.values().iterator(); while (e.hasNext()) { Color color= e.next(); if (color != null && !color.isDisposed()) color.dispose(); } } }
Example 14
Source File: ColorManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void dispose() { synchronized (lock) { for (Color c : _colorsByRGB.values()) { c.dispose(); } _colorsByRGB.clear(); } }
Example 15
Source File: BoxSettingsImpl.java From gama with GNU General Public License v3.0 | 4 votes |
protected Color setColorCopy(final Color old, final Color newColor) { if (old != null) { old.dispose(); } return newColor == null ? null : new Color(null, newColor.getRGB()); }
Example 16
Source File: FillChooserComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
void paintControl( PaintEvent pe ) { Color cBlack = new Color( this.getDisplay( ), 0, 0, 0 ); Color cWhite = new Color( this.getDisplay( ), 255, 255, 255 ); GC gc = pe.gc; gc.setForeground( cBlack ); int iCellWidth = this.getSize( ).x / ROW_SIZE; int iCellHeight = this.getSize( ).y / COLUMN_SIZE; boolean isFound = false; for ( int iR = 0; iR < COLUMN_SIZE; iR++ ) { for ( int iC = 0; iC < ROW_SIZE; iC++ ) { int index = iR * ROW_SIZE + iC; try { gc.setBackground( colorMap[index] ); } catch ( Throwable e ) { e.printStackTrace( ); } gc.fillRectangle( iC * iCellWidth, iR * iCellHeight, iCellWidth, iCellHeight ); // Highlight currently selected color if it exists in this // list if ( selectedIndex == index || !isFound && colorSelection != null && colorSelection.equals( colorMap[index] ) ) { isFound = true; selectedIndex = index; if ( colorSelection == null ) { colorSelection = colorMap[index]; } if ( isFocusControl( ) ) { gc.setLineStyle( SWT.LINE_DOT ); } gc.drawRectangle( iC * iCellWidth, iR * iCellHeight, iCellWidth - 2, iCellHeight - 2 ); gc.setForeground( cWhite ); gc.drawRectangle( iC * iCellWidth + 1, iR * iCellHeight + 1, iCellWidth - 3, iCellHeight - 3 ); gc.setForeground( cBlack ); } } } if ( !isFound ) { clearColorSelection( ); } cBlack.dispose( ); cWhite.dispose( ); gc.dispose( ); }
Example 17
Source File: Gradient.java From arx with Apache License 2.0 | 4 votes |
/** * Dispose all colors */ public void dispose() { for (Color c : colors) { if (!c.isDisposed()) c.dispose(); } }
Example 18
Source File: BreadcrumbItemDropDown.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void drawCompositeImage( int width, int height ) { Display display = fParentComposite.getDisplay( ); Image image = new Image( display, ARROW_SIZE, ARROW_SIZE * 2 ); GC gc = new GC( image ); Color triangle = createColor( SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 20, display ); Color aliasing = createColor( SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 30, display ); gc.setBackground( triangle ); if ( fLTR ) { gc.fillPolygon( new int[]{ mirror( 0 ), 0, mirror( ARROW_SIZE ), ARROW_SIZE, mirror( 0 ), ARROW_SIZE * 2 } ); } else { gc.fillPolygon( new int[]{ ARROW_SIZE, 0, 0, ARROW_SIZE, ARROW_SIZE, ARROW_SIZE * 2 } ); } gc.setForeground( aliasing ); gc.drawLine( mirror( 0 ), 1, mirror( ARROW_SIZE - 1 ), ARROW_SIZE ); gc.drawLine( mirror( ARROW_SIZE - 1 ), ARROW_SIZE, mirror( 0 ), ARROW_SIZE * 2 - 1 ); gc.dispose( ); triangle.dispose( ); aliasing.dispose( ); ImageData imageData = image.getImageData( ); for ( int y = 1; y < ARROW_SIZE; y++ ) { for ( int x = 0; x < y; x++ ) { imageData.setAlpha( mirror( x ), y, 255 ); } } for ( int y = 0; y < ARROW_SIZE; y++ ) { for ( int x = 0; x <= y; x++ ) { imageData.setAlpha( mirror( x ), ARROW_SIZE * 2 - y - 1, 255 ); } } int offset = fLTR ? 0 : -1; drawImage( imageData, ( width / 2 ) - ( ARROW_SIZE / 2 ) + offset, ( height / 2 ) - ARROW_SIZE - 1 ); image.dispose( ); }
Example 19
Source File: BreadcrumbViewer.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
/** * The image to use for the breadcrumb background as specified in * https://bugs.eclipse.org/bugs/show_bug.cgi?id=221477 * * @param height the height of the image to create * @param display the current display * @return the image for the breadcrumb background */ private Image createGradientImage(int height, Display display) { int width = 50; Image result = new Image(display, width, height); GC gc = new GC(result); Color colorC = createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 35, display); Color colorD = createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 45, display); Color colorE = createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 80, display); Color colorF = createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 70, display); Color colorG = createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_WHITE, 45, display); Color colorH = createColor(SWT.COLOR_WIDGET_NORMAL_SHADOW, SWT.COLOR_LIST_BACKGROUND, 35, display); try { drawLine(width, 0, colorC, gc); drawLine(width, 1, colorC, gc); gc.setForeground(colorD); gc.setBackground(colorE); gc.fillGradientRectangle(0, 2, width, 2 + 8, true); gc.setBackground(colorE); gc.fillRectangle(0, 2 + 9, width, height - 4); drawLine(width, height - 3, colorF, gc); drawLine(width, height - 2, colorG, gc); drawLine(width, height - 1, colorH, gc); } finally { gc.dispose(); colorC.dispose(); colorD.dispose(); colorE.dispose(); colorF.dispose(); colorG.dispose(); colorH.dispose(); } return result; }
Example 20
Source File: GuiResource.java From hop with Apache License 2.0 | 4 votes |
private void disposeColors( Collection<Color> colors ) { for ( Color color : colors ) { color.dispose(); } }