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

The following examples show how to use org.openide.util.ImageUtilities#image2Icon() . 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: SkyboxVisualPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void multipleTexBottomLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexBottomLoadButtonActionPerformed
    Component view = editorBottom.getCustomEditor();
    view.setVisible(true);
    if (editorBottom.getValue() != null) {
        Texture tex = (Texture) editorBottom.getValue();
        String selected = tex.getKey().getName();

        if (selected.toLowerCase().endsWith(".dds")) {
            if (ddsPreview == null) {
                ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
            }
            ddsPreview.requestPreview(selected, "", 80, 80, bottomPic, null);

        } else {
            Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
            bottomPic.setIcon(newicon);
        }
    }
}
 
Example 2
Source File: SkyboxVisualPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void multipleTexTopLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexTopLoadButtonActionPerformed
    Component view = editorTop.getCustomEditor();
    view.setVisible(true);
    if (editorTop.getValue() != null) {
        Texture tex = (Texture) editorTop.getValue();
        String selected = tex.getKey().getName();

        if (selected.toLowerCase().endsWith(".dds")) {
            if (ddsPreview == null) {
                ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
            }
            ddsPreview.requestPreview(selected, "", 80, 80, topPic, null);

        } else {
            Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
            topPic.setIcon(newicon);
        }
    }
}
 
Example 3
Source File: SkyboxVisualPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void multipleTexWestLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexWestLoadButtonActionPerformed
    Component view = editorWest.getCustomEditor();
    view.setVisible(true);
    if (editorWest.getValue() != null) {
        Texture tex = (Texture) editorWest.getValue();
        String selected = tex.getKey().getName();

        if (selected.toLowerCase().endsWith(".dds")) {
            if (ddsPreview == null) {
                ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
            }
            ddsPreview.requestPreview(selected, "", 80, 80, westPic, null);

        } else {
            Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
            westPic.setIcon(newicon);
        }
    }
}
 
Example 4
Source File: ArtifactTreeElement.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override public Icon getIcon() {
    if (!art.getVersion().isEmpty()) {
        try {
            Project p = FileOwnerQuery.getOwner(RepositoryUtil.downloadArtifact(art).toURI());
            if (p != null) {
                return ProjectUtils.getInformation(p).getIcon();
            }
        } catch (Exception x) {
            LOG.log(Level.FINE, null, "could not check project icon for " + art);
        }
        return ImageUtilities.loadImageIcon(IconResources.ICON_DEPENDENCY_JAR, true);
    } else if (!art.getArtifactId().isEmpty()) {
        // XXX should probably be moved into NodeUtils
        return ImageUtilities.loadImageIcon("org/netbeans/modules/maven/repository/ArtifactBadge.png", true);
    } else {
        return ImageUtilities.image2Icon(NodeUtils.getTreeFolderIcon(false));
    }
}
 
Example 5
Source File: BreadCrumbComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void configureForNode(Node node) {
    renderer.reset();
    
    Image nodeIcon = node.getIcon(BeanInfo.ICON_COLOR_16x16);
    Icon icon = nodeIcon != null && nodeIcon != BreadcrumbsController.NO_ICON ? ImageUtilities.image2Icon(nodeIcon) : null;
    int width = icon != null ? icon.getIconWidth() : 0;
    if (width > 0) {
        renderer.setIcon(icon);
        renderer.setIconTextGap(ICON_TEXT_SEPARATOR);
    } else {
        renderer.setIcon(null);
        renderer.setIconTextGap(0);
    }
    String html = node.getHtmlDisplayName();
    if (html != null) {
        renderer.setHtml(true);
        renderer.setText(html);
    } else {
        renderer.setHtml(false);
        renderer.setText(node.getDisplayName());
    }
    renderer.setFont(getFont());
}
 
Example 6
Source File: BookmarkNodeRenderer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    Icon icon = null;
    BookmarksTableModel model = (BookmarksTableModel) table.getModel();
    BookmarkNode bNode = model.getEntry(row);
    BookmarkInfo bookmark = bNode.getBookmarkInfo();
    Node fNode = bNode.getParentNode();
    if (fNode != null) {
        if (!isSelected) {
            String text = fNode.getHtmlDisplayName();
            if (text != null) {
                text = bookmark.getDescription(text, forHistoryPopup, forHistoryPopup, true);
                setText("<html>" + text + "</html>");
            } // else leave original text set by "super"
        }
        Image image = fNode.getIcon(BeanInfo.ICON_COLOR_16x16);
        if (image != null) {
            icon = ImageUtilities.image2Icon(image);
        }
    }
    setIcon(icon);
    return this;

}
 
Example 7
Source File: MavenSourcesImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages("SG_Root_not_defined=<Root not defined>")
        OtherGroup(NbMavenProjectImpl p, FileObject rootFold, String nm, String displayNm, boolean test) {
            project = p;
            rootFolder = rootFold;
            rootFile = FileUtil.toFile(rootFolder);
            resource = checkResource(rootFold, 
                    test ? project.getOriginalMavenProject().getTestResources() :
                           project.getOriginalMavenProject().getResources());
            if (resource != null) {
                Image badge = ImageUtilities.loadImage(OTHERS_BADGE, true); //NOI18N
//                ImageUtilities.addToolTipToImage(badge, "Resource root as defined in POM.");
                icon = ImageUtilities.image2Icon(ImageUtilities.mergeImages(NodeUtils.getTreeFolderIcon(false), badge, 8, 8));
                openedIcon = ImageUtilities.image2Icon(ImageUtilities.mergeImages(NodeUtils.getTreeFolderIcon(true), badge, 8, 8));
                name = FileUtilities.relativizeFile(FileUtil.toFile(project.getProjectDirectory()), FileUtilities.convertStringToFile(resource.getDirectory()));
                displayName = name;
            } else {
                icon = ImageUtilities.image2Icon(NodeUtils.getTreeFolderIcon(false));
                openedIcon = ImageUtilities.image2Icon(NodeUtils.getTreeFolderIcon(true));
                name = nm;
                displayName = displayNm != null ? displayNm : SG_Root_not_defined();
            }
        }
 
Example 8
Source File: SkyboxVisualPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void multipleTexSouthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexSouthLoadButtonActionPerformed
    Component view = editorSouth.getCustomEditor();
    view.setVisible(true);
    if (editorSouth.getValue() != null) {
        Texture tex = (Texture) editorSouth.getValue();
        String selected = tex.getKey().getName();

        if (selected.toLowerCase().endsWith(".dds")) {
            if (ddsPreview == null) {
                ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
            }
            ddsPreview.requestPreview(selected, "", 80, 80, southPic, null);

        } else {
            Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
            southPic.setIcon(newicon);
        }
    }
}
 
Example 9
Source File: SearchScopeNodeSelection.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Icon getIcon() {
    Node[] nodes = getNodes();
    if (nodes.length > 1) {
        return MULTI_SELECTION_ICON;
    } else if (nodes.length == 1 && nodes[0] != null) {
        Node n = nodes[0];
        Image image = n.getIcon(BeanInfo.ICON_COLOR_16x16);
        if (image != null) {
            return ImageUtilities.image2Icon(image);
        } else {
            return null;
        }
    } else {
        return null;
    }
}
 
Example 10
Source File: AndroidNodes.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static SourceGroup createLibrarySourceGroup(String name, FileObject cpRoot) {
    Icon openedIcon = cpRoot != null
            ? ImageUtilities.loadImageIcon(ARCHIVE_ICON, true)
            : ImageUtilities.image2Icon(UiUtils.getTreeFolderIcon(true));
    Icon closedIcon = cpRoot != null
            ? ImageUtilities.loadImageIcon(ARCHIVE_ICON, true)
            : ImageUtilities.image2Icon(UiUtils.getTreeFolderIcon(false));
    return new LibrariesSourceGroup(cpRoot, name, closedIcon, openedIcon);
}
 
Example 11
Source File: MethodsFeatureModes.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Icon getAddIcon() {
    String iconMask = LanguageIcons.METHOD;
    Image baseIcon = Icons.getImage(iconMask);
    Image addBadge = Icons.getImage(GeneralIcons.BADGE_ADD);
    Image addImage = ImageUtilities.mergeImages(baseIcon, addBadge, 0, 0);
    return ImageUtilities.image2Icon(addImage);
}
 
Example 12
Source File: MethodsFeatureModes.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Icon getAddIcon() {
    String iconMask = LanguageIcons.CLASS;
    Image baseIcon = Icons.getImage(iconMask);
    Image addBadge = Icons.getImage(GeneralIcons.BADGE_ADD);
    Image addImage = ImageUtilities.mergeImages(baseIcon, addBadge, 0, 0);
    return ImageUtilities.image2Icon(addImage);
}
 
Example 13
Source File: ExtIconTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testByteConversions() {
    ExtIcon ext = new ExtIcon();
    URL res = getClass().getClassLoader().getResource("org/netbeans/modules/project/ui/module.gif");
    assertNotNull(res);
    //#138000
    Image img = ImageUtilities.loadImage("org/netbeans/modules/project/ui/module.gif");
    img = ImageUtilities.addToolTipToImage(img, "XXX");
    Icon icon = ImageUtilities.image2Icon(img);
    ext.setIcon(icon);
    try {
        byte[] bytes1 = ext.getBytes();
        ExtIcon ext2 = new ExtIcon(bytes1);
        byte[] bytes2 = ext2.getBytes();
        ExtIcon ext3 = new ExtIcon(bytes2);
        byte[] bytes3 = ext3.getBytes();
        
        assertEquals(bytes1.length, bytes2.length);
        assertEquals(bytes3.length, bytes3.length);
        for (int i = 0; i < bytes1.length; i++) {
            assertEquals("Non equals at position " + i,bytes1[i], bytes2[i]);
            assertEquals("Non equals at position " + i,bytes1[i], bytes3[i]);
        }
    }
    catch (IOException ex) {
        Exceptions.printStackTrace(ex);
        fail();
    }
    
}
 
Example 14
Source File: OverrideDescription.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Icon getIcon() {
    Image badge;

    if (overriddenFlag) {
        badge = ImageUtilities.loadImage("org/netbeans/modules/csl/navigation/resources/is-overridden-badge.png");
    } else {
        badge = ImageUtilities.loadImage("org/netbeans/modules/csl/navigation/resources/overrides-badge.png");
    }

    ImageIcon icon = Icons.getElementIcon(location.getElement().getKind(), location.getElement().getModifiers());

    return ImageUtilities.image2Icon(ImageUtilities.mergeImages(ImageUtilities.icon2Image(icon), badge, 16, 0));
}
 
Example 15
Source File: DashboardUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Icon getTaskIcon(IssueImpl issue) {
    Image priorityIcon = issue.getPriorityIcon();
    Image scheduleIcon = getScheduleIcon(issue);
    if (scheduleIcon != null) {
        return ImageUtilities.image2Icon(ImageUtilities.mergeImages(priorityIcon, scheduleIcon, 0, 0));
    }
    return ImageUtilities.image2Icon(priorityIcon);
}
 
Example 16
Source File: ScreenshotComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JButton createZoomOutButton() {
    JButton outButton = new JButton(ImageUtilities.image2Icon(ImageUtilities.loadImage("org/netbeans/modules/debugger/jpda/visual/resources/zoomOut.gif")));
    outButton.setToolTipText(NbBundle.getMessage(ScreenshotComponent.class, "TLTP_ZoomOut"));
    outButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ScreenshotComponent.class, "LBL_ZoomOutA11yDescr"));
    outButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            canvas.zoomOut();
        }
    });
    outButton.setAlignmentX(CENTER_ALIGNMENT);
    return outButton;
}
 
Example 17
Source File: MethodsFeatureModes.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected Icon getAddIcon() {
    String iconMask = LanguageIcons.METHOD;
    Image baseIcon = Icons.getImage(iconMask);
    Image addBadge = Icons.getImage(GeneralIcons.BADGE_ADD);
    Image addImage = ImageUtilities.mergeImages(baseIcon, addBadge, 0, 0);
    return ImageUtilities.image2Icon(addImage);
}
 
Example 18
Source File: BrowserMenu.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Icon getIcon() {
    return ImageUtilities.image2Icon( browser.getIconImage(false) );
}
 
Example 19
Source File: Utilities.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Make an icon for the provided iconBase.
 */
private static Icon makeIcon(String iconBase) {
    return ImageUtilities.image2Icon(
            ImageUtilities.loadImageIcon(iconBase, false).getImage());
}
 
Example 20
Source File: VisualGraphTopComponent.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
    final Schema schema = graph.getSchema();
    final Icon icon = ImageUtilities.image2Icon(getBufferedImageForSchema(schema, false));
    icon.paintIcon(c, g, x, y);
}