All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bibliothek.gui.dock.util.IconManager Maven / Gradle / Ivy

The newest version!
/*
 * Bibliothek - DockingFrames
 * Library built on Java/Swing, allows the user to "drag and drop"
 * panels containing any Swing-Component the developer likes to add.
 * 
 * Copyright (C) 2007 Benjamin Sigg
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Benjamin Sigg
 * [email protected]
 * CH - Switzerland
 */

package bibliothek.gui.dock.util;

import java.awt.Component;
import java.awt.Dimension;

import javax.swing.Icon;

import bibliothek.gui.DockController;
import bibliothek.gui.DockUI;
import bibliothek.gui.dock.action.DropDownAction;
import bibliothek.gui.dock.themes.basic.action.dropdown.DropDownIcon;
import bibliothek.gui.dock.util.icon.DockIcon;
import bibliothek.gui.dock.util.icon.DockIconBridge;
import bibliothek.gui.dock.util.property.ConstantPropertyFactory;

/**
 * A map of icons which are used by various objects. The icon is stored
 * under a given String-key. Every icon can be stored with three different
 * {@link Priority priorities}, only the icon with the highest priority
 * will be returned.
* Clients have to add an {@link DockIcon} in order to read values from this * manager.
* The default icons are stored as png files alongside the framework, the "icons.ini" files * tells what keys are used for the icons. Additional keys for icons are: *
    *
  • {@link DropDownIcon#ICON_KEY}: this icon is painted for {@link DropDownAction}s, it is * a small triangle pointing downwards.
  • *
  • {@link DockUI#OVERFLOW_MENU_ICON}: the icon used for the menu that is created if there are too many buttons * of actions in a row.
  • *
* @author Benjamin Sigg */ public class IconManager extends UIProperties{ /** * What size the framework should expect the smallest icon to be. This number is used to calculate the * minimum and the preferred size of various {@link Component}s. This is not a hard boundary, just expect any * icon smaller than this constant to be surrounded by some addional empty space. The default size * is 16x16 pixels. */ public static final PropertyKey MINIMUM_ICON_SIZE = new PropertyKey( "dock.icon.minimumSize", new ConstantPropertyFactory( new Dimension( 16, 16 )), true ); /** * Creates a new {@link IconManager}. * @param controller the owner of this map */ public IconManager( DockController controller ){ super( controller ); } /** * Stores an icon. * @param key the key of the icon * @param priority the priority, where {@link Priority#CLIENT} is the * highest, {@link Priority#DEFAULT} the lowest. Icons stored with the * same key but another priority are not deleted. * @param icon the icon, null if the icon should be removed */ public void setIcon( String key, Priority priority, Icon icon ){ put( priority, key, icon ); } /** * Sets an icon with default-priority. * @param key the key of the icon * @param icon the icon or null */ public void setIconDefault( String key, Icon icon ){ setIcon( key, Priority.DEFAULT, icon ); } /** * Sets an icon with theme-priority. * @param key the key of the icon * @param icon the icon or null */ public void setIconTheme( String key, Icon icon ){ setIcon( key, Priority.THEME, icon ); } /** * Sets an icon with client-priority. * @param key the key of the icon * @param icon the icon or null */ public void setIconClient( String key, Icon icon ){ setIcon( key, Priority.CLIENT, icon ); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy