]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/function/weather/IconRenderer.java
Moved source into separate src directory due to popular request
[GpsPrune.git] / src / tim / prune / function / weather / IconRenderer.java
diff --git a/src/tim/prune/function/weather/IconRenderer.java b/src/tim/prune/function/weather/IconRenderer.java
new file mode 100644 (file)
index 0000000..caeb184
--- /dev/null
@@ -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);
+       }
+}