//# 0 errors, 35 messages
//#
/*
    //#ColourRenderer.java:1:1: class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#ColourRenderer.java:1:1: method: com.dmdirc.addons.nickcolours.ColourRenderer.com.dmdirc.addons.nickcolours.ColourRenderer__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.nickcolours;

import com.dmdirc.ui.messages.ColourManager;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * Provides a colour renderer for JTables.
 *
 * @author Chris
 */
public class ColourRenderer extends DefaultTableCellRenderer {
    
    /**
     * 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;
    
    /**
     * Creates a new instance of ColourRenderer.
     */
    public ColourRenderer() {
        super();
    //#ColourRenderer.java:51: method: void com.dmdirc.addons.nickcolours.ColourRenderer.com.dmdirc.addons.nickcolours.ColourRenderer()
    //#input(void com.dmdirc.addons.nickcolours.ColourRenderer()): this
        
        setOpaque(true);
    //#ColourRenderer.java:53: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setOpaque(bool)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: void com.dmdirc.addons.nickcolours.ColourRenderer()
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setOpaque(bool)
    }
    //#ColourRenderer.java:54: end of method: void com.dmdirc.addons.nickcolours.ColourRenderer.com.dmdirc.addons.nickcolours.ColourRenderer()
    
    /** {@inheritDoc} */
    @Override
    public Component getTableCellRendererComponent(final JTable table,
            final Object value, final boolean isSelected,
            final boolean hasFocus, final int row, final int column) {
        Color colour = null;
    //#ColourRenderer.java:61: method: Component com.dmdirc.addons.nickcolours.ColourRenderer.getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#input(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): java.awt.Color.BLACK
    //#input(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): java.awt.Color.GRAY
    //#input(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): table
    //#input(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): this
    //#input(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): value
    //#output(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): return_value
    //#pre[1] (Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): (soft) table != null
    //#presumption(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): init'ed(java.awt.Color.BLACK)
    //#presumption(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): init'ed(java.awt.Color.GRAY)
    //#post(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): return_value == this
    //#post(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): return_value != null
    //#test_vector(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): value: Addr_Set{null}, Inverse{null}
    //#test_vector(Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)): java.lang.String:isEmpty(...)@62: {1}, {0}
        if (value != null && !((String) value).isEmpty()) {
            colour = ColourManager.parseColour((String) value, null);
    //#ColourRenderer.java:63: Warning: method not available - call not analyzed
    //#    call on Color com.dmdirc.ui.messages.ColourManager:parseColour(String, Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: Color com.dmdirc.ui.messages.ColourManager:parseColour(String, Color)
        }
        
        setHorizontalAlignment(CENTER);
    //#ColourRenderer.java:66: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setHorizontalAlignment(int)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setHorizontalAlignment(int)
        
        if (colour == null) {
            setBorder(new LineBorder(Color.GRAY));
    //#ColourRenderer.java:69: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setBorder(Border)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setBorder(Border)
            setText("Not Set");
    //#ColourRenderer.java:70: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setText(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setText(String)
            setBackground(table.getBackground());
    //#ColourRenderer.java:71: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setBackground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setBackground(Color)
        } else {
            setBorder(new LineBorder(Color.BLACK));
    //#ColourRenderer.java:73: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setBorder(Border)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setBorder(Border)
            setText("");
    //#ColourRenderer.java:74: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setText(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setText(String)
            setBackground(colour);
    //#ColourRenderer.java:75: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.nickcolours.ColourRenderer:setBackground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.nickcolours.ColourRenderer
    //#    method: Component getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    //#    unanalyzed callee: void com.dmdirc.addons.nickcolours.ColourRenderer:setBackground(Color)
        }
        
        return this;
    //#ColourRenderer.java:78: end of method: Component com.dmdirc.addons.nickcolours.ColourRenderer.getTableCellRendererComponent(JTable, Object, bool, bool, int, int)
    }
    
}
    //#output(com.dmdirc.addons.nickcolours.ColourRenderer__static_init): __Descendant_Table[com/dmdirc/addons/nickcolours/ColourRenderer]
    //#output(com.dmdirc.addons.nickcolours.ColourRenderer__static_init): __Dispatch_Table.getTableCellRendererComponent(Ljavax/swing/JTable;Ljava/lang/Object;ZZII)Ljava/awt/Component;
    //#post(com.dmdirc.addons.nickcolours.ColourRenderer__static_init): __Descendant_Table[com/dmdirc/addons/nickcolours/ColourRenderer] == &__Dispatch_Table
    //#post(com.dmdirc.addons.nickcolours.ColourRenderer__static_init): __Dispatch_Table.getTableCellRendererComponent(Ljavax/swing/JTable;Ljava/lang/Object;ZZII)Ljava/awt/Component; == &getTableCellRendererComponent
    //#ColourRenderer.java:: end of method: com.dmdirc.addons.nickcolours.ColourRenderer.com.dmdirc.addons.nickcolours.ColourRenderer__static_init
    //#ColourRenderer.java:: end of class: com.dmdirc.addons.nickcolours.ColourRenderer
