Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview GenericTreeView.java,1.14,1.15
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-02-15 11:36:00
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26745/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java Log Message: New icons in d-view Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** GenericTreeView.java 14 Feb 2006 14:10:28 -0000 1.14 --- GenericTreeView.java 15 Feb 2006 11:35:50 -0000 1.15 *************** *** 7,10 **** --- 7,12 ---- package net.sourceforge.bprocessor.gui.treeview; + import java.awt.Component; + import java.net.URL; import java.util.Collection; import java.util.Iterator; *************** *** 12,15 **** --- 14,19 ---- import java.util.Set; + import javax.swing.ImageIcon; + import javax.swing.JTree; import javax.swing.SwingUtilities; import javax.swing.event.TreeSelectionEvent; *************** *** 36,55 **** */ public class GenericTreeView extends TreeView implements Observer { - - /** - * Renderer - */ - public class Renderer extends DefaultTreeCellRenderer { - /** - * Constructor - */ - public Renderer() { - super(); - } - } /** Show numbers of elements in display-string of container-nodes */ private static final boolean SHOW_COUNTERS = false; /** The model */ protected DefaultTreeModel model; --- 40,86 ---- */ public class GenericTreeView extends TreeView implements Observer { /** Show numbers of elements in display-string of container-nodes */ private static final boolean SHOW_COUNTERS = false; + /** Space icon */ + protected static ImageIcon spaceicon; + + /** Space group icon*/ + protected static ImageIcon spacegroupicon; + + /** Surface icon */ + protected static ImageIcon surfaceicon; + + /** Surface group icon */ + protected static ImageIcon surfacegroupicon; + + /** Edge icon */ + protected static ImageIcon edgeicon; + + /** Edge group */ + protected static ImageIcon edgegroupicon; + + /** Vertex icon */ + protected static ImageIcon vertexicon; + + /** Vertex group icon */ + protected static ImageIcon vertexgroupicon; + + /** Generic group icon */ + protected static ImageIcon genericgroupicon; + + static { + spaceicon = loadIcon("Biconspace.gif"); + spacegroupicon = loadIcon("Biconspacegroup.gif"); + surfaceicon = loadIcon("Biconsurface.gif"); + surfacegroupicon = loadIcon("Biconsurfacegroup.gif"); + edgeicon = loadIcon("Biconedge.gif"); + edgegroupicon = loadIcon("Biconedgegroup.gif"); + vertexicon = loadIcon("Biconvertex.gif"); + vertexgroupicon = loadIcon("Biconvertexgroup.gif"); + genericgroupicon = loadIcon("Bicongenericgroup.gif"); + } + /** The model */ protected DefaultTreeModel model; *************** *** 65,68 **** --- 96,157 ---- /** + * Renderer + */ + public class Renderer extends DefaultTreeCellRenderer { + /** + * Constructor + */ + public Renderer() { + super(); + } + + /** + * Customize icon + * @param tree Tree + * @param value Object + * @param sel Boolean + * @param expanded Boolean + * @param leaf Boolean + * @param row Integer + * @param hasFocus Boolean + * @return Component + */ + 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); + if (value instanceof GenericNode) { + GenericNode node = (GenericNode) value; + ImageIcon icon = node.icon(); + if (icon != null) { + setIcon(icon); + } + } + return this; + } + } + + /** + * Load an icon + * @param name Filename of icon + * @return Icon + */ + public static ImageIcon loadIcon(String name) { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + URL url = classloader.getResource(name); + ImageIcon icon = new ImageIcon(url); + return icon; + } + + /** * Constructor for GenericTreeView */ *************** *** 78,81 **** --- 167,171 ---- model.nodeStructureChanged(root); isChanged = false; + setCellRenderer(new Renderer()); changed(); } *************** *** 125,131 **** /** * ContainerNode */ ! public class ContainerNode extends DefaultMutableTreeNode { /** * Constructor for ContainerNode --- 215,241 ---- /** + * GenericNode + */ + public class GenericNode extends DefaultMutableTreeNode { + /** + * Constructor + * @param object The value + */ + public GenericNode(Object object) { + super(object); + } + + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return null; + } + } + /** * ContainerNode */ ! public class ContainerNode extends GenericNode { /** * Constructor for ContainerNode *************** *** 153,156 **** --- 263,275 ---- return false; } + + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return genericgroupicon; + } + } *************** *** 158,162 **** * The EntityNode */ ! public class EntityNode extends DefaultMutableTreeNode { /** * Constructor for EntityNode --- 277,281 ---- * The EntityNode */ ! public class EntityNode extends GenericNode { /** * Constructor for EntityNode *************** *** 192,201 **** super(space); Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Surface", surfaces)); ! add(new ContainerNode("Element")); if (space.getModellor() != null) { add(new ModellorNode(space.getModellor())); } } } --- 311,328 ---- super(space); Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces)); ! add(new ContainerNode("Interior")); if (space.getModellor() != null) { add(new ModellorNode(space.getModellor())); } } + + /** + * Return icon + * @return icon + */ + public ImageIcon icon() { + return spaceicon; + } } *************** *** 210,214 **** public SurfaceNode(Surface surface) { super(surface); ! add(new EdgeContainer("Edge", surface.getEdges())); } } --- 337,349 ---- public SurfaceNode(Surface surface) { super(surface); ! add(new EdgeContainer("Contour", surface.getEdges())); ! } ! ! /** ! * Return icon ! * @return Icon ! */ ! public ImageIcon icon() { ! return surfaceicon; } } *************** *** 227,230 **** --- 362,373 ---- add(new VertexNode(edge.getTo())); } + + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return edgeicon; + } } *************** *** 240,243 **** --- 383,395 ---- super(vertex); } + + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return vertexicon; + } + } *************** *** 285,288 **** --- 437,449 ---- } } + + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return spacegroupicon; + } + } *************** *** 304,307 **** --- 465,477 ---- } } + + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return surfacegroupicon; + } + } *************** *** 323,326 **** --- 493,505 ---- } } + + /** + * Return icon + * @return Icon + */ + public ImageIcon icon() { + return edgegroupicon; + } + } |