MapTreeCellRenderer:

* fix indentation
* fix java 5 issues
This commit is contained in:
teo_sarca 2008-09-04 08:13:42 +00:00
parent 1672bf5c18
commit 351edc13ea
1 changed files with 28 additions and 27 deletions

View File

@ -24,35 +24,36 @@ import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
/**
* @author Gunther Hoppe, tranSIT GmbH Ilmenau/Germany
* @version 1.0, October 14th 2005
*/
public abstract class MapTreeCellRenderer extends DefaultTreeCellRenderer {
* @author Gunther Hoppe, tranSIT GmbH Ilmenau/Germany
* @version 1.0, October 14th 2005
*/
public abstract class MapTreeCellRenderer extends DefaultTreeCellRenderer
{
private HashMap<Object, Object> map;
HashMap map;
protected abstract ImageIcon getIcon(Object value);
public MapTreeCellRenderer(HashMap map) {
this.map = new HashMap();
protected abstract ImageIcon getIcon(Object value);
public MapTreeCellRenderer(HashMap<?, ?> map)
{
this.map = new HashMap<Object, Object>();
this.map.putAll(map);
}
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
String name = (String)getMapping(value);
setText(name);
ImageIcon icon = getIcon(value);
setIcon(icon);
return this;
}
protected Object getMapping(Object value) {
return map.get(value);
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
{
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
String name = (String)getMapping(value);
setText(name);
ImageIcon icon = getIcon(value);
setIcon(icon);
return this;
}
protected Object getMapping(Object value)
{
return map.get(value);
}
}