1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.utgb.client.track.lib;
26
27 import org.utgenome.gwt.utgb.client.track.Track;
28 import org.utgenome.gwt.utgb.client.track.TrackBase;
29 import org.utgenome.gwt.utgb.client.track.TrackFrame;
30 import org.utgenome.gwt.utgb.client.track.TrackGroup;
31 import org.utgenome.gwt.utgb.client.track.TrackWindow;
32
33 import com.google.gwt.event.dom.client.ClickEvent;
34 import com.google.gwt.event.dom.client.ClickHandler;
35 import com.google.gwt.user.client.ui.Button;
36 import com.google.gwt.user.client.ui.Composite;
37 import com.google.gwt.user.client.ui.HorizontalPanel;
38 import com.google.gwt.user.client.ui.Widget;
39
40
41
42
43
44
45
46 public class ScrollButtonTrack extends TrackBase {
47 public static TrackFactory factory() {
48 return new TrackFactory() {
49 public Track newInstance() {
50 return new ScrollButtonTrack();
51 }
52 };
53 }
54
55 class ScrollButtonSet extends Composite {
56 HorizontalPanel _panel = new HorizontalPanel();
57
58 class WindowScrollButton extends Button implements ClickHandler {
59 int movePercentageOnWindow;
60
61 public WindowScrollButton(String label, int movePercentageOnWindow) {
62 super(label);
63 setStyleName("scrollbutton");
64 addClickHandler(this);
65 this.movePercentageOnWindow = movePercentageOnWindow;
66 }
67
68 public void onClick(ClickEvent e) {
69 TrackWindow window = getTrackGroup().getTrackWindow();
70 int genomeRange = window.getEndOnGenome() - window.getStartOnGenome();
71 if (genomeRange < 0)
72 genomeRange = -genomeRange;
73
74 int offset = (int) (genomeRange * ((double) movePercentageOnWindow / 100.0));
75 getTrackGroup().getPropertyWriter().setTrackWindow(window.getStartOnGenome() + offset, window.getEndOnGenome() + offset);
76 }
77 }
78
79 public ScrollButtonSet() {
80 _panel.add(new WindowScrollButton("<<<< ", -95));
81 _panel.add(new WindowScrollButton("<<< ", -50));
82 _panel.add(new WindowScrollButton("<< ", -25));
83 _panel.add(new WindowScrollButton("< ", -10));
84 _panel.add(new WindowScrollButton("> ", 10));
85 _panel.add(new WindowScrollButton(">> ", 25));
86 _panel.add(new WindowScrollButton(">>> ", 50));
87 _panel.add(new WindowScrollButton(">>>> ", 95));
88
89 initWidget(_panel);
90 }
91
92 }
93
94 private ScrollButtonSet _buttonSet = new ScrollButtonSet();
95
96 public ScrollButtonTrack() {
97 super("Scroll Button");
98 }
99
100 public int getDefaultWindowHeight() {
101 return 20;
102 }
103
104 public Widget getWidget() {
105 return _buttonSet;
106 }
107
108 public void setUp(TrackFrame trackFrame, TrackGroup group) {
109 trackFrame.disablePack();
110 }
111
112 }