View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2010 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  // utgb-core Project
18  //
19  // RefseqTrack.java
20  // Since: Aug 5, 2010
21  //
22  //--------------------------------------
23  package org.utgenome.gwt.utgb.client.track.lib;
24  
25  import org.utgenome.gwt.utgb.client.track.Track;
26  import org.utgenome.gwt.utgb.client.track.TrackConfigChange;
27  import org.utgenome.gwt.utgb.client.track.TrackFrame;
28  import org.utgenome.gwt.utgb.client.track.TrackGroup;
29  
30  /**
31   * Reference sequence track
32   * 
33   * <pre>
34   * -track
35   *  -class: RefSeqTrack
36   *  -property
37   *    -path: db/genome/%species-%ref.sqlite
38   * </pre>
39   * 
40   * @author leo
41   * 
42   */
43  public class RefSeqTrack extends GenomeTrack {
44  
45  	public static TrackFactory factory() {
46  		return new TrackFactory() {
47  			@Override
48  			public Track newInstance() {
49  				return new RefSeqTrack();
50  			}
51  		};
52  	}
53  
54  	public RefSeqTrack() {
55  		super("Reference Sequence");
56  	}
57  
58  	private static final String CONFIG_PATH = "path";
59  
60  	@Override
61  	public void draw() {
62  
63  		String path = getConfig().getString(CONFIG_PATH, "");
64  		String trackBaseURL = "utgb-core/Sequence.png?path=" + path + "&%q";
65  		getConfig().setParameter(GenomeTrack.CONFIG_TRACK_BASE_URL, trackBaseURL);
66  
67  		super.draw();
68  	}
69  
70  	@Override
71  	public void setUp(TrackFrame trackFrame, TrackGroup group) {
72  		super.setUp(trackFrame, group);
73  
74  		getConfig().addConfigString("path", CONFIG_PATH, "");
75  		getConfig().setParameter(GenomeTrack.CONFIG_TRACK_TYPE, "image");
76  	}
77  
78  	@Override
79  	public void onChangeTrackConfig(TrackConfigChange change) {
80  
81  		if (change.contains(CONFIG_PATH)) {
82  			refresh();
83  		}
84  	}
85  
86  }