KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > tree > TreeRenderer


1 /*
2  * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
3  *
4  * This file is part of TransferCM.
5  *
6  * TransferCM is free software; you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation; either version 2 of the License, or (at your option) any later
9  * version.
10  *
11  * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18  * Fifth Floor, Boston, MA 02110-1301 USA
19  */

20
21 package com.methodhead.tree;
22
23 import java.util.Map JavaDoc;
24
25 /**
26  * A base class for tree renderers that provides some common properties.
27  */

28 public abstract class TreeRenderer {
29
30   // constructors /////////////////////////////////////////////////////////////
31

32   // constants ////////////////////////////////////////////////////////////////
33

34   /**
35    * The icon to be used for a node whose icon hint cannot be found in the
36    * renderer's icon images.
37    */

38   public static final String JavaDoc DEFAULT_ICON = "com.methodhead.tree.DEFAULT_ICON";
39
40   /**
41    * The icon to be used as a spacer in cells where no icon should appear; this
42    * icon should be the same size as other icons, but should match the
43    * background or be transparent.
44    */

45   public static final String JavaDoc SPACER_ICON = "com.methodhead.tree.SPACER_ICON";
46
47   // classes //////////////////////////////////////////////////////////////////
48

49   // methods //////////////////////////////////////////////////////////////////
50

51   /**
52    * Returns the HTML for the tree.
53    */

54   public abstract String JavaDoc renderTree(
55     FoldingTreeNode root )
56   throws
57     TreeException;
58
59   // properties ///////////////////////////////////////////////////////////////
60

61   /**
62    * Returns URL of the image to display for the handle (the icon clicked to
63    * open or close a node) of a opened node. If no image has been specified,
64    * the renderer should use a reasonable text character in it's place.
65    */

66   public String JavaDoc getOpenedHandleImage() {
67     return openedHandleImage_;
68   }
69
70   public void setOpenedHandleImage( String JavaDoc openedHandleImage ) {
71     openedHandleImage_ = openedHandleImage;
72   }
73
74   /**
75    * Returns URL of the image to display for the handle (the icon clicked to
76    * open or close a node) of a closed node. If no image has been specified,
77    * the renderer should use a reasonable text character in it's place.
78    */

79   public String JavaDoc getClosedHandleImage() {
80     return closedHandleImage_;
81   }
82
83   public void setClosedHandleImage( String JavaDoc closedHandleImage ) {
84     closedHandleImage_ = closedHandleImage;
85   }
86
87   /**
88    * Returns a map of image URLs for the icons displayed next to each node. A
89    * node's iconHint is looked up in the map. If no image URL is found, {@link
90    * #DEFAULT_ICON DEFAULT_ICON} is looked up; if that image URL is not found,
91    * a blank space should be rendered. If no map is specified at all, no icons
92    * should be at all.
93    */

94   public Map JavaDoc getIconImages() {
95     return iconImages_;
96   }
97
98   public void setIconImages( Map JavaDoc iconImages ) {
99     iconImages_ = iconImages;
100   }
101
102   /**
103    * Returns whether the root node is hidden when the tree is rendered.
104    */

105   public boolean isRootHidden() {
106     return rootHidden_;
107   }
108
109   public void setRootHidden( boolean rootHidden ) {
110     rootHidden_ = rootHidden;
111   }
112
113   // attributes ///////////////////////////////////////////////////////////////
114

115   private String JavaDoc openedHandleImage_ = null;
116   private String JavaDoc closedHandleImage_ = null;
117   private Map JavaDoc iconImages_ = null;
118   private boolean rootHidden_ = false;
119 }
120
121
Popular Tags