Java Code Examples for org.openide.util.ImageUtilities#mergeImages()

The following examples show how to use org.openide.util.ImageUtilities#mergeImages() . 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: PhpLogicalViewProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Image annotateImage(Image image) {
    Image badged = image;
    boolean first = true;
    PhpModule phpModule = project.getPhpModule();
    for (PhpFrameworkProvider frameworkProvider : project.getFrameworks()) {
        BadgeIcon badgeIcon = frameworkProvider.getBadgeIcon();
        final String frameworkName = frameworkProvider.getName(phpModule);
        if (badgeIcon != null) {
            badged = ImageUtilities.addToolTipToImage(badged, String.format(TOOLTIP, badgeIcon.getUrl(), frameworkName));
            if (first) {
                badged = ImageUtilities.mergeImages(badged, badgeIcon.getImage(), 15, 0);
                first = false;
            }
        } else {
            badged = ImageUtilities.addToolTipToImage(badged, String.format(TOOLTIP, Utils.PLACEHOLDER_BADGE_URL, frameworkName));
        }
    }
    return badged;
}
 
Example 2
Source File: TransactionNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Image getIcon(int type) {
       Image base;
// Get icon
if(method.equals(Constants.Http.GET)) {
           base = ImageUtilities.loadImage("org/netbeans/modules/web/monitor/client/icons/get.gif");
// Post icon
       } else if(method.equals(Constants.Http.POST)) {
           base = ImageUtilities.loadImage("org/netbeans/modules/web/monitor/client/icons/post.gif"); // NOI18N
// Other 
       } else {
           base = ImageUtilities.loadImage("org/netbeans/modules/web/monitor/client/icons/other.gif"); // NOI18N
       }
       
       Image badge;
       if (statusCode >= 400 || statusCode < 0) {
           badge = ImageUtilities.loadImage("org/netbeans/modules/web/monitor/client/icons/infoBadge.gif"); // NOI18N
       } else if (statusCode >= 300) {
           badge = ImageUtilities.loadImage("org/netbeans/modules/web/monitor/client/icons/warningBadge.gif"); // NOI18N
       } else if (statusCode >= 200) {
           return base;
       } else {
           badge = ImageUtilities.loadImage("org/netbeans/modules/web/monitor/client/icons/errorBadge.gif"); // NOI18N
       }
       return ImageUtilities.mergeImages(base, badge, 0, 0);
   }
 
Example 3
Source File: ProfilerSnapshotNPS.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image resolveIcon() {
    try {
        int snapshotType = getLoadedSnapshot().getType();
        switch (snapshotType) {
            case LoadedSnapshot.SNAPSHOT_TYPE_CPU:
                return ImageUtilities.mergeImages(CPU_ICON, NODE_BADGE, 0, 0);
            case LoadedSnapshot.SNAPSHOT_TYPE_CPU_JDBC:
                return ImageUtilities.mergeImages(JDBC_ICON, NODE_BADGE, 0, 0);
            case LoadedSnapshot.SNAPSHOT_TYPE_MEMORY_LIVENESS:
            case LoadedSnapshot.SNAPSHOT_TYPE_MEMORY_ALLOCATIONS:
            case LoadedSnapshot.SNAPSHOT_TYPE_MEMORY_SAMPLED:
                return ImageUtilities.mergeImages(MEMORY_ICON, NODE_BADGE, 0, 0);
            default:
                // Fallback icon, cannot return null - throws NPE in DataSourceView
                return ImageUtilities.mergeImages(SNAPSHOT_ICON, NODE_BADGE, 0, 0);
        }
    } catch (Exception e) {
        LOGGER.log(Level.FINE, "Failed to determine profiler snapshot type", e);  // NOI18N
        // Fallback icon, cannot return null - throws NPE in DataSourceView
        return ImageUtilities.mergeImages(SNAPSHOT_ICON, NODE_BADGE, 0, 0);
    }
}
 
Example 4
Source File: WebPagesNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Image getIcon(int param) {
    Image retValue = super.getIcon(param);
    if (isTopLevelNode) {
        retValue = ImageUtilities.mergeImages(retValue,
                                         ImageUtilities.loadImage("org/netbeans/modules/maven/j2ee/ui/resources/WebPagesBadge.png"), //NOI18N
                                         8, 8);
    } 
    return retValue;
}
 
Example 5
Source File: LogicalViewProviders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Image getIcon(int type) {
    final Icon icon = info.getIcon();
    final Image img = icon == null ?
        super.getIcon(type) :
        ImageUtilities.icon2Image(icon);
    return !broken && compileOnSaveDisabled ?
        ImageUtilities.mergeImages(img, compileOnSaveDisabledBadge, 8, 0) :
        img;
}
 
Example 6
Source File: DOMNodeAnnotator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Annotates the icon of the given node. If the node is associated with
 * some badge then this badge is merge into the node's icon. The node's
 * icon is left unmodified otherwise.
 * 
 * @param node node whose icon should be annotated.
 * @param originalImage original (not annotated) icon of the node.
 * @return annotated icon of the node.
 */
public Image annotateIcon(Node node, Image originalImage) {
    Image image = originalImage;
    Image badge = badges.get(node.getNodeId());
    if (badge != null) {
        int x = image.getWidth(null)-badge.getWidth(null);
        int y = image.getHeight(null)-badge.getHeight(null);
        image = ImageUtilities.mergeImages(image, badge, x, y);
    }
    return image;
}
 
Example 7
Source File: VCSAnnotationProviderTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Image annotateIcon(Image icon, VCSContext context) {
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    icon = ImageUtilities.mergeImages(icon, VCSAnnotationProviderTestCase.IMAGE_ANNOTATION, 16, 16);
    icon = ImageUtilities.addToolTipToImage(icon, "Annotated");
    return icon;
}
 
Example 8
Source File: DockerContainerNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Image badgeIcon(Image image, DockerContainer.Status status) {
    Image badge = null;
    switch (status) {
        case PAUSED:
            badge = ImageUtilities.loadImage(PAUSED_ICON);
            break;
        case RUNNING:
            badge = ImageUtilities.loadImage(RUNNING_ICON);
            break;
        default:
            break;
    }
    return badge != null ? ImageUtilities.mergeImages(image, badge, 13, 8) : image;
}
 
Example 9
Source File: InstanceNodeDecorator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Image badgeIcon(Image origImg) {
    Image badge = null;        
    switch (si.getServerState()) {
        case ServerInstance.STATE_WAITING : 
            badge = ImageUtilities.loadImage(WAITING_ICON);
            break;
        case ServerInstance.STATE_RUNNING : 
            badge = ImageUtilities.loadImage(RUNNING_ICON);
            break;
        case ServerInstance.STATE_DEBUGGING : 
            badge = ImageUtilities.loadImage(DEBUGGING_ICON);
            break;
        case ServerInstance.STATE_SUSPENDED : 
            badge = ImageUtilities.loadImage(SUSPENDED_ICON);
            break;
        case ServerInstance.STATE_PROFILING : 
            badge = ImageUtilities.loadImage(PROFILING_ICON);
            break;
        case ServerInstance.STATE_PROFILER_BLOCKING : 
            badge = ImageUtilities.loadImage(PROFILER_BLOCKING_ICON);
            break;
        case ServerInstance.STATE_PROFILER_STARTING : 
            badge = ImageUtilities.loadImage(WAITING_ICON);
            break;
        default:
            break;
    }
    return badge != null ? ImageUtilities.mergeImages(origImg, badge, 15, 8) : origImg;
}
 
Example 10
Source File: EjbContainerNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Image computeIcon(boolean opened, int type) {
    Image image;
    Node iconDelegate = getIconDelegate();
    if (opened) {
        image = iconDelegate != null ? iconDelegate.getOpenedIcon(type) : super.getOpenedIcon(type);
    } else {
        image = iconDelegate != null ? iconDelegate.getIcon(type) : super.getIcon(type);
    }
    Image badge = ImageUtilities.loadImage(EJB_BADGE);
    return ImageUtilities.mergeImages(image, badge, 7, 7);
}
 
Example 11
Source File: PackageRootNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Image computeIcon( boolean opened, int type ) {
    Image image;
    Icon icon = group.getIcon( opened );
    
    if ( icon == null ) {
        image = opened ? getDataFolderNodeDelegate().getOpenedIcon( type ) : 
                         getDataFolderNodeDelegate().getIcon( type );
        image = ImageUtilities.mergeImages(image, ImageUtilities.loadImage(PACKAGE_BADGE), 7, 7);
    }
    else {
        image = ImageUtilities.icon2Image(icon);
    }
    
    return image;        
}
 
Example 12
Source File: OthersRootNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Image getIcon(boolean opened) {
    Image badge = ImageUtilities.loadImage(OTHERS_BADGE, true); //NOI18N
    return ImageUtilities.mergeImages(NodeUtils.getTreeFolderIcon(opened), badge, 8, 8);
}
 
Example 13
Source File: BrowserUtils.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public static ImageIcon createLoopIcon(ImageIcon icon) {
    return new ImageIcon(ImageUtilities.mergeImages(icon.getImage(), ICON_LOOP.getImage(), 0, 0));
}
 
Example 14
Source File: ModulesNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Image getIcon(boolean opened) {
    Image badge = ImageUtilities.loadImage(MODULES_BADGE, true); //NOI18N
    return ImageUtilities.mergeImages(NodeUtils.getTreeFolderIcon(opened), badge, 8, 8);
}
 
Example 15
Source File: ComposerLibraries.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Image getIcon(int type) {
    return ImageUtilities.mergeImages(iconDelegate.getIcon(type), ImageUtilities.loadImage(LIBRARIES_BADGE), 7, 7);
}
 
Example 16
Source File: SrcNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Image getIcon(int type) {
    return ImageUtilities.mergeImages(super.getIcon(type), ImageUtilities.loadImage(PACKAGE_BADGE_IMAGE, false), 7, 7);
}
 
Example 17
Source File: ImportantFilesNodeFactory.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
private Image getIcon(boolean opened) {
    Image badge = ImageUtilities.loadImage("org/netbeans/modules/android/project/ui/resources/config-badge.gif", true);
    return ImageUtilities.mergeImages(UiUtils.getTreeFolderIcon(opened), badge, 8, 8);
}
 
Example 18
Source File: DependenciesNode.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
private Image computeIcon(boolean opened, int type) {
    Image image = UiUtils.getTreeFolderIcon(opened);
    image = ImageUtilities.mergeImages(image, ICON_BADGE, 7, 7);
    return image;
}
 
Example 19
Source File: BuildScriptsNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Image getIcon(boolean opened) {
    Image badge = ImageUtilities.loadImage(BS_BADGE, true); //NOI18N
    Image img = ImageUtilities.mergeImages(NodeUtils.getTreeFolderIcon(opened), badge, 8, 8);
    return img;
}
 
Example 20
Source File: Hk2InstanceNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
     * Copied along with icons from InstanceNodeDecorator in j2eeserver module.
     * 
     * @todo Could this be put in common server SPI to make it sharable?
     * 
     * @param origImg
     * @return
     */
    private Image badgeIcon(Image origImg) {
        Image badge = null;        
        switch (serverInstance.getServerState()) {
            case RUNNING:
                if(isDebug()) {
                    badge = ImageUtilities.loadImage(DEBUGGING_ICON);
                } else if (isProfile()) {
                    badge = ImageUtilities.loadImage(PROFILING_ICON);
                } else {
                    badge = ImageUtilities.loadImage(RUNNING_ICON);
                }
                break;
//            case RUNNING_JVM_DEBUG:
//                badge = ImageUtilities.loadImage(DEBUGGING_ICON);
//                break;
            case STARTING:
                badge = ImageUtilities.loadImage(WAITING_ICON);
                break;
            case STOPPED:
//                badge = ImageUtilities.loadImage(SUSPENDED_ICON);
                break;
            case STOPPED_JVM_BP:
            case STOPPED_JVM_PROFILER:
                badge = ImageUtilities.loadImage(SUSPENDED_ICON);
                break;
            case STOPPING:
                badge = ImageUtilities.loadImage(WAITING_ICON);
                break;
            // TODO profiler states
//            case PROFILING: 
//                badge = ImageUtilities.loadImage(PROFILING_ICON);
//                break;
//            case PROFILER_BLOCKING: 
//                badge = ImageUtilities.loadImage(PROFILER_BLOCKING_ICON);
//                break;
//            case PROFILER_STARTING: 
//                badge = ImageUtilities.loadImage(WAITING_ICON);
//                break;
        }
        return badge != null ? ImageUtilities.mergeImages(origImg, badge, 15, 8) : origImg;
    }