File: IconRenderer.java

package info (click to toggle)
gpsprune 17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,984 kB
  • ctags: 5,218
  • sloc: java: 39,403; sh: 25; makefile: 17; python: 15
file content (37 lines) | stat: -rw-r--r-- 945 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package tim.prune.function.weather;

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

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.TableCellRenderer;

import tim.prune.gui.IconManager;

/**
 * Class to render the weather icons in the table
 */
public class IconRenderer extends JLabel implements TableCellRenderer
{
	/** Get the renderer component for the given row, column and value */
	public Component getTableCellRendererComponent(JTable inTable, Object inValue, boolean inIsSelected,
		boolean inHasFocus, int inRow, int inColumn)
	{
		if (inValue != null) {
			setIcon(IconManager.getImageIcon("weather-" + inValue.toString()));
			setHorizontalAlignment(SwingConstants.CENTER);
		}
		else {
			setIcon(null);
			setText("");
		}
		return this;
	}

	/** Override the minimum size method */
	public Dimension getMinimumSize() {
		return new Dimension(52, 52);
	}
}