changeset 440:8f658642d031

Crude use of the type uris to map to icons representing the feature types. No actual de-referencing of the uris or attempt to understand them.
author Lucas Thompson <dev@lucas.im>
date Mon, 26 Jun 2017 01:55:11 +0100
parents e609c6d25f40
children 55e17af8a0ee
files src/app/feature-extraction-menu/feature-extraction-menu.component.html src/app/feature-extraction-menu/feature-extraction-menu.component.ts
diffstat 2 files changed, 43 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/feature-extraction-menu/feature-extraction-menu.component.html	Mon Jun 26 01:53:10 2017 +0100
+++ b/src/app/feature-extraction-menu/feature-extraction-menu.component.html	Mon Jun 26 01:55:11 2017 +0100
@@ -7,7 +7,9 @@
       <md-list-item
         *ngFor="let output of extractor.outputs"
         (click)="extract(output)">
-        <md-icon md-list-icon>extension</md-icon>
+        <md-icon md-list-icon>
+          {{output.iconName ? output.iconName : 'extension'}}
+        </md-icon>
         <h4 md-line>{{output.name}}</h4>
         <p md-line>{{output.combinedKey}}</p>
         <button md-icon-button
--- a/src/app/feature-extraction-menu/feature-extraction-menu.component.ts	Mon Jun 26 01:53:10 2017 +0100
+++ b/src/app/feature-extraction-menu/feature-extraction-menu.component.ts	Mon Jun 26 01:55:11 2017 +0100
@@ -11,12 +11,14 @@
 } from '../services/feature-extraction/feature-extraction.service';
 import {ListResponse} from 'piper';
 import {Subscription} from 'rxjs/Subscription';
+import {HigherLevelFeatureShape} from "../visualisations/FeatureUtilities";
 
 export interface ExtractorOutputInfo {
   extractorKey: string;
   combinedKey: string;
   outputId: string;
   name: string;
+  iconName?: string;
 }
 
 interface ExtractorInfo {
@@ -24,6 +26,29 @@
   outputs: ExtractorOutputInfo[];
 }
 
+const crudeTypeUriMap: {[key: string]: HigherLevelFeatureShape} = {
+  'http://purl.org/ontology/af/Beat': 'instants',
+  'http://purl.org/ontology/af/Chromagram': 'matrix',
+  'http://purl.org/ontology/af/Spectrogram': 'matrix',
+  'http://purl.org/ontology/af/KeyChange': 'instants',
+  'http://purl.org/ontology/af/OnsetDetectionFunction': 'vector',
+  'http://purl.org/ontology/af/Onset': 'instants',
+  'http://purl.org/ontology/af/StructuralSegment': 'instants',
+  'http://purl.org/ontology/af/TonalOnset': 'instants',
+  'http://purl.org/ontology/af/Note': 'notes',
+  'http://purl.org/ontology/af/ChordSegment': 'instants',
+  'http://purl.org/ontology/af/MusicSegment': 'instants',
+  'http://purl.org/ontology/af/Pitch': 'tracks'
+};
+
+const featureIconMap = {
+  vector: 'show_chart',
+  matrix: 'grid_on',
+  tracks: 'multiline_chart',
+  instants: 'view_week',
+  notes: 'audiotrack',
+};
+
 @Component({
   selector: 'ugly-feature-extraction-menu',
   templateUrl: './feature-extraction-menu.component.html',
@@ -59,12 +84,21 @@
         const outputs: ExtractorOutputInfo[] =
           staticData.basicOutputInfo.map(output => {
             const combinedKey = `${staticData.key}:${output.identifier}`;
-            return {
-              extractorKey: staticData.key,
-              combinedKey: combinedKey,
-              name: output.name,
-              outputId: output.identifier
-            };
+            const hasTypeInfo = staticData.staticOutputInfo &&
+              staticData.staticOutputInfo.get(output.identifier) &&
+              staticData.staticOutputInfo.get(output.identifier).typeURI;
+            const getIcon = () => featureIconMap[crudeTypeUriMap[
+              staticData.staticOutputInfo.get(output.identifier).typeURI
+              ]];
+            const hasIcon = hasTypeInfo && getIcon();
+            return Object.assign({
+                extractorKey: staticData.key,
+                combinedKey: combinedKey,
+                name: output.name,
+                outputId: output.identifier
+              },
+              hasIcon ? {iconName: getIcon()} : {}
+            );
           });
         acc.push({name, outputs});
         return acc;