//# 0 errors, 75 messages
//#
/*
    //#PreferencesListCellRenderer.java:1:1: class: com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer
    //#PreferencesListCellRenderer.java:1:1: method: com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer.com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.addons.ui_swing.dialogs.prefs;

import com.dmdirc.config.prefs.PreferencesCategory;

import java.awt.Component;
import java.awt.Font;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;


/**
 * Prefs dialog list cell renderer.
 *
 * @since 0.6.3m1
 */
public class PreferencesListCellRenderer extends JLabel implements ListCellRenderer {

    /**
     * A version number for this class. It should be changed whenever the class
     * structure is changed (or anything else that would prevent serialized
     * objects being unserialized with the new class).
     */
    private static final long serialVersionUID = 1;
    /** Number of categories shown. */
    private final int numCats;
    /** Label map. */
    private Map<PreferencesCategory, JLabel> labelMap;
    
    /**
     * Instantiates a new prefs list cell renderer.
     *
     * @param numCats Number of categories in the list
     */
    public PreferencesListCellRenderer(final int numCats) {
    //#PreferencesListCellRenderer.java:60: method: void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer.com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)
    //#input(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): numCats
    //#input(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): this
    //#output(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): new HashMap(PreferencesListCellRenderer#1) num objects
    //#output(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): this.labelMap
    //#output(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): this.numCats
    //#new obj(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): new HashMap(PreferencesListCellRenderer#1)
    //#post(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): this.labelMap == &new HashMap(PreferencesListCellRenderer#1)
    //#post(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): this.numCats == numCats
    //#post(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): init'ed(this.numCats)
    //#post(void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)): new HashMap(PreferencesListCellRenderer#1) num objects == 1
        labelMap = new HashMap<PreferencesCategory, JLabel>();
        this.numCats = numCats;
    }
    //#PreferencesListCellRenderer.java:63: end of method: void com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer.com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer(int)

    /** {@inheritDoc} */
    @Override
    public final Component getListCellRendererComponent(final JList list,
            final Object value, final int index, final boolean isSelected,
            final boolean cellHasFocus) {
        final PreferencesCategory cat = (PreferencesCategory) value;
    //#PreferencesListCellRenderer.java:70: method: Component com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryLabel.java.awt.Color.GRAY
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryLabel.java.awt.Color.LIGHT_GRAY
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): index
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): isSelected
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): list
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): this
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): this.labelMap
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): this.numCats
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value
    //#output(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value
    //#pre[5] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): this.labelMap != null
    //#pre[3] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) list != null
    //#pre[7] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) value != null
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer:getFont(...)@77 != null
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer:getFont(...)@79 != null
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): java.util.Map:get(...)@74 != null
    //#post(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value != null
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:javax.swing.JLabel
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:net.miginfocom.layout.PlatformDefaults:getUnitValueX
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:net.miginfocom.layout.UnitValue:getValue
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.config.prefs.PreferencesCategory:getTitle
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:setText
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.config.prefs.PreferencesCategory:getIcon
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:javax.swing.SwingWorker
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel$IconLoader:execute
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.config.prefs.PreferencesCategory:getParent
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:getFont
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.awt.Font:getSize
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.Math:max
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.awt.Dimension
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:setPreferredSize
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:javax.swing.BorderFactory:createEmptyBorder
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:setBorder
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:javax.swing.JList:getBackground
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:setBackground
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:javax.swing.JList:getForeground
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:setForeground
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:setOpaque
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:setToolTipText
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.config.prefs.PreferencesCategory:getPath
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.config.prefs.PreferencesCategory:getSubcats
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.config.prefs.PreferencesCategory:isInline
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:javax.swing.BorderFactory:createMatteBorder
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.addons.ui_swing.dialogs.prefs.CategoryLabel:getBorder
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:javax.swing.BorderFactory:createCompoundBorder
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): isSelected: {0}, {1}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): java.util.Map:containsKey(...)@71: {1}, {0}
        if (!labelMap.containsKey(cat)) {
            labelMap.put(cat, new CategoryLabel(list, cat, numCats, index));
        }
        final JLabel label = labelMap.get(cat);

        if (isSelected) {
            label.setFont(getFont().deriveFont(Font.BOLD));
    //#PreferencesListCellRenderer.java:77: Warning: method not available - call not analyzed
    //#    call on Font com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer:getFont()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: Font com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer:getFont()
        } else {
            label.setFont(getFont().deriveFont(Font.PLAIN));
    //#PreferencesListCellRenderer.java:79: Warning: method not available - call not analyzed
    //#    call on Font com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer:getFont()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: Font com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer:getFont()
        }

        return label;
    //#PreferencesListCellRenderer.java:82: end of method: Component com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    }

}
    //#output(com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/dialogs/prefs/PreferencesListCellRenderer]
    //#output(com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component;
    //#post(com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/dialogs/prefs/PreferencesListCellRenderer] == &__Dispatch_Table
    //#post(com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component; == &getListCellRendererComponent
    //#PreferencesListCellRenderer.java:: end of method: com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer.com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer__static_init
    //#PreferencesListCellRenderer.java:: end of class: com.dmdirc.addons.ui_swing.dialogs.prefs.PreferencesListCellRenderer
