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

@ -27,20 +27,21 @@ import javax.swing.tree.DefaultTreeCellRenderer;
* @author Gunther Hoppe, tranSIT GmbH Ilmenau/Germany * @author Gunther Hoppe, tranSIT GmbH Ilmenau/Germany
* @version 1.0, October 14th 2005 * @version 1.0, October 14th 2005
*/ */
public abstract class MapTreeCellRenderer extends DefaultTreeCellRenderer { public abstract class MapTreeCellRenderer extends DefaultTreeCellRenderer
{
HashMap map; private HashMap<Object, Object> map;
protected abstract ImageIcon getIcon(Object value); protected abstract ImageIcon getIcon(Object value);
public MapTreeCellRenderer(HashMap map) { public MapTreeCellRenderer(HashMap<?, ?> map)
{
this.map = new HashMap(); this.map = new HashMap<Object, Object>();
this.map.putAll(map); this.map.putAll(map);
} }
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { @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); super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
String name = (String)getMapping(value); String name = (String)getMapping(value);
@ -51,8 +52,8 @@ public abstract class MapTreeCellRenderer extends DefaultTreeCellRenderer {
return this; return this;
} }
protected Object getMapping(Object value) { protected Object getMapping(Object value)
{
return map.get(value); return map.get(value);
} }
} }