1

Updates to UI

This commit is contained in:
Alex Yatskov 2015-06-29 14:02:24 +09:00
parent 32329bcce4
commit 90986beb92
3 changed files with 25 additions and 22 deletions

View File

@ -87,10 +87,9 @@
var _easeTime = 400;
var _height = 500;
var _padding = 10;
var _panelSize = 20;
var _modeSize = 20;
var _panelSize = 40;
var _tickSize = 5;
var _width = 120;
var _width = 125;
var _indicatorAnim = null;
var _bracketAnim = null;
@ -111,7 +110,7 @@
_densitySize,
0,
_width - (_bracketSize + _densitySize),
_height - (_panelSize + _modeSize)
_height - _panelSize
).attr({
cursor: 'crosshair',
stroke: _borderColor,
@ -123,7 +122,7 @@
0,
0,
_densitySize,
_height - (_panelSize + _modeSize)
_height - _panelSize
).attr({
stroke: _borderColor
});
@ -131,7 +130,7 @@
// panel
_elements.panel = _canvas.rect(
0,
_height - (_panelSize + _modeSize),
_height - _panelSize,
_width - _bracketSize,
_panelSize
).attr({
@ -141,11 +140,12 @@
// label
_elements.label = _canvas.text(
(_width - _bracketSize) / 2,
_height - (_panelSize / 2 + _modeSize),
_height - _panelSize * 3 / 4,
_name
).attr({
'dominant-baseline': 'middle',
'text-anchor': 'middle'
'text-anchor': 'middle',
'font-weight': 'bold'
});
// bracketBg
@ -153,7 +153,7 @@
_width - _bracketSize,
0,
_bracketSize,
_height - (_panelSize + _modeSize)
_height - _panelSize
).attr({
fill: _bracketColorBg
});
@ -297,19 +297,22 @@
}
function updateMode() {
var modeText = '( ' + _data.mode + ' )';
if (_.has(_elements, 'mode')) {
_elements.mode.attr({
text: _data.mode
text: modeText
});
}
else {
_elements.mode = _canvas.text(
(_width - _bracketSize) / 2,
_height - _modeSize / 2,
_data.mode
_height - _panelSize / 4,
modeText
).attr({
'dominant-baseline': 'middle',
'text-anchor': 'middle'
'text-anchor': 'middle',
cursor: 'hand'
}).click(modeClick);
}
}
@ -454,7 +457,7 @@
}
function modeClick(event, x, y) {
var mode = _data.mode === 'prod' ? 'dist' : 'prod';
var mode = _data.mode === 'product' ? 'distance' : 'product';
updateState(_data.value, mode);
}

View File

@ -29,7 +29,7 @@ type modeType int
const (
ModeTypeNone modeType = iota
ModeTypeProduct
ModeTypeDist
ModeTypeDistance
)
type featureMap map[string]float64
@ -199,9 +199,9 @@ func (s recordSorter) Swap(i, j int) {
func (m modeType) String() string {
switch m {
case ModeTypeProduct:
return "prod"
case ModeTypeDist:
return "dist"
return "product"
case ModeTypeDistance:
return "distance"
default:
return "invalid"
}
@ -209,10 +209,10 @@ func (m modeType) String() string {
func strToModeType(mode string) modeType {
switch mode {
case "prod":
case "product":
return ModeTypeProduct
case "dist":
return ModeTypeDist
case "distance":
return ModeTypeDistance
default:
return ModeTypeNone
}

View File

@ -81,7 +81,7 @@ func compare(features1 featureMap, features2 featureMap, modes modeMap) float64
value2, _ := features2[key]
switch mode, _ := modes[key]; mode {
case ModeTypeDist:
case ModeTypeDistance:
result += 1 - math.Abs(value1-value2)
default:
result += value1 * value2