View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2007 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // GenomeBrowser Project
18  //
19  // TrackInfo.java
20  // Since: Jun 6, 2007
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.track;
26  
27  import java.util.ArrayList;
28  import java.util.Iterator;
29  
30  /**
31   * TrackInfo class holds track name, track id, descriptions etc.
32   * 
33   * @author leo
34   * 
35   */
36  public class TrackInfo {
37  	private String trackName;
38  	private String description = "";
39  	private String linkURL = "";
40  
41  	private ArrayList<TrackInfoChangeListener> _listenerList = new ArrayList<TrackInfoChangeListener>();
42  
43  	public TrackInfo(String trackName) {
44  		setTrackName(trackName);
45  		description = trackName;
46  	}
47  
48  	/**
49  	 * @param trackName
50  	 * @param description
51  	 */
52  	public TrackInfo(String trackName, String description) {
53  		this.trackName = trackName;
54  		this.description = description;
55  	}
56  
57  	/**
58  	 * add a change listener
59  	 * 
60  	 * @param listener
61  	 */
62  	public void addChangeListener(TrackInfoChangeListener listener) {
63  		_listenerList.add(listener);
64  	}
65  
66  	/**
67  	 * remove the specified change listener
68  	 * 
69  	 * @param listner
70  	 */
71  	public void removeChangeListner(TrackInfoChangeListener listner) {
72  		_listenerList.remove(listner);
73  	}
74  
75  	public String getDescription() {
76  		return description;
77  	}
78  
79  	public void setDescription(String description) {
80  		this.description = description;
81  		notifyTheChange();
82  	}
83  
84  	public String getTrackName() {
85  		return trackName;
86  	}
87  
88  	public void setTrackName(final String trackName) {
89  		this.trackName = trackName;
90  		notifyTheChange();
91  	}
92  
93  	public String getLinkURL() {
94  		return linkURL;
95  	}
96  
97  	/**
98  	 * Set a link for this track
99  	 * 
100 	 * @param linkURL
101 	 */
102 	public void setLinkURL(String linkURL) {
103 		this.linkURL = linkURL;
104 		notifyTheChange();
105 	}
106 
107 	private void notifyTheChange() {
108 		for (Iterator<TrackInfoChangeListener> it = _listenerList.iterator(); it.hasNext();) {
109 			TrackInfoChangeListener listener = it.next();
110 			listener.onChange(this);
111 		}
112 	}
113 }