<commit_before>package net.coobird.paint.application;

import java.awt.Component;

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

import net.coobird.paint.brush.Brush;

/**
 * The {@code BrushListCellRenderer} class is the {@link ListCellRenderer} for
 * displaying {@link Brush} objects in a {@link JList}.
 * @author coobird
 *
 */
public class BrushListCellRenderer 
	extends JLabel
	implements ListCellRenderer
{
	/**
	 * Version string for this class, used for serialization. 
	 */
	private static final long serialVersionUID = -2298872884258272114L;
	
	private boolean showLabel;

	/**
	 * Constructs an instance of {@code BrushListCellRenderer}.
	 */
	public BrushListCellRenderer()
	{
		this(true);
	}
	
	public BrushListCellRenderer(boolean showLabel)
	{
		super();
		this.showLabel = showLabel;
		this.setOpaque(true);
	}
	
	/**
	 * Generates a {@link BrushListCellRenderer} object to display the
	 * information about a {@link Brush}.
	 */
	@Override
	public Component getListCellRendererComponent(
			JList list,
			Object value,
			int cell,
			boolean isSelected,
			boolean cellHasFocus
	)
	{
		if (value instanceof Brush)
		{
			Brush b = (Brush)value;
			
			if (showLabel)
			{
				this.setText(b.getName());
			}
			else
			{
				this.setToolTipText(b.getName());
			}
			
			this.setIcon(new ImageIcon(b.getThumbImage()));
			
			if (isSelected)
			{
				this.setOpaque(true);
				this.setBackground(list.getSelectionBackground());
				this.setForeground(list.getSelectionForeground());
			}
			else
			{
				this.setOpaque(true);
				this.setBackground(list.getBackground());
				this.setForeground(list.getForeground());
			}
		}
		else
		{
			this.setText("Not a Brush.");
		}

		return this;
	}
}<commit_msg>Added javadocs, improved no-icon rendering of a brush.<commit_after>package net.coobird.paint.application;

import java.awt.Component;

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

import net.coobird.paint.brush.Brush;

/**
 * The {@code BrushListCellRenderer} class is the {@link ListCellRenderer} for
 * displaying {@link Brush} objects in a {@link JList}.
 * @author coobird
 *
 */
public class BrushListCellRenderer 
	extends JLabel
	implements ListCellRenderer
{
	/**
	 * Version string for this class, used for serialization. 
	 */
	private static final long serialVersionUID = -1935391746701897141L;
	
	/**
	 * Specifies whether or not to display the brush name.
	 */
	private boolean showLabel;

	/**
	 * Constructs an instance of {@code BrushListCellRenderer}.
	 * The brush name will be displayed.
	 */
	public BrushListCellRenderer()
	{
		this(true);
	}
	
	/**
	 * Constructor which specifies whether or not to display the name of the
	 * brush on the cell.
	 *  
	 * @param showLabel		Whether or not to display the brush name.
	 */
	public BrushListCellRenderer(boolean showLabel)
	{
		super();
		this.showLabel = showLabel;
		this.setOpaque(true);
	}
	
	/**
	 * Generates a {@link BrushListCellRenderer} object to display the
	 * information about a {@link Brush}.
	 */
	@Override
	public Component getListCellRendererComponent(
			JList list,
			Object value,
			int cell,
			boolean isSelected,
			boolean cellHasFocus
	)
	{
		if (value instanceof Brush)
		{
			Brush b = (Brush)value;
			
			if (showLabel)
			{
				this.setToolTipText("");
				this.setText(b.getName());
			}
			else
			{
				this.setToolTipText(b.getName());
				this.setText("");
			}
			
			this.setIcon(new ImageIcon(b.getThumbImage()));
			
		}
		else
		{
			this.setIcon(null);
			this.setText("Not a Brush.");
		}
		
		if (isSelected)
		{
			this.setOpaque(true);
			this.setBackground(list.getSelectionBackground());
			this.setForeground(list.getSelectionForeground());
		}
		else
		{
			this.setOpaque(true);
			this.setBackground(list.getBackground());
			this.setForeground(list.getForeground());
		}

		return this;
	}
}
{'fraction_non_alphanumeric': 0.11352838209552388, 'fraction_numerical': 0.009502375593898474, 'mean_word_length': 3.5045045045045047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1790361', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1283, 'n_words': 309}