Search in sources :

Example 1 with UIIcon

use of org.freeplane.features.icon.UIIcon in project freeplane by freeplane.

the class MainView method updateIcons.

void updateIcons(final NodeView node) {
    // setHorizontalTextPosition(node.isLeft() ? SwingConstants.LEADING : SwingConstants.TRAILING);
    final MultipleImage iconImages = new MultipleImage();
    /* fc, 06.10.2003: images? */
    final NodeModel model = node.getModel();
    for (final UIIcon icon : IconController.getController().getStateIcons(model)) {
        iconImages.addImage(icon.getIcon());
    }
    final ModeController modeController = getNodeView().getMap().getModeController();
    final Collection<MindIcon> icons = IconController.getController(modeController).getIcons(model);
    for (final MindIcon myIcon : icons) {
        iconImages.addImage(myIcon.getIcon());
    }
    addOwnIcons(iconImages, model);
    setIcon((iconImages.getImageCount() > 0 ? iconImages : null));
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MultipleImage(org.freeplane.core.ui.components.MultipleImage) MindIcon(org.freeplane.features.icon.MindIcon) ModeController(org.freeplane.features.mode.ModeController) UIIcon(org.freeplane.features.icon.UIIcon)

Example 2 with UIIcon

use of org.freeplane.features.icon.UIIcon in project freeplane by freeplane.

the class MainView method getUIIconAt.

public UIIcon getUIIconAt(Point coordinate) {
    Icon icon = getIcon();
    if (icon instanceof MultipleImage) {
        Rectangle iconRectangle = getIconRectangle();
        Point transformedToIconCoordinate = new Point(coordinate);
        transformedToIconCoordinate.translate(-iconRectangle.x, -iconRectangle.y);
        return ((MultipleImage) icon).getUIIconAt(transformedToIconCoordinate);
    } else
        return null;
}
Also used : MultipleImage(org.freeplane.core.ui.components.MultipleImage) Rectangle(java.awt.Rectangle) Icon(javax.swing.Icon) UIIcon(org.freeplane.features.icon.UIIcon) MindIcon(org.freeplane.features.icon.MindIcon) Point(java.awt.Point)

Example 3 with UIIcon

use of org.freeplane.features.icon.UIIcon in project freeplane by freeplane.

the class ExportWithXSLT method copyIconsToDirectory.

/**
 * @param map
 */
static void copyIconsToDirectory(final MapModel map, final String directoryName) {
    final ListModel icons = map.getIconRegistry().getIconsAsListModel();
    for (int i = 0; i < icons.getSize(); i++) {
        final UIIcon icon = (UIIcon) icons.getElementAt(i);
        final String iconName = icon.getName();
        final StringBuilder sb = new StringBuilder(directoryName);
        final int lastIndexOfSeparator = iconName.lastIndexOf('/');
        if (lastIndexOfSeparator != -1) {
            sb.append(File.separatorChar);
            sb.append(iconName.substring(0, lastIndexOfSeparator));
        }
        final File destinationDirectory = new File(sb.toString());
        destinationDirectory.mkdirs();
        FileUtils.copyFromURL(icon.getUrl(), destinationDirectory);
    }
}
Also used : ListModel(javax.swing.ListModel) File(java.io.File) UIIcon(org.freeplane.features.icon.UIIcon)

Example 4 with UIIcon

use of org.freeplane.features.icon.UIIcon in project freeplane by freeplane.

the class DefaultConditionRenderer method getCellRendererComponent.

private Component getCellRendererComponent(final Object value, final boolean isSelected) {
    final JComponent component;
    if (value == null) {
        component = new JLabel(noValueText);
    } else if (value instanceof UIIcon) {
        component = new JLabel(((UIIcon) value).getIcon());
    } else if (value instanceof ASelectableCondition) {
        final ASelectableCondition cond = (ASelectableCondition) value;
        final String userName = cond.getUserName();
        if (renderNamedConditions || userName == null)
            component = cond.getListCellRendererComponent();
        else {
            component = new JLabel(userName);
            component.setToolTipText(cond.createDescription());
        }
    } else
        component = new JLabel(value.toString());
    component.setOpaque(true);
    component.setAlignmentX(Component.LEFT_ALIGNMENT);
    return component;
}
Also used : JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) UIIcon(org.freeplane.features.icon.UIIcon)

Example 5 with UIIcon

use of org.freeplane.features.icon.UIIcon in project freeplane by freeplane.

the class IconStoreFactory method setIconGroups.

private static void setIconGroups(final IconStore iconStore) {
    final String[] groupNames = RESOURCE_CONTROLLER.getProperty(GROUP_NAMES_KEY).split(SEPARATOR);
    for (final String groupName : groupNames) {
        final String description = TextUtils.getText(String.format(GROUP_DESC_KEY, groupName));
        List<MindIcon> icons;
        UIIcon groupIcon = null;
        if ("user".equals(groupName)) {
            icons = IconStoreFactory.getUserIcons();
            groupIcon = MindIconFactory.create("user_icon");
        } else {
            final String groupIconName = RESOURCE_CONTROLLER.getProperty(String.format(GROUP_ICON_KEY, groupName));
            final Map<String, MindIcon> iconMap = IconStoreFactory.getIcons(groupName);
            groupIcon = iconMap.get(groupIconName);
            icons = new ArrayList<MindIcon>(iconMap.values());
        }
        if (groupIcon == null) {
            groupIcon = icons.size() > 0 ? icons.get(0) : IconNotFound.instance();
        }
        iconStore.addGroup(new IconGroup(groupName, groupIcon, description, icons));
    }
}
Also used : IconGroup(org.freeplane.features.icon.IconGroup) MindIcon(org.freeplane.features.icon.MindIcon) UIIcon(org.freeplane.features.icon.UIIcon)

Aggregations

UIIcon (org.freeplane.features.icon.UIIcon)5 MindIcon (org.freeplane.features.icon.MindIcon)3 MultipleImage (org.freeplane.core.ui.components.MultipleImage)2 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 File (java.io.File)1 Icon (javax.swing.Icon)1 JComponent (javax.swing.JComponent)1 JLabel (javax.swing.JLabel)1 ListModel (javax.swing.ListModel)1 IconGroup (org.freeplane.features.icon.IconGroup)1 NodeModel (org.freeplane.features.map.NodeModel)1 ModeController (org.freeplane.features.mode.ModeController)1