Mercurial > hg > dml-open-vis
comparison src/DML/MainVisBundle/Resources/assets/marionette/modules/RepresentationModule/RepresentationModule.31-Master.view.collection._similarity.js @ 0:493bcb69166c
added public content
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 20:54:02 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:493bcb69166c |
---|---|
1 "use strict"; | |
2 | |
3 App.module("RepresentationModule", function(RepresentationModule, App, Backbone, Marionette, $, _, Logger) { | |
4 | |
5 RepresentationModule.addInitializer(function(options){ | |
6 | |
7 RepresentationModule.registerMaster({ | |
8 id: "view.collection._similarity", | |
9 inherit: "view._default", | |
10 | |
11 options: { | |
12 canHaveBase: true, | |
13 widthToHeightRatio: 1, | |
14 headerSuffixesForCompressorValues: { | |
15 "zlib": "normalised", | |
16 "zxd": "differential" | |
17 }, | |
18 }, | |
19 | |
20 defaultConfigParameterValues: { | |
21 measure: "euclidean", | |
22 simFeaturesIncludeChords: "1", | |
23 simFeaturesIncludeChromagram: "1", | |
24 simFeaturesIncludeMFCC: "1", | |
25 compressor: "zlib", | |
26 subsampling: "1" | |
27 }, | |
28 | |
29 | |
30 // ================================================================= | |
31 // housekeeping | |
32 | |
33 _listSimFeatures: function(viewConfig) { | |
34 var result = []; | |
35 if (this.getConfigPlannedParameterValueOrDefaultValue(viewConfig, "simFeaturesIncludeChords")) { | |
36 result.push("chords"); | |
37 } | |
38 if (this.getConfigPlannedParameterValueOrDefaultValue(viewConfig, "simFeaturesIncludeChromagram")) { | |
39 result.push("chromagram"); | |
40 } | |
41 if (this.getConfigPlannedParameterValueOrDefaultValue(viewConfig, "simFeaturesIncludeMFCC")) { | |
42 result.push("mfcc"); | |
43 } | |
44 return result; | |
45 }, | |
46 | |
47 | |
48 // ================================================================= | |
49 // config grid panel | |
50 | |
51 | |
52 // ----------------------------------------------------------------- | |
53 // config grid panel - prepare | |
54 | |
55 prepareConfigGridPanelMainArea: function(configGridPanelView) { | |
56 configGridPanelView._$mainArea.data("$measure", configGridPanelView._$mainArea.find(".cgpma__id_compressor")); | |
57 configGridPanelView._$mainArea.data("$subsampling", configGridPanelView._$mainArea.find(".cgpma__id_subsampling")); | |
58 | |
59 // Parent master's behaviour | |
60 RepresentationModule.getMasterById("view._default").prepareConfigGridPanelMainArea.apply(this, arguments); | |
61 }, | |
62 | |
63 | |
64 // ----------------------------------------------------------------- | |
65 // config grid panel - sync | |
66 | |
67 syncConfigGridPanelMainArea: function(configGridPanelView, instant) { | |
68 var measure = this.getConfigPlannedParameterValueOrDefaultValue(configGridPanelView._cachedConfig, "measure").toLowerCase().trim(); | |
69 var toggleValue = measure == "compression"; | |
70 configGridPanelView._$mainArea.data("$measure").toggle(toggleValue); | |
71 configGridPanelView._$mainArea.data("$subsampling").toggle(toggleValue); | |
72 | |
73 // Parent master's behaviour | |
74 RepresentationModule.getMasterById("view._default").syncConfigGridPanelMainArea.apply(this, arguments); | |
75 }, | |
76 | |
77 | |
78 // ================================================================= | |
79 // config grid header | |
80 | |
81 _generateHeaderLabelSuffix: function(headerView) { | |
82 var result = [" ("]; | |
83 | |
84 var simFeatures = this._listSimFeatures(headerView.options.config); | |
85 if (simFeatures) { | |
86 result.push("by "); | |
87 result.push(simFeatures.join(" + ")); | |
88 } else { | |
89 result.push("no characteristics"); | |
90 } | |
91 | |
92 var measure = this.getConfigParameterValueOrDefaultValue(headerView.options.config, "measure", true); | |
93 if (measure == "euclidean") { | |
94 result.push("; euclidean measure"); | |
95 } else if (measure == "compression") { | |
96 var compressor = this.getConfigParameterValueOrDefaultValue(headerView.options.config, "compressor", true); | |
97 var compressorLabel = this.options.headerSuffixesForCompressorValues[compressor]; | |
98 if (compressorLabel) { | |
99 result.push(_.str.sprintf("; %s compressor", compressorLabel)); | |
100 } else { | |
101 result.push("; unknown compressor"); | |
102 }; | |
103 var subsampling = this.getConfigParameterValueOrDefaultValue(headerView.options.config, "subsampling", true); | |
104 if (subsampling) { | |
105 result.push("; subsampling"); | |
106 } | |
107 } else { | |
108 result.push("; unknown measure"); | |
109 } | |
110 result.push(")"); | |
111 return result.join(""); | |
112 }, | |
113 | |
114 | |
115 // ================================================================= | |
116 // vis instance rendering | |
117 | |
118 calculateVisInstanceContentHeight: function(viewConfig, entityWidth) { | |
119 var representation = this.getConfigParameterValueOrDefaultValue(viewConfig, "representaton", true); | |
120 return entityWidth; | |
121 }, | |
122 | |
123 | |
124 // ----------------------------------------------------------------- | |
125 // vis instance rendering - base | |
126 | |
127 _generateCustomParamsForBasePerspectiveRequestParams: function(viewConfig) { | |
128 var measure = this.getConfigParameterValueOrDefaultValue(viewConfig, "measure", true); | |
129 var result = { | |
130 "sim_features": this._listSimFeatures(viewConfig).join(","), | |
131 "sim_type": measure, | |
132 "pid": "similarity" | |
133 }; | |
134 if (measure) { | |
135 result["sim_compressor"] = this.getConfigParameterValueOrDefaultValue(viewConfig, "compressor", true); | |
136 result["sim_downsample"] = this.getConfigParameterValueOrDefaultValue(viewConfig, "subsampling", true); | |
137 } | |
138 return result; | |
139 }, | |
140 | |
141 | |
142 _doRenderVisInstanceViewBaseWithKnownComparisonMode: function(visInstanceView, comparisonMode) { | |
143 var viewConfig = visInstanceView.options.viewConfig; | |
144 | |
145 var options = {}; | |
146 options.comparisonMode = comparisonMode; | |
147 | |
148 options.measure = !!this.getConfigParameterValueOrDefaultValue(viewConfig, "measure", true); | |
149 | |
150 options.primaryColor = "#3182bd"; | |
151 options.secondaryColor = "#31a354"; | |
152 | |
153 var representation = this.getConfigParameterValueOrDefaultValue(viewConfig, "sequenceRepresentation", true); | |
154 App.GraphicsRenderingModule.render(this.id.split(".")[2], visInstanceView.$content, this._groupDataForGraphicsRendering(visInstanceView, "base"), options); | |
155 }, | |
156 | |
157 }); | |
158 }); | |
159 }, Logger); |