/** * Sets the active icon set name. If the icon set is not found, IllegalArgumentException will be thrown. * * @param activeIconSetName the new active icon set name. * * @throws IllegalArgumentException if the icon set is not found by that name. */ public void setActiveIconSetName(String activeIconSetName) { IconSet iconSet = findIconSet(activeIconSetName); if (iconSet == null) { throw new IllegalArgumentException("Icon set \"" + activeIconSetName + "\" not found"); } _activeIconSet = iconSet; _activeIconSetName = activeIconSetName; }
/** * Gets the ImageIcon. * * @param iconName the icon name as defined in IconSet. * * @return the ImageIcon. */ public ImageIcon getImageIcon(String iconName) { return getImageIcon(iconName, 16); }
/** * Gets the ImageIcon. * * @param iconName the icon name as defined in IconSet. * @param size the icon size. If the size is not available, it will find the closest size that is larger * than the requested size. * @param overlayIconName the overlay icon name as defined in IconSet. * @param location the location as defined in SwingConstants - CENTER, NORTH, SOUTH, WEST, EAST, NORTH_EAST, * NORTH_WEST, SOUTH_WEST and SOUTH_EAST. * * @return the ImageIcon. */ public ImageIcon getOverlayImageIcon(String iconName, int size, String overlayIconName, int location) { return getOverlayImageIcon(iconName, size, overlayIconName, location, new Insets(0, 0, 0, 0)); }
public void add(String name, int[] sizes, String packageName) { if (_availableStyles == null) { _availableStyles = new HashMap<String, IconSet>(); } _availableStyles.put(name, new IconSet(name, sizes, packageName)); if (_availableStyles.size() == 1) { setActiveIconSetName(name); } }
/** * Gets the ImageIcon with an overlay icon on it. * * @param iconName the icon name as defined in IconSet. * @param size the icon size. If the size is not available, it will find the closest size that is larger * than the requested size. * @param overlayIconName the overlay icon name as defined in IconSet. The overlay icon doesn't have to be in the * overlay category. It can be any regular icon. Of course the size of the overlay icon * should be smaller than the size of the regular icon. * @param overlayIconSize the size of the overlay icon. * @param location the location as defined in SwingConstants - CENTER, NORTH, SOUTH, WEST, EAST, NORTH_EAST, * NORTH_WEST, SOUTH_WEST and SOUTH_EAST. * @param insets the margin of the overlay icon to the border of the icon. * * @return the ImageIcon. */ public ImageIcon getOverlayImageIcon(String iconName, int size, String overlayIconName, int overlayIconSize, int location, Insets insets) { ImageIcon icon = getImageIcon(iconName, size); if (icon == null) { return null; } ImageIcon overlay = getImageIcon(overlayIconName, overlayIconSize); if (overlay == null) { return icon; } return IconsFactory.getOverlayIcon(null, icon, overlay, location, insets); }
/** * Gets the ImageIcon with an overlay icon on it. * * @param iconName the icon name as defined in IconSet. * @param size the icon size. If the size is not available, it will find the closest size that is larger * than the requested size. * @param overlayIconName the overlay icon name as defined in IconSet. The icons in the Overlay category are half * the size of the regular icons. So this method will take the middle portion of the overlay * icon specified in the overlayIconName and use it as the overlay icon. * @param location the location as defined in SwingConstants - CENTER, NORTH, SOUTH, WEST, EAST, NORTH_EAST, * NORTH_WEST, SOUTH_WEST and SOUTH_EAST. * @param insets the margin of the overlay icon to the border of the icon. * * @return the ImageIcon. */ public ImageIcon getOverlayImageIcon(String iconName, int size, String overlayIconName, int location, Insets insets) { ImageIcon icon = getImageIcon(iconName, size); if (icon == null) { return null; } ImageIcon overlay = getImageIcon(overlayIconName, size); if (overlay == null) { return icon; } // grab the middle portion of the overlay icon only overlay = IconsFactory.getIcon(null, overlay, size / 4, size / 4, size / 2, size / 2); return IconsFactory.getOverlayIcon(null, icon, overlay, location, insets); }