Java 类org.eclipse.jface.resource.CompositeImageDescriptor 实例源码

项目:eclipsensis    文件:NSISInstallElementLabelProvider.java   
private Image decorateImage(final Image image, INSISInstallElement element)
{
    String name = Integer.toString(image.hashCode())+"$error"; //$NON-NLS-1$
    Image image2 = EclipseNSISPlugin.getImageManager().getImage(name);
    if(image2 == null) {
        EclipseNSISPlugin.getImageManager().putImageDescriptor(name,
                new CompositeImageDescriptor(){
                    @Override
                    protected void drawCompositeImage(int width, int height)
                    {
                        drawImage(image.getImageData(),0,0);
                        drawImage(cErrorImageData,0,getSize().y-cErrorImageData.height);
                    }

                    @Override
                    protected Point getSize()
                    {
                        return new Point(image.getBounds().width,image.getBounds().height);
                    }
                });
        image2 = EclipseNSISPlugin.getImageManager().getImage(name);
    }
    return image2;
}
项目:eclipsensis    文件:NSISOutlineLabelProvider.java   
private Image decorateImage(NSISOutlineElement element)
{
    final Image image = (element.isRoot()?cRootImage:element.getIcon());
    final ImageData data;
    String hashCode;
    int severity = getElementSeverity(element);
    switch(severity) {
        case IMarker.SEVERITY_ERROR:
            hashCode = image.hashCode() + "$error"; //$NON-NLS-1$
            data = cErrorImageData;
            break;
        case IMarker.SEVERITY_WARNING:
            hashCode = image.hashCode() + "$warning"; //$NON-NLS-1$
            data = cWarningImageData;
            break;
        default:
            return image;
    }
    Image image2 = EclipseNSISPlugin.getImageManager().getImage(hashCode);
    if(image2 == null) {
        EclipseNSISPlugin.getImageManager().putImageDescriptor(hashCode,
                new CompositeImageDescriptor(){
                    @Override
                    protected void drawCompositeImage(int width, int height)
                    {
                        drawImage(image.getImageData(),0,0);
                        drawImage(data,0,getSize().y-data.height);
                    }

                    @Override
                    protected Point getSize()
                    {
                        return new Point(image.getBounds().width,image.getBounds().height);
                    }
                });
        image2 = EclipseNSISPlugin.getImageManager().getImage(hashCode);
    }
    return image2;
}