X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fweather%2FIconRenderer.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fweather%2FIconRenderer.java;h=caeb184ff35dac428e66cebd1ebd6f4a8fd91a6c;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/weather/IconRenderer.java b/src/tim/prune/function/weather/IconRenderer.java new file mode 100644 index 0000000..caeb184 --- /dev/null +++ b/src/tim/prune/function/weather/IconRenderer.java @@ -0,0 +1,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); + } +}