-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathapp.go
55 lines (50 loc) · 1.1 KB
/
app.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package termeter
type App struct {
*VBox
panels []Panel
}
func NewApp() *App {
return &App{
VBox: NewVBox(),
panels: []Panel{},
}
}
func (app *App) GetPanel(i int) Panel {
return app.panels[i]
}
func (app *App) AddPanel(label string, panelType int, options map[string]string) {
var panel Panel
switch panelType {
case LINE:
panel = NewLineChartPanel(label)
lineChartPanel := panel.(*LineChartPanel)
lineChartPanel.SetMode(options["line-mode"])
case CDF:
panel = NewCDFPanel(label)
cdfChartPanel := panel.(*CDFPanel)
cdfChartPanel.SetMode(options["line-mode"])
case COUNTER:
panel = NewCounterPanel(label)
switch options["sort-mode"] {
case "alphabetical":
panel.(*CounterPanel).SetSortMode(SORT_ALPHABETICAL)
case "numerical":
panel.(*CounterPanel).SetSortMode(SORT_NUMERICAL)
}
default:
return
}
app.VBox.AddBoxes(panel)
app.panels = append(app.panels, panel)
}
func (app *App) Render() {
for _, panel := range app.panels {
switch panel.GetType() {
case LINE:
panel.(*LineChartPanel).Update()
case CDF:
panel.(*CDFPanel).Update()
}
}
Render(app.VBox)
}