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.widget.client;
26
27 import org.utgenome.gwt.widget.client.impl.TrackPanelBase;
28
29 import com.google.gwt.user.client.ui.FlexTable;
30 import com.google.gwt.user.client.ui.FocusPanel;
31 import com.google.gwt.user.client.ui.HorizontalPanel;
32 import com.google.gwt.user.client.ui.Label;
33 import com.google.gwt.user.client.ui.ScrollPanel;
34 import com.google.gwt.user.client.ui.SimplePanel;
35 import com.google.gwt.user.client.ui.VerticalPanel;
36 import com.google.gwt.user.client.ui.Widget;
37
38
39
40
41
42
43
44 public class HorizontalTrackFrame extends TrackPanelBase {
45
46
47 private final FlexTable layoutTable = new FlexTable();
48 private FocusPanel labelFrame = new FocusPanel();
49 private SimplePanel trackInfoPanel = new SimplePanel();
50 private String trackTitle;
51 private FrameBorder trackInfoFrame = new FrameBorder(2, FrameBorder.WEST | FrameBorder.SOUTH);
52 private Label trackLabel = new Label();
53 private int buttonVisibilityFlag = ~0;
54
55 private ScrollPanel scrollPanel = new ScrollPanel();
56
57 public HorizontalTrackFrame() {
58
59 enableResizeWidth(false);
60
61 drawWidget();
62 initWidget(layoutTable);
63 }
64
65 public Widget getDraggableWidget() {
66 return labelFrame;
67 }
68
69 protected void drawWidget() {
70
71 setTrackTitle("Track");
72
73 Style.fullWidth(layoutTable);
74 layoutTable.setCellPadding(0);
75 layoutTable.setCellSpacing(0);
76
77
78 Style.fontSize(trackLabel, 11);
79 Style.fontFamily(trackLabel, "Arial, Tahoma, Verdana");
80 Style.set(trackLabel, "color", "white");
81 Style.margin(trackLabel, Style.LEFT, 2);
82 Style.verticalAlign(trackLabel, "middle");
83 Style.overflowHidden(trackLabel);
84
85
86 labelFrame.add(trackLabel);
87 Style.cursor(labelFrame, Style.CURSOR_MOVE);
88
89
90 HorizontalPanel hp = new HorizontalPanel();
91 Style.fullWidth(hp);
92 hp.add(labelFrame);
93 hp.setCellWidth(labelFrame, "100%");
94 hp.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
95 hp.add(getIconSetPanel());
96
97
98 Style.fullSize(trackInfoPanel);
99 Style.backgroundImage(trackInfoPanel, "theme/default/track-base.png");
100 Style.backgroundColor(trackInfoPanel, "00a7bf");
101 trackInfoPanel.add(hp);
102
103
104 trackInfoFrame.setWidget(trackInfoPanel);
105 trackInfoFrame.setSize("180px", "100%");
106
107
108 layoutTable.setWidget(0, 0, trackInfoFrame);
109
110
111 layoutTable.setWidget(0, 1, scrollPanel);
112 layoutTable.getCellFormatter().setHeight(0, 1, "100%");
113 layoutTable.getCellFormatter().setWidth(0, 1, "100%");
114
115
116 VerticalPanel resizeBarPanel = new VerticalPanel();
117 Style.fullSize(resizeBarPanel);
118 Style.backgroundColor(resizeBarPanel, "D0F0F0");
119 resizeBarPanel.setVerticalAlignment(VerticalPanel.ALIGN_BOTTOM);
120 resizeBarPanel.add(getResizeButton());
121
122
123 FrameBorder resizeBarBorder = new FrameBorder(2, FrameBorder.EAST | FrameBorder.SOUTH);
124 resizeBarBorder.setSize("16px", "100%");
125 resizeBarBorder.setWidget(resizeBarPanel);
126 layoutTable.getCellFormatter().setHeight(0, 2, "100%");
127 layoutTable.getCellFormatter().setWidth(0, 2, "100%");
128 layoutTable.setWidget(0, 2, resizeBarBorder);
129
130
131 }
132
133 @Override
134 public void setHeight(int pixelHeight) {
135 if (pixelHeight >= 20) {
136 layoutTable.setHeight(pixelHeight + "px");
137 scrollPanel.setHeight(pixelHeight + "px");
138 }
139 }
140
141 @Override
142 public void setWidth(int pixelWidth) {
143 if (pixelWidth >= 200) {
144 layoutTable.setWidth(pixelWidth + "px");
145 scrollPanel.setWidth(pixelWidth - 200 + "px");
146 }
147 }
148
149
150
151
152
153
154
155 public boolean isVisible(int buttonType) {
156 return (buttonVisibilityFlag & buttonType) != 0;
157 }
158
159 public String getTrackTitle() {
160 return trackTitle;
161 }
162
163 public void setTrackTitle(String title) {
164 this.trackTitle = title;
165 if (trackTitle.length() > 20)
166 trackLabel.setText(trackTitle.substring(0, 20) + "...");
167 else
168 trackLabel.setText(trackTitle);
169
170 trackLabel.setTitle(trackTitle);
171 }
172
173 public void setTrackContent(Widget w) {
174 scrollPanel.setWidget(w);
175 }
176
177 }