View Javadoc
1   /*
2    * $Source$
3    * $Revision$
4    *
5    * Copyright (C) 2001 Myles Chippendale
6    *
7    * Part of Melati (http://melati.org), a framework for the rapid
8    * development of clean, maintainable web applications.
9    *
10   * Melati is free software; Permission is granted to copy, distribute
11   * and/or modify this software under the terms either:
12   *
13   * a) the GNU General Public License as published by the Free Software
14   *    Foundation; either version 2 of the License, or (at your option)
15   *    any later version,
16   *
17   *    or
18   *
19   * b) any version of the Melati Software License, as published
20   *    at http://melati.org
21   *
22   * You should have received a copy of the GNU General Public License and
23   * the Melati Software License along with this program;
24   * if not, write to the Free Software Foundation, Inc.,
25   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA to obtain the
26   * GNU General Public License and visit http://melati.org to obtain the
27   * Melati Software License.
28   *
29   * Feel free to contact the Developers of Melati (http://melati.org),
30   * if you would like to work out a different arrangement than the options
31   * outlined here.  It is our intention to allow Melati to be used by as
32   * wide an audience as possible.
33   *
34   * This program is distributed in the hope that it will be useful,
35   * but WITHOUT ANY WARRANTY; without even the implied warranty of
36   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37   * GNU General Public License for more details.
38   *
39   * Contact details for copyright holder:
40   *
41   *     Myles Chippendale <mylesc At paneris.org>
42   */
43  package org.melati.util;
44  
45  import org.melati.poem.Treeable;
46  
47  /**
48   * A JavaScript tree which can be rendered as ordinary HTML.
49   */
50  public class JSStaticTree extends Tree {
51  
52    private String backgroundColour = "FFFFFF";
53    private Integer depthPerDownload = new Integer(-1);
54    private String verticalLinkImage;
55    private String spacerImage;
56    private String openedFolderImage;
57    private String closedFolderImage;
58    private String openedTImage;
59    private String closedTImage;
60    private String openedLImage;
61    private String closedLImage;
62    private String leafTImage;
63    private String leafLImage;
64    private String leafImage;
65    private String imageBaseRef;
66  
67    /**
68     * Constructor.
69     * 
70     * @param tree
71     *        the Tree to render
72     * @param staticURL
73     *        images base url
74     */
75    public JSStaticTree(Tree tree, String staticURL) {
76      super(tree.getTreeableRoots(), tree.getDepth());
77      verticalLinkImage = staticURL + "/vertline.gif";
78      spacerImage = staticURL + "/spacer.gif";
79      openedFolderImage = staticURL + "/openfolder.gif";
80      closedFolderImage = staticURL + "/closedfolder.gif";
81      openedTImage = staticURL + "/node_minus.gif";
82      closedTImage = staticURL + "/node_plus.gif";
83      openedLImage = staticURL + "/lastnode_minus.gif";
84      closedLImage = staticURL + "/lastnode_plus.gif";
85      leafTImage = staticURL + "/node.gif";
86      leafLImage = staticURL + "/last_node.gif";
87      leafImage = staticURL + "/file.gif";
88      imageBaseRef = staticURL;
89    }
90  
91    /**
92     * Constructor for an array.
93     * 
94     * @param nodes
95     * @param staticURL
96     */
97    public JSStaticTree(Treeable[] nodes, String staticURL) { 
98      super(nodes);    
99      verticalLinkImage = staticURL + "/vertline.gif";
100     spacerImage = staticURL + "/spacer.gif";
101     openedFolderImage = staticURL + "/openfolder.gif";
102     closedFolderImage = staticURL + "/closedfolder.gif";
103     openedTImage = staticURL + "/node_minus.gif";
104     closedTImage = staticURL + "/node_plus.gif";
105     openedLImage = staticURL + "/lastnode_minus.gif";
106     closedLImage = staticURL + "/lastnode_plus.gif";
107     leafTImage = staticURL + "/node.gif";
108     leafLImage = staticURL + "/last_node.gif";
109     leafImage = staticURL + "/file.gif";
110     imageBaseRef = staticURL;
111   }
112 
113   /**
114    * @return the background colour hex string (without a hash)
115    */
116   public String getBackgroundColour() {
117     return backgroundColour;
118   }
119 
120   /**
121    * Set the background colour. 
122    * 
123    * @param bg the background colour hex string (without a hash)
124    */
125   public void setBackgroundColour(String bg) {
126     backgroundColour = bg;
127   }
128 
129   /**
130    * @return the vertical link image
131    */
132   public String getVerticalLinkImage() {
133     return verticalLinkImage;
134   }
135 
136   /**
137    * Set the vertical link image.
138    * @param vli the vertical link image
139    */
140   public void setVerticalLinkImage(String vli) {
141     verticalLinkImage = vli;
142   }
143 
144   /**
145    * @return the spacer image name
146    */
147   public String getSpacerImage() {
148     return spacerImage;
149   }
150 
151   /**
152    * Set the spacer image name.
153    * @param si the spacer image name to set
154    */
155   public void setSpacerImage(String si) {
156     spacerImage = si;
157   }
158 
159   /**
160    * @return the opened folder image name
161    */
162   public String getOpenedFolderImage() {
163     return openedFolderImage;
164   }
165 
166   /**
167    * Set the opened folder image name.
168    * @param ofi the opened folder image name to set
169    */
170   public void setOpenedFolderImage(String ofi) {
171     openedFolderImage = ofi;
172   }
173 
174   /**
175    * @return the closed folder image name
176    */
177   public String getClosedFolderImage() {
178     return closedFolderImage;
179   }
180 
181   /**
182    * Set the closed folder image name.
183    * @param cfi the closed folder image name to set
184    */
185   public void setClosedFolderImage(String cfi) {
186     closedFolderImage = cfi;
187   }
188 
189   /**
190    * @return the opened Tee image 
191    */
192   public String getOpenedTImage() {
193     return openedTImage;
194   }
195 
196   /**
197    * Set the opened Tee image.
198    * @param oti the opened Tee image to set
199    */
200   public void setOpenedTImage(String oti) {
201     openedTImage = oti;
202   }
203 
204   /**
205    * @return the opened L image
206    */
207   public String getOpenedLImage() {
208     return openedLImage;
209   }
210 
211   /**
212    * Set the opened L image.
213    * @param oli the opened L image to set
214    */
215   public void setOpenedLImage(String oli) {
216     openedLImage = oli;
217   }
218 
219   /**
220    * @return the closed Tee image
221    */
222   public String getClosedTImage() {
223     return closedTImage;
224   }
225 
226   /**
227    * Set the closed Tee image.
228    * @param cti the closed Tee image
229    */
230   public void setClosedTImage(String cti) {
231     closedTImage = cti;
232   }
233 
234   /**
235    * @return the closed L image
236    */
237   public String getClosedLImage() {
238     return closedLImage;
239   }
240 
241   /**
242    * Set the closed L image.
243    * @param cli the closed L image
244    */
245   public void setClosedLImage(String cli) {
246     closedLImage = cli;
247   }
248 
249   /**
250    * @return the Leaf Tee image
251    */
252   public String getLeafTImage() {
253     return leafTImage;
254   }
255 
256   /**
257    * Set the Leaf Tee image.
258    * @param lti the Leaf Tee image to set
259    */
260   public void setLeafTImage(String lti) {
261     leafTImage = lti;
262   }
263 
264   /**
265    * @return the leaf L image
266    */
267   public String getLeafLImage() {
268     return leafLImage;
269   }
270 
271   /**
272    * Set the leaf L image.
273    * @param lli the leaf L image to set
274    */
275   public void setLeafLImage(String lli) {
276     leafLImage = lli;
277   }
278 
279   /**
280    * @return the leaf image
281    */
282   public String getLeafImage() {
283     return leafImage;
284   }
285 
286   /**
287    * Set the leaf image.
288    * @param li the leaf image to set
289    */
290   public void setLeafImage(String li) {
291     leafImage = li;
292   }
293 
294   /**
295    * @return the image base href
296    */
297   public String getImageBaseRef() {
298     return imageBaseRef;
299   }
300 
301   /**
302    * Set the image base href.
303    * @param ibr the image base href to set
304    */
305   public void setImageBaseRef(String ibr) {
306     imageBaseRef = ibr;
307   }
308 
309   /**
310    * @return the depth per download
311    */
312   public Integer getDepthPerDownload() {
313     return depthPerDownload;
314   }
315 
316   /**
317    * Set the depth per download.
318    * @param dpd the depth per download to set
319    */
320   public void setDepthPerDownload(Integer dpd) {
321     depthPerDownload = dpd;
322   }
323 
324 }