File: IconRenderer.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (44 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download | duplicates (4)
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
38
39
40
41
42
43
44
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
{
	private final IconManager _iconManager;

	/** @param inIconManager icon manager for weather symbols */
	public IconRenderer(IconManager inIconManager) {
		_iconManager = inIconManager;
	}

	/** 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);
	}
}