Java Code Examples for org.eclipse.swt.graphics.Image

The following are top voted examples for showing how to use org.eclipse.swt.graphics.Image. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Hydrograph   File: HydrographCompletionProposal.java   View source code 6 votes vote down vote up
public HydrographCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition,
        Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
    Assert.isNotNull(replacementString);
    Assert.isTrue(replacementOffset >= 0);
    Assert.isTrue(replacementLength >= 0);
    Assert.isTrue(cursorPosition >= 0);

    fReplacementString = replacementString;
    fReplacementOffset = replacementOffset;
    fReplacementLength = replacementLength;
    fCursorPosition = cursorPosition;
    fImage = image;
    fDisplayString = displayString;
    fContextInformation = contextInformation;
    fAdditionalProposalInfo = additionalProposalInfo;
}
 
Example 2
Project: n4js   File: N4JSProjectExplorerLabelProvider.java   View source code 6 votes vote down vote up
@Override
public Image getImage(final Object element) {

	if (element instanceof WorkingSet) {
		return decorator.decorateImage(WORKING_SET_IMG, element);
	}

	// (temporarily) disabled because #isSourceFolder() and #isOutputFolder() obtain a lock on the workspace
	// (e.g. they call IResource#exists() on IFolder 'element') and this seems to cause performance issues with
	// locks that egit is obtaining for doing cyclic updates (see IDE-2269):

	// if (element instanceof IFolder) {
	// final IFolder folder = (IFolder) element;
	// if (helper.isSourceFolder(folder) || helper.isOutputFolder(folder)) {
	// return decorator.decorateImage(SRC_FOLDER_IMG, element);
	// }
	// }

	return delegate.getImage(element);
}
 
Example 3
Project: eclipse-bash-editor   File: EclipseUtil.java   View source code 6 votes vote down vote up
/**
 * Get image by path from image registry. If not already registered a new
 * image will be created and registered. If not createable a fallback image
 * is used instead
 * 
 * @param path
 * @param pluginId
 *            - plugin id to identify which plugin image should be loaded
 * @return image
 */
public static Image getImage(String path, String pluginId) {
	ImageRegistry imageRegistry = getImageRegistry();
	if (imageRegistry == null) {
		return null;
	}
	Image image = imageRegistry.get(path);
	if (image == null) {
		ImageDescriptor imageDesc = createImageDescriptor(path, pluginId);
		image = imageDesc.createImage();
		if (image == null) {
			image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
		}
		imageRegistry.put(path, image);
	}
	return image;
}
 
Example 4
Project: bdf2   File: BaseModelLabelProvider.java   View source code 6 votes vote down vote up
public Image getImage(Object objects) {
	if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
		return null;
	}
	Object object = ((IStructuredSelection) objects).getFirstElement();
	if (object instanceof TableEditPart || object instanceof TableTreeEditPart) {
		return Activator.getImage(Activator.IMAGE_TABLE_16);
	} else if (object instanceof ColumnEditPart || object instanceof ColumnTreeEditPart) {
		return Activator.getImage(Activator.IMAGE_COLUMN_16);
	} else if (object instanceof SchemaEditPart || object instanceof SchemaTreeEditPart) {
		return Activator.getImage(Activator.IMAGE_SCHEMA_16);
	} else if (object instanceof ConnectionEditPart) {
		return Activator.getImage(Activator.IMAGE_CONNECTION);
	}
	return null;
}
 
Example 5
Project: convertigo-eclipse   File: StatisticsDialog.java   View source code 6 votes vote down vote up
private void addStats() {

		for (String key : statsProject.keySet()) {
			if (key != project.getName()) {
				CLabel title = new CLabel(descriptifRight, SWT.BOLD);
				title.setText(key);
				title.setImage(new Image(display, getClass()
						.getResourceAsStream(
								"images/stats_"
										+ key.replaceAll(" ", "_")
												.toLowerCase() + "_16x16.png")));
				title.setBackground(new Color(display, 255, 255, 255));
				title.setMargins(10, 10, 0, 0);

				FontData[] fd = title.getFont().getFontData();
				fd[0].setStyle(SWT.BOLD);
				title.setFont(new Font(title.getFont().getDevice(), fd));

				CLabel subText = new CLabel(descriptifRight, SWT.NONE);
				subText.setText(statsProject.get(key)
						.replaceAll("<br/>", "\r\n").replaceAll("&nbsp;", " "));
				subText.setBackground(new Color(display, 255, 255, 255));
				subText.setMargins(30, 0, 0, 0);
			}
		}
	}
 
Example 6
Project: ide-plugins   File: PluginDialog.java   View source code 6 votes vote down vote up
protected void createTopContent(String title, InputStream imageName) {
    Composite top = new Composite(composite, SWT.NONE);

    top.setLayout(new GridLayout(2, false));
    top.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    top.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    
    final Image image = new Image(top.getDisplay(), imageName);
    Image resized = resizeImage(image, 48, 48);
    Label labelImage = new Label(top, SWT.CENTER);
    labelImage.setImage(resized);
    
    Label label = new Label(top, SWT.NONE);
    label.setText(title);
    final Font newFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    label.setFont(newFont);
    label.setBackground(rowColorSelection);
    
    createLineContent();
    
    top.addDisposeListener(e -> {
        newFont.dispose();
        resized.dispose();
    });
}
 
Example 7
Project: tap17-muggl-javaee   File: ImageRepository.java   View source code 6 votes vote down vote up
/**
 * Private Constructor.
 */
private ImageRepository() {
	this.folderImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/Fairytale_folder.png"));
	this.moonImage = new Image(Display.getDefault(),
			ImageRepository.class.getResourceAsStream("/images/Nuvola_apps_kmoon.png"));
	this.checkImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/400px-P_yes_green.svg.png"));
	this.logfileImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/Gartoon-Gedit-icon.png"));
	this.helpImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/Nuvola_apps_filetypes.png"));
	this.infoImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/Info_icon.png"));
	this.refreshImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/Arrow_refresh.png"));
	this.editImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/edit16.png"));
	this.pushImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/push16.png"));
	this.popImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/pop16.png"));
	this.emptyImage = new Image(Display.getDefault(),
	        ImageRepository.class.getResourceAsStream("/images/empty16.png"));
}
 
Example 8
Project: scanning   File: ModelFieldLabelProvider.java   View source code 6 votes vote down vote up
/**
 * The <code>LabelProvider</code> implementation of this
 * <code>ILabelProvider</code> method returns <code>null</code>.
 * Subclasses may override.
 */
@Override
public Image getImage(Object ofield) {

	if (ofield == null) return null;

	FieldValue field  = (FieldValue)ofield;
	Object   element  = field.get();
	if (element instanceof Boolean) {
		if (ticked==null)   ticked   = Activator.getImageDescriptor("icons/ticked.png").createImage();
		if (unticked==null) unticked = Activator.getImageDescriptor("icons/unticked.gif").createImage();
		Boolean val = (Boolean)element;
		return val ? ticked : unticked;
	}
	return null;
}
 
Example 9
Project: scanning   File: DetectorView.java   View source code 6 votes vote down vote up
protected Image getIcon(String fullPath) throws IOException {

		if (fullPath==null)      return defaultIcon;
		if ("".equals(fullPath)) return defaultIcon;

		try {
			if (iconMap.containsKey(fullPath)) return iconMap.get(fullPath);
			final String[] sa = fullPath.split("/");
			final Bundle bundle = Platform.getBundle(sa[0]);
			if (bundle==null) return defaultIcon;
			if (bundle!=null) {
				Image image = new Image(null, bundle.getResource(sa[1]+"/"+sa[2]).openStream());
				iconMap.put(fullPath, image);
			}
			return iconMap.get(fullPath);
		} catch (Exception ne) {
			logger.debug("Cannot get icon for "+fullPath, ne);
			return defaultIcon;
		}
	}
 
Example 10
Project: Sensors   File: SWTResourceManager.java   View source code 5 votes vote down vote up
/**
 * Returns an {@link Image} stored in the file at the specified path.
 * 
 * @param path
 *            the path to the image file
 * @return the {@link Image} stored in the file at the specified path
 */
public static Image getImage(String path) {
	Image image = m_imageMap.get(path);
	if (image == null) {
		try {
			image = getImage(new FileInputStream(path));
			m_imageMap.put(path, image);
		} catch (Exception e) {
			image = getMissingImage();
			m_imageMap.put(path, image);
		}
	}
	return image;
}
 
Example 11
Project: Hydrograph   File: ViewDataPreferencesDialog.java   View source code 5 votes vote down vote up
private ControlDecoration addDecorator(Control control, String message) {
	ControlDecoration txtDecorator = new ControlDecoration(control, SWT.LEFT);
	FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
			FieldDecorationRegistry.DEC_ERROR);
	Image img = fieldDecoration.getImage();
	txtDecorator.setImage(img);
	txtDecorator.setDescriptionText(message);
	txtDecorator.setMarginWidth(3);
	return txtDecorator;
}
 
Example 12
Project: bdf2   File: NodeImageConfig.java   View source code 5 votes vote down vote up
public Image getSmallImage(){
	if(this.customSmallImage==null){
		return this.defaultSmallImage;
	}else{
		return this.customSmallImage;
	}
}
 
Example 13
Project: BiglyBT   File: SubscriptionManagerUI.java   View source code 5 votes vote down vote up
protected Graphic
loadGraphic(
	UISWTInstance	swt,
	String			name )
{
	Image	image = swt.loadImage( "com/biglybt/ui/images/" + name );

	Graphic graphic = swt.createGraphic(image );

	icon_list.add(image);

	return( graphic );
}
 
Example 14
Project: APITools   File: SWTResourceManager.java   View source code 5 votes vote down vote up
/**
 * Returns an {@link Image} stored in the file at the specified path.
 * 
 * @param path
 *            the path to the image file
 * @return the {@link Image} stored in the file at the specified path
 */
public static Image getImage(String path) {
	Image image = m_imageMap.get(path);
	if (image == null) {
		try {
			image = getImage(new FileInputStream(path));
			m_imageMap.put(path, image);
		} catch (Exception e) {
			image = getMissingImage();
			m_imageMap.put(path, image);
		}
	}
	return image;
}
 
Example 15
Project: n4js   File: GHOLD_170_ImageCaching_PluginUITest.java   View source code 5 votes vote down vote up
/**
 * Checks the indirect {@link Image image} caching.
 */
@Test
public void testIndirectImageCaching() {
	final ImageDescriptor desc1 = ImageRef.LIB_PATH.asImageDescriptor().orNull();
	final ImageDescriptor desc2 = ImageRef.LIB_PATH.asImageDescriptor().orNull();
	final Image img1 = desc1.createImage();
	final Image img2 = desc2.createImage();
	assertTrue("Expected different reference of images.", img1 != img2);
}
 
Example 16
Project: gw4e.project   File: ProjectLabelDecorator.java   View source code 5 votes vote down vote up
@Override
public Image decorateImage(Image image, Object element) {
	if (image!=null) {
		if (element instanceof IProject) {
			IProject project = (IProject) element;
			boolean b = GW4ENature.hasGW4ENature(project);
			if (b) {
				DecorationOverlayIcon icon = new DecorationOverlayIcon(image, GW_DESCRIPTOR, IDecoration.TOP_LEFT);
				Image ret = (Image)resourceManager.get(icon);
				return ret;
			}
		}
	}
	return image;
}
 
Example 17
Project: n4js   File: XpectLabelProvider.java   View source code 5 votes vote down vote up
@Override
public void dispose() {
	for (Iterator<Image> i = imageCache.values().iterator(); i.hasNext();) {
		i.next().dispose();
	}
	imageCache.clear();
}
 
Example 18
Project: BiglyBT   File: UISWTGraphicImpl.java   View source code 5 votes vote down vote up
@Override
public boolean equals(Object obj) {
	if (super.equals(obj)) {
		return true;
	}
	if (obj instanceof UISWTGraphic) {
		Image img2 = ((UISWTGraphic) obj).getImage();
		if (img2 == null) {
			return img == null;
		}
		return img2.equals(img);
	}
	return false;
}
 
Example 19
Project: APITools   File: SWTResourceManager.java   View source code 5 votes vote down vote up
/**
 * @return the small {@link Image} that can be used as placeholder for missing image.
 */
private static Image getMissingImage() {
	Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
	//
	GC gc = new GC(image);
	gc.setBackground(getColor(SWT.COLOR_RED));
	gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
	gc.dispose();
	//
	return image;
}
 
Example 20
Project: n4js   File: ProjectCompareTree.java   View source code 5 votes vote down vote up
@Override
public Image getColumnImage(Object element, int columnIndex) {
	if (columnIndex == 0) {
		final ProjectComparisonEntry entry = (ProjectComparisonEntry) element;
		final EObject api = entry.getElementAPI();
		if (api != null)
			return projectCompareTreeHelper.getImage(api);
	}
	return null;
}
 
Example 21
Project: BiglyBT   File: UISWTGraphicImpl.java   View source code 5 votes vote down vote up
@Override
public Image getImage() {
	if (img == null || img.isDisposed()) {
		return null;
	}
 try {
  img.getDevice();
 } catch (Throwable t) {
		return null;
 }
  return img;
}
 
Example 22
Project: openaudible   File: EnumTable.java   View source code 5 votes vote down vote up
private void layoutColumns() {
    columns = getColumnsToDisplay();
    tableColumns.clear();

    TableColumn cols[] = table.getColumns();
    int index = 0;
    for (F o : columns) {
        TableColumn column;
        // Check to see if column already set...
        if (cols.length > index) {
            column = cols[index];

        } else {
            column = new TableColumn(table, SWT.LEFT);
            column.addSelectionListener(getColumnListener());
        }
        String n = getColumnName(o);
        Image r = getColumnImage(o);
        column.setImage(r);
        column.setText(n);
        column.setWidth(getColumnWidth(o));
        column.setData(o);

        tableColumns.add(column);
        index++;
    }

    // Make sure we didn't shrink. May not be tested.
    while (table.getColumns().length > columns.length) {
        table.getColumn(columns.length).dispose(); // last one
    }

    assert (table.getColumns().length == columns.length);

    //

    setColumWidths();
}
 
Example 23
Project: n4js   File: AbstractExportToSingleFileWizardPage.java   View source code 5 votes vote down vote up
/**
 * Displays a Yes/No question to the user with the specified message and returns the user's response.
 *
 * @param message
 *            the question to ask
 * @return <code>true</code> for Yes, and <code>false</code> for No
 */
private boolean queryYesNoQuestion(String message) {
	MessageDialog dialog = new MessageDialog(getContainer().getShell(),
			IDEWorkbenchMessages.Question,
			(Image) null, message, MessageDialog.NONE,
			new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
		@Override
		protected int getShellStyle() {
			return super.getShellStyle() | SWT.SHEET;
		}
	};
	return dialog.open() == 0;
}
 
Example 24
Project: n4js   File: WorkingSetAdapter.java   View source code 5 votes vote down vote up
WorkingSetAdapter(final WorkingSet delegate) {
	this.delegate = delegate;
	imageDescriptorSupplier = memoize(() -> {
		final Image image = WorkingSetAdapter.this.delegate.getWorkingSetManager().getImage().orNull();
		if (image != null) {
			return ImageDescriptor.createFromImage(image);
		}
		return null;
	});
}
 
Example 25
Project: Hydrograph   File: WidgetUtility.java   View source code 5 votes vote down vote up
/**
 * This Method use to create error message decorator,Its show an error image with message on applied controller field. 
 * @param control
 * @param message
 * @return ControlDecoration
 */

public static ControlDecoration addDecorator(Control control,String message){
	ControlDecoration txtDecorator = new ControlDecoration(control,SWT.LEFT);
	FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
	Image img = fieldDecoration.getImage();
	txtDecorator.setImage(img);
	txtDecorator.setDescriptionText(message);
	return txtDecorator; 
}
 
Example 26
Project: AppleCommander   File: ImageCanvas.java   View source code 5 votes vote down vote up
/**
 * Constructor for ImageCanvas.
 */
public ImageCanvas(Composite parent, int style, Image image, Object layoutData) {
	super(parent, style | SWT.SHELL_TRIM | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
	this.image = image;
	setLayoutData(layoutData);
	setSize(image.getImageData().width, image.getImageData().height);
	addPaintListener(this);
}
 
Example 27
Project: bdf2   File: TableTreeNodeLabelProvider.java   View source code 5 votes vote down vote up
public Image getImage(Object element) {
	TableTreeNode node = (TableTreeNode) element;
	if (node.isTable) {
		return Activator.getImage(Activator.IMAGE_TABLE);
	} else {
		return Activator.getImage(Activator.IMAGE_DATABASE_CONNECT);
	}
}
 
Example 28
Project: n4js   File: GraphList.java   View source code 5 votes vote down vote up
@Override
public Image getImage(Object element) {
	if (((ListEntry) element).type == GraphType.AST) {
		return imageAST;
	}
	if (((ListEntry) element).type == GraphType.CFG)
		return imageCFG;
	return null;
}
 
Example 29
Project: Hydrograph   File: SaveJobFileBeforeRunDialog.java   View source code 5 votes vote down vote up
private Image getSWTImage() {
	Shell shell = getShell();
	final Display display;
	if (shell == null || shell.isDisposed()) {
		shell = getParentShell();
	}
	if (shell == null || shell.isDisposed()) {
		display = Display.getCurrent();
		// The dialog should be always instantiated in UI thread.
		// However it was possible to instantiate it in other threads
		// (the code worked in most cases) so the assertion covers
		// only the failing scenario. See bug 107082 for details.
		Assert.isNotNull(display,
				"The dialog should be created in UI thread"); //$NON-NLS-1$
	} else {
		display = shell.getDisplay();
	}

	final Image[] image = new Image[1];
	display.syncExec(new Runnable() {
		public void run() {
			image[0] = display.getSystemImage(SWT.ICON_QUESTION);
		}
	});

	return image[0];

}
 
Example 30
Project: AgentWorkbench   File: SWTResourceManager.java   View source code 5 votes vote down vote up
/**
 * Returns an {@link Image} encoded by the specified {@link InputStream}.
 * 
 * @param stream
 *            the {@link InputStream} encoding the image data
 * @return the {@link Image} encoded by the specified input stream
 */
protected static Image getImage(InputStream stream) throws IOException {
	try {
		Display display = Display.getCurrent();
		ImageData data = new ImageData(stream);
		if (data.transparentPixel > 0) {
			return new Image(display, data, data.getTransparencyMask());
		}
		return new Image(display, data);
	} finally {
		stream.close();
	}
}
 
Example 31
Project: AgentWorkbench   File: SWTResourceManager.java   View source code 5 votes vote down vote up
/**
 * Returns an {@link Image} stored in the file at the specified path relative to the specified class.
 * 
 * @param clazz
 *            the {@link Class} relative to which to find the image
 * @param path
 *            the path to the image file, if starts with <code>'/'</code>
 * @return the {@link Image} stored in the file at the specified path
 */
public static Image getImage(Class<?> clazz, String path) {
	String key = clazz.getName() + '|' + path;
	Image image = m_imageMap.get(key);
	if (image == null) {
		try {
			image = getImage(clazz.getResourceAsStream(path));
			m_imageMap.put(key, image);
		} catch (Exception e) {
			image = getMissingImage();
			m_imageMap.put(key, image);
		}
	}
	return image;
}
 
Example 32
Project: convertigo-eclipse   File: SWTX.java   View source code 5 votes vote down vote up
public static void drawButtonUp(GC gc, String text, int textAlign,
    Image image, int imageAlign, Rectangle r, int leftMargin,
    int topMargin) {
  Display display = Display.getCurrent();
  drawButtonUp(gc, text, textAlign, image, imageAlign, r.x, r.y, r.width,
      r.height, display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND),
      display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW),
      display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), display
          .getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW),
      leftMargin, topMargin);
}
 
Example 33
Project: BiglyBT   File: ColumnThumbnail.java   View source code 5 votes vote down vote up
@Override
public void cellHover(TableCell cell) {
	final Object ds = cell.getDataSource();
	Image[] imgThumbnail = TorrentUIUtilsV3.getContentImage(ds, true, new ContentImageLoadedListener() {
		@Override
		public void contentImageLoaded(Image image, boolean wasReturned) {
			TorrentUIUtilsV3.releaseContentImage(ds);
		}
	});

	cell.setToolTip(imgThumbnail == null ? null : imgThumbnail[0]);
}
 
Example 34
Project: convertigo-eclipse   File: SchemaViewLabelDecorator.java   View source code 5 votes vote down vote up
public Image decorateImage(Image image, Object element) {
	Image decoratedImage = image;
	
	if (element == null) {
		decoratedImage = null;
	} else if (element instanceof XmlSchemaParticle) {
		XmlSchemaParticle particle = (XmlSchemaParticle) element;
		
		long min = particle.getMinOccurs();
		long max = particle.getMaxOccurs();
		
		String occur = null;
		if (min == 0) {
			occur = "zero";
			if (max > 0) {
				occur += "_" + (max == 1 ? "one" : max == Long.MAX_VALUE ? "unbounded" : "n");
			}
		} else if (min == 1) {
			if (max > 1) {
				occur = "one_" + (max == Long.MAX_VALUE ? "unbounded" : "n");
			}
		} else {
			occur = "n";
			if (max > min) {
				occur += "_" + (max == Long.MAX_VALUE ? "unbounded" : "m");
			}
		}
		if (occur != null) {
			decoratedImage = getOverlayImageOccur(decoratedImage, element, occur);
		}			
	} else if (element instanceof XmlSchemaAttribute) {
		XmlSchemaAttribute attribute = (XmlSchemaAttribute) element;
		XmlSchemaUse use = attribute.getUse();
		if (use.equals(XmlSchemaUtils.attributeUseOptional)) {
			decoratedImage = getOverlayImageOccur(decoratedImage, element, "zero_one");
		}
	}
	
	return decoratedImage;
}
 
Example 35
Project: neoscada   File: ViewerLabelProvider.java   View source code 5 votes vote down vote up
public final Image getImage ( final Object element )
{
    final StyledViewerLabel label = new StyledViewerLabel ( "", null ); //$NON-NLS-1$
    updateLabel ( label, element );

    logger.debug ( "Get Image: {} for {}", new Object[] { label.getImage (), element } ); //$NON-NLS-1$

    return label.getImage ();
}
 
Example 36
Project: Hydrograph   File: SWTResourceManager.java   View source code 5 votes vote down vote up
/**
 * Returns an {@link Image} stored in the file at the specified path.
 * 
 * @param path
 *            the path to the image file
 * @return the {@link Image} stored in the file at the specified path
 */
public static Image getImage(String path) {
	Image image = m_imageMap.get(path);
	if (image == null) {
		try {
			image = getImage(new FileInputStream(path));
			m_imageMap.put(path, image);
		} catch (IOException e) {
			logger.error("Failed to get image ", e); 
			image = getMissingImage();
			m_imageMap.put(path, image);				
		}
	}
	return image;
}
 
Example 37
Project: tap17-muggl-javaee   File: OptionsComposite.java   View source code 5 votes vote down vote up
/**
 * Change the background color of an image and draw a rectangle on it that
 * has the same bounds as the image. This effectively turns the image into
 * the color supplied with the RGB.
 * @param image The image to be painted.
 * @param rgb The desired RGB for the image.
 */
protected void changeImageBackgroundColor(Image image, RGB rgb) {
	Display display = this.shell.getDisplay();
	GC gc = new GC(image);
	gc.setBackground(new Color(display, rgb));
	gc.fillRectangle(this.fileInspConstantClassImage.getBounds());
	gc.dispose();
}
 
Example 38
Project: convertigo-eclipse   File: ConvertigoPlugin.java   View source code 5 votes vote down vote up
private void disposeImages() {
	for (Image beanIcon : icons.values()) {
        if (beanIcon != null)
        	beanIcon.dispose();
    }
	icons.clear();
}
 
Example 39
Project: BiglyBT   File: PiecesItem.java   View source code 5 votes vote down vote up
@Override
public void dispose(TableCell cell) {
	// Named infoObj so code can be copied easily to the other PiecesItem
	DownloadManager infoObj = (DownloadManager) cell.getDataSource();
	if (infoObj == null)
		return;

	Image img = (Image) infoObj.getUserData("PiecesImage");
	if (img != null && !img.isDisposed())
		img.dispose();

	infoObj.setUserData("PiecesImageBuffer", null);
	infoObj.setUserData("PiecesImage", null);
}
 
Example 40
Project: convertigo-eclipse   File: SWTX.java   View source code 5 votes vote down vote up
public static void drawButtonDown(GC gc, String text, int textAlign,
    Image image, int imageAlign, int x, int y, int w, int h) {
  Display display = Display.getCurrent();
  drawButtonDown(gc, text, textAlign, image, imageAlign, x, y, w, h,
      display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND), display
          .getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), 2, 2);
}