View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2009 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  // RibbonRulerTrack.java
20  // Since: Jul 13, 2009
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.track.lib;
26  
27  import org.utgenome.gwt.utgb.client.canvas.RibbonRuler;
28  import org.utgenome.gwt.utgb.client.track.Track;
29  import org.utgenome.gwt.utgb.client.track.TrackBase;
30  import org.utgenome.gwt.utgb.client.track.TrackFrame;
31  import org.utgenome.gwt.utgb.client.track.TrackGroup;
32  import org.utgenome.gwt.utgb.client.track.TrackWindow;
33  
34  import com.google.gwt.user.client.ui.FlexTable;
35  import com.google.gwt.user.client.ui.Widget;
36  
37  /**
38   * Track for displaying ribbon coordinates
39   * 
40   * @author leo
41   * 
42   */
43  public class RibbonRulerTrack extends TrackBase {
44  	FlexTable layoutTable = new FlexTable();
45  	RibbonRuler ribbon = new RibbonRuler();
46  
47  	public static TrackFactory factory() {
48  		return new TrackFactory() {
49  			public Track newInstance() {
50  				return new RibbonRulerTrack();
51  			}
52  		};
53  	}
54  
55  	public RibbonRulerTrack() {
56  		super("Ribbon Track");
57  
58  		// prepare the widgets
59  		layoutTable.setCellPadding(0);
60  		layoutTable.setCellSpacing(0);
61  		layoutTable.setBorderWidth(0);
62  		layoutTable.setWidth("100%");
63  		layoutTable.getCellFormatter().setWidth(0, 0, "100px");
64  		layoutTable.setWidget(0, 1, ribbon);
65  	}
66  
67  	public Widget getWidget() {
68  		return layoutTable;
69  	}
70  
71  	@Override
72  	public void setUp(TrackFrame trackFrame, TrackGroup group) {
73  
74  		ribbon.setWindow(group.getTrackWindow());
75  	}
76  
77  	@Override
78  	public void onChangeTrackWindow(TrackWindow newWindow) {
79  		ribbon.setWindow(newWindow);
80  	}
81  
82  }