本文整理了Java中org.eclipse.jface.resource.ResourceManager.createImage
方法的一些代码示例,展示了ResourceManager.createImage
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceManager.createImage
方法的具体详情如下:
包路径:org.eclipse.jface.resource.ResourceManager
类名称:ResourceManager
方法名:createImage
[英]Creates an image, given an image descriptor. Images allocated in this manner must be disposed by #destroyImage(ImageDescriptor), and never by calling Image#dispose().
If the image is intended to remain allocated for the lifetime of the ResourceManager, the call to destroyImage may be omitted and the image will be cleaned up automatically when the ResourceManager is disposed. This should only be done with short-lived ResourceManagers, as doing so with the global manager effectively leaks the resource.
[中]在给定图像描述符的情况下创建图像。以这种方式分配的图像必须由#destroyImage(ImageDescriptor)处理,而决不能通过调用Image#dispose()处理。
如果该映像打算在ResourceManager的生命周期内保持分配状态,则可以省略对destroyImage的调用,并且在处置ResourceManager时,该映像将被自动清除。这只能通过短期的ResourceManager来完成,因为使用global manager这样做实际上会泄露资源。
代码示例来源:origin: org.eclipse.egit/ui
@Override
public Image getImage(Object element) {
return fImageCache.createImage(UIIcons.REPOSITORY);
}
代码示例来源:origin: org.eclipse.egit/ui
/**
* Returns the common icon for a changeset.
*
* @return an image
*/
protected Image getChangesetIcon() {
return getImageCache().createImage(UIIcons.CHANGESET);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.team.ui
public Image getImage(ImageDescriptor descriptor) {
if (descriptor == null || disposed)
return null;
ResourceManager manager = getResourceManager();
Image image = manager.createImage(descriptor);
return image;
}
代码示例来源:origin: inspectIT/inspectIT
/**
* Returns the combined image for given array of descriptors. Orientation can be vertical or
* horizontal.
*
* @param resourceManager
* {@link ResourceManager}.
* @param orientation
* SWT#Vertical or SWT#Horizontal. Descriptors will be passed in given order.
* @param minWidth
* min width of image
* @param minHeight
* min height of image
* @param descriptors
* Array of descriptors.
*
* @return Combined {@link Image}.
*/
public static Image getCombinedImage(ResourceManager resourceManager, int orientation, int minWidth, int minHeight, ImageDescriptor... descriptors) {
ImageDescriptor combinedImageDescriptor = new CombinedIcon(descriptors, orientation, minWidth, minHeight);
Image img = resourceManager.createImage(combinedImageDescriptor);
return img;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
/**
* Decorate the Image supplied with the overlays.
*
* @param image
* @param manager
* @return Image
*/
Image decorateWithOverlays(Image image, ResourceManager manager) {
// Do not try to do anything if there is no source or overlays
if (image == null || descriptors == null) {
return image;
}
Rectangle bounds = image.getBounds();
Point size = new Point(bounds.width, bounds.height);
DecorationOverlayIcon icon = new DecorationOverlayIcon(image, descriptors, size);
return manager.createImage(icon);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private Image findOrCreateImage(ImageDescriptor imageDescriptor,
ResourceManager resourceManager) {
if (imageDescriptor == null) {
return null;
}
Image image = (Image) resourceManager.find(imageDescriptor);
if (image == null) {
try {
image = resourceManager.createImage(imageDescriptor);
} catch (DeviceResourceException e) {
WorkbenchPlugin.log(e);
}
}
return image;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private Image getIcon(Job job) {
if (job != null) {
Object property = job
.getProperty(IProgressConstants.ICON_PROPERTY);
// Create an image from the job's icon property or family
if (property instanceof ImageDescriptor) {
return manager.createImage((ImageDescriptor) property);
} else if (property instanceof URL) {
return manager.createImage(ImageDescriptor
.createFromURL((URL) property));
} else {
// Let the progress manager handle the resource management
return ProgressManager.getInstance().getIconFor(job);
}
}
return null;
}
代码示例来源:origin: inspectIT/inspectIT
/**
* The passed image will be decorated with an overlay which is defined on the event type of the
* exception transparently.
*
* @param image
* the image that will be decorated with the overlay.
* @param data
* the exception data from which the event will be extracted.
* @param resourceManager
* Resource manager that image will be created with. It is responsibility of a caller
* to provide {@link ResourceManager} for correct image disposing.
* @return the resulting image
*/
public static Image decorateImageWithException(Image image, ExceptionSensorData data, ResourceManager resourceManager) {
ImageDescriptor exceptionDesc = getImageDescriptor(data);
DecorationOverlayIcon icon = new DecorationOverlayIcon(image, exceptionDesc, IDecoration.BOTTOM_RIGHT);
Image createdImage = resourceManager.createImage(icon);
return createdImage;
}
代码示例来源:origin: org.eclipse.neoscada.hmi/org.eclipse.scada.da.ui.connection
private void updateFolder ( final StyledViewerLabel label, final FolderEntry folderEntry )
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/folder.gif" ) ) );
String folderName = folderEntry.getName ();
if ( folderName == null || folderName.length () == 0 )
{
folderName = " ";
}
label.setText ( folderName );
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.compare
/**
* Returns an image showing the specified change kind.
* The different kind of changes are defined in the <code>Differencer</code>.
* Newly created images are remembered by this class and
* disposed when the <code>dispose</code> method is called.
*
* @param kind the kind of change as defined in <code>Differencer</code>.
* @return an modification of the base image reflecting the kind of change
* or {@code null} if there is no image descriptor registered for
* given id.
* @see org.eclipse.compare.structuremergeviewer.Differencer
* @since 2.0
*/
public Image getImage(int kind) {
if (fDisposed) {
return null;
}
ImageDescriptor id= getImageDescriptor(kind);
if (id == null) {
return null;
}
ResourceManager rm = getResourceManager();
return rm.createImage(id);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
/**
* Returns an image to show for the corresponding editor descriptor.
*
* @param editorDesc the editor descriptor, or null for the system editor
* @return the image or null
*/
private Image getImage(IEditorDescriptor editorDesc) {
ImageDescriptor imageDesc = getImageDescriptor(editorDesc);
if (imageDesc == null) {
return null;
}
return IDEWorkbenchPlugin.getDefault().getResourceManager().createImage(imageDesc);
}
代码示例来源:origin: org.eclipse.neoscada.hmi/org.eclipse.scada.da.ui.connection
private void updateItem ( final StyledViewerLabel label, final DataItemEntry dataItemEntry )
{
String itemName = dataItemEntry.getName ();
if ( itemName == null || itemName.length () == 0 )
{
itemName = " ";
}
label.setText ( itemName );
if ( dataItemEntry.getIODirections ().containsAll ( Arrays.asList ( IODirection.INPUT, IODirection.OUTPUT ) ) )
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item_io.gif" ) ) );
}
else if ( dataItemEntry.getIODirections ().contains ( IODirection.INPUT ) )
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item_i.gif" ) ) );
}
else if ( dataItemEntry.getIODirections ().contains ( IODirection.OUTPUT ) )
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item_o.gif" ) ) );
}
else
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item.gif" ) ) );
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.compare
/**
* Returns an image showing the specified change kind applied to a
* given base image. The different kind of changes are defined in the <code>Differencer</code>.
* Typically an implementation would build a composite image
* from the given base image and an image representing the change kind.
* Newly created images are remembered by this class and
* disposed when the <code>dispose</code> method is called.
*
* @param base the image which is modified to reflect the kind of change
* @param kind the kind of change as defined in <code>Differencer</code>.
* @return an modification of the base image reflecting the kind of change.
* @see org.eclipse.compare.structuremergeviewer.Differencer
*/
public Image getImage(Image base, int kind) {
if (fDisposed)
return null;
ImageDescriptor id = new DiffImageDescriptor(base, getImageDescriptor(kind), ICompareUIConstants.COMPARE_IMAGE_WIDTH, false);
ResourceManager rm = getResourceManager();
return rm.createImage(id);
}
代码示例来源:origin: inspectIT/inspectIT
/**
* Returns overlayed icon for editors with additional {@link ImageDescriptor} depending if the
* repository is CMR or Storage repository.
*
* @param original
* Original icon.
* @param repositoryDefinition
* Repository definition.
* @param resourceManager
* Resource manager that image will be created with. It is responsibility of a caller
* to provide {@link ResourceManager} for correct image disposing.
* @return Overlayed icon.
*/
public static Image getOverlayedEditorImage(Image original, RepositoryDefinition repositoryDefinition, ResourceManager resourceManager) {
if (repositoryDefinition instanceof CmrRepositoryDefinition) {
return original;
} else if (repositoryDefinition instanceof StorageRepositoryDefinition) {
ImageDescriptor overlayDescriptor = InspectIT.getDefault().getImageDescriptor(InspectITImages.IMG_STORAGE_OVERLAY);
DecorationOverlayIcon icon = new DecorationOverlayIcon(original, new ImageDescriptor[] { null, null, null, overlayDescriptor, null });
Image img = resourceManager.createImage(icon);
return img;
}
return null;
}
代码示例来源:origin: org.eclipse.egit/ui
private static Image getImage(ResourceManager rm, Color bgColor, Image img) {
ImageData imageData = img.getImageData();
imageData.transparentPixel = imageData.palette.getPixel(bgColor
.getRGB());
Image image = rm.createImage(createFromImageData(imageData));
img.dispose();
return image;
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
private void parsePlugin(Object input, DocumentRangeNode rootNode, IDocument document, PDELabelProvider labelProvider, ResourceManager resources, IProgressMonitor monitor) throws CoreException {
boolean isFragment = isFragment(input);
PluginModelBase model = createModel(input, document, isFragment);
if (!model.isLoaded() && model.getStatus().getSeverity() == IStatus.ERROR)
throw new CoreException(model.getStatus());
try {
String id = isFragment ? "fragment" : "plugin"; //$NON-NLS-1$ //$NON-NLS-2$
ImageDescriptor icon = isFragment ? PDEPluginImages.DESC_FRAGMENT_MF_OBJ : PDEPluginImages.DESC_PLUGIN_MF_OBJ;
PluginNode parent = new PluginNode(rootNode, ROOT, id, resources.createImage(icon), document, 0, document.getLength());
createChildren(parent, model, labelProvider, resources);
} finally {
model.dispose();
}
}
代码示例来源:origin: org.eclipse.neoscada.hmi/org.eclipse.scada.core.ui.connection
@Override
public void updateLabel ( final StyledViewerLabel label, final Object element )
{
if ( element instanceof ConnectionDiscovererBean )
{
final ConnectionDiscovererBean bean = (ConnectionDiscovererBean)element;
if ( bean.getImageDescriptor () != null )
{
label.setImage ( this.resource.createImage ( ( (ConnectionDiscovererBean)element ).getImageDescriptor () ) );
}
label.setText ( bean.getName () );
}
else if ( element instanceof ConnectionHolder )
{
final Image image = this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/connection.gif" ) ); //$NON-NLS-1$
label.setImage ( image );
label.setStyledText ( getConnectionString ( (ConnectionHolder)element ) );
}
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.hmi/org.eclipse.scada.core.ui.connection
@Override
public void updateLabel ( final StyledViewerLabel label, final Object element )
{
if ( element instanceof ConnectionDiscovererBean )
{
final ConnectionDiscovererBean bean = (ConnectionDiscovererBean)element;
if ( bean.getImageDescriptor () != null )
{
label.setImage ( this.resource.createImage ( ( (ConnectionDiscovererBean)element ).getImageDescriptor () ) );
}
label.setText ( bean.getName () );
}
else if ( element instanceof ConnectionHolder )
{
final Image image = this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/connection.gif" ) ); //$NON-NLS-1$
label.setImage ( image );
label.setStyledText ( getConnectionString ( (ConnectionHolder)element ) );
}
}
代码示例来源:origin: inspectIT/inspectIT
/**
* Returns an overlayed icon of the passed main image using the passed images as overlays.
*
* @param main
* main image to be overlayed
* @param resourceManager
* Resource manager that image will be created with. It is responsibility of a caller
* to provide {@link ResourceManager} for correct image disposing.
* @param scaleFactor
* scale factor to be used to scale the overlay images. 1.0 means exactly the
* original size, 0.5 half size, 2.0 double size.
* @param overlays
* 1 to 4 overlay images. 1: top-left, 2: top-right, 3: bottom-left, 4: button-right.
* Any of the overlay positions can be null to not draw an overlay at that position.
* @return an overlayed image
*/
public static Image getOverlayedImage(Image main, ResourceManager resourceManager, double scaleFactor, Image... overlays) {
ImageDescriptor[] descriptors = new ImageDescriptor[overlays.length];
for (int i = 0; i < overlays.length; i++) {
if (null != overlays[i]) {
ImageData imageData = overlays[i].getImageData();
imageData = imageData.scaledTo((int) (scaleFactor * imageData.width), (int) (scaleFactor * imageData.height));
descriptors[i] = ImageDescriptor.createFromImageData(imageData);
}
}
DecorationOverlayIcon icon = new DecorationOverlayIcon(main, descriptors);
Image img = resourceManager.createImage(icon);
return img;
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
private void createNode(DocumentRangeNode parent, int type, Object element, PDELabelProvider labelProvider, ResourceManager resources) {
if (element instanceof IDocumentElementNode) {
IDocumentElementNode node = (IDocumentElementNode) element;
ImageDescriptor imageDescriptor = getImageDescriptor(element);
Image image = null;
if (imageDescriptor != null) {
image = resources.createImage(imageDescriptor);
}
new PluginNode(parent, type, labelProvider.getText(element), image, parent.getDocument(), node.getOffset(), node.getLength());
}
}
内容来源于网络,如有侵权,请联系作者删除!