001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.rGUI.RFileBrowser; 020 021import java.awt.Component; 022import java.util.HashMap; 023import java.util.Map; 024import javax.swing.DefaultListCellRenderer; 025import javax.swing.Icon; 026import javax.swing.JLabel; 027import javax.swing.JList; 028import javax.swing.plaf.metal.MetalIconFactory; 029 030/** 031 * Icons Renderes to the Remote File Chooser 032 * 033 * @author Samuel Campos <samuelcampos@ua.pt> 034 */ 035@Deprecated 036public class IconListRenderer extends DefaultListCellRenderer { 037 038 private Map<Object, Icon> icons = null; 039 040 public IconListRenderer() { 041 icons = new HashMap<Object, Icon>(); 042 043 icons.put("file", 044 MetalIconFactory.getTreeLeafIcon()); 045 046 icons.put("folder", 047 MetalIconFactory.getTreeFolderIcon()); 048 icons.put("computer", 049 MetalIconFactory.getTreeComputerIcon()); 050 051 } 052 053 @Override 054 public Component getListCellRendererComponent( 055 JList list, Object value, int index, 056 boolean isSelected, boolean cellHasFocus) { 057 058 059 060 // Get the renderer component from parent class 061 JLabel label = 062 (JLabel) super.getListCellRendererComponent(list, 063 value, index, isSelected, cellHasFocus); 064 065 066 067 RemoteFile file = (RemoteFile) value; 068 String type = "file"; 069 070 if(file != null && file.isDirectory()) 071 type = "folder"; 072 073 // Get icon to use for the list item value 074 Icon icon = icons.get(type); 075 076 // Set icon to display for value 077 label.setIcon(icon); 078 079 return label; 080 } 081}