Skip to content
Snippets Groups Projects
Commit 8e46b33d authored by Mathis Neumann's avatar Mathis Neumann
Browse files

color theme support

parent 55c8059d
No related branches found
No related tags found
No related merge requests found
import Ember from 'ember'; import Ember from 'ember';
import Themes from './architecture-visualisation-cytoscape/themes';
export default Ember.Component.extend({ export default Ember.Component.extend({
graph: null, graph: null,
layoutAlgorithm: 'cose', layoutAlgorithm: 'cose',
theme: Themes[Object.keys(Themes)[0]], // first theme
themes: Object.keys(Themes),
layoutAlgorithms: [ layoutAlgorithms: [
'cose', 'cose',
// 'cose-bilkent', // broken 'cose-bilkent', // broken
'cola', 'cola',
'grid', 'grid',
'concentric', 'concentric',
...@@ -19,6 +24,9 @@ export default Ember.Component.extend({ ...@@ -19,6 +24,9 @@ export default Ember.Component.extend({
selectLayoutAlgorithm(value) { selectLayoutAlgorithm(value) {
this.debug('value', value); this.debug('value', value);
this.set('layoutAlgorithm', value); this.set('layoutAlgorithm', value);
},
selectTheme(theme) {
this.set('theme', Themes[theme]);
} }
} }
}); });
...@@ -9,6 +9,7 @@ import coseBilkent from 'npm:cytoscape-cose-bilkent'; ...@@ -9,6 +9,7 @@ import coseBilkent from 'npm:cytoscape-cose-bilkent';
coseBilkent(cytoscape); // register coseBilkent(cytoscape); // register
export default Ember.Component.extend({ export default Ember.Component.extend({
theme: null,
layoutAlgorithm: 'cose', layoutAlgorithm: 'cose',
classNames: ['cytoscapeRenderingSpace'], classNames: ['cytoscapeRenderingSpace'],
init: function() { init: function() {
...@@ -19,33 +20,18 @@ export default Ember.Component.extend({ ...@@ -19,33 +20,18 @@ export default Ember.Component.extend({
willDestroyElement() { willDestroyElement() {
clearInterval(this.interval); clearInterval(this.interval);
}, },
layoutChanged: Ember.observer('layout', function(newLayout) { layoutChanged: function(newLayout) {
this.debug('layout changed!', newLayout); this.debug('layout changed!', newLayout);
}), }.observes('layout'),
renderGraph: function() { renderGraph: function() {
this.debug('graph', this.get('graph')); this.debug('graph',this.get('theme'), this.get('graph'));
this.cytoscape = cytoscape({ this.cytoscape = cytoscape({
container: this.element, container: this.element,
boxSelectionEnabled: false, boxSelectionEnabled: false,
autounselectify: true, autounselectify: true,
style: cytoscapeStyle({ style: cytoscapeStyle(this.get('theme')),
nodeGroupTextColor: '#3399CC',
nodeGroupColor: 'white',
borderColor: '#39588A',
nodeColor: '#B4DCED',
nodeTextColor: '#3399CC',
serviceColor: '#E8F8FF',
serviceTextColor: '#3399CC',
arrowBorderColor: '#3399CC',
arrowColor: '#3399CC',
arrowLabelColor: 'black'
}
),
elements: _.cloneDeep(this.get('graph')), // TODO! elements: _.cloneDeep(this.get('graph')), // TODO!
...@@ -60,5 +46,5 @@ export default Ember.Component.extend({ ...@@ -60,5 +46,5 @@ export default Ember.Component.extend({
window.cy = cytoscape; window.cy = cytoscape;
window.cytoscape = this.cytoscape; window.cytoscape = this.cytoscape;
}.on('didInsertElement').observes('layoutAlgorithm', 'graph') }.on('didInsertElement').observes('layoutAlgorithm', 'graph', 'theme')
}); });
export default {
'arctic': {
nodeGroupTextColor: '#3399CC',
nodeGroupColor: 'white',
borderColor: '#39588A',
nodeColor: '#B4DCED',
nodeTextColor: '#3399CC',
serviceColor: '#E8F8FF',
serviceTextColor: '#3399CC',
arrowBorderColor: '#3399CC',
arrowColor: '#3399CC',
arrowLabelColor: 'black'
}
};
\ No newline at end of file
<div class="row"> <div class="row">
<div class="col-md-10 visualisationContainer"> <div class="col-md-10 visualisationContainer">
{{architecture-visualisation-cytoscape graph=graph layoutAlgorithm=layoutAlgorithm}} {{architecture-visualisation-cytoscape graph=graph layoutAlgorithm=layoutAlgorithm theme=theme}}
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<div class="form-group"> <div class="form-group">
...@@ -11,6 +11,14 @@ ...@@ -11,6 +11,14 @@
{{/each}} {{/each}}
</select> </select>
</div> </div>
<div class="form-group">
<label for="layoutTheme">Theme:</label>
<select class="form-control" id="layoutTheme" onchange={{action "selectTheme" value="target.value"}}>
{{#each themes as |theme|}}
<option>{{theme}}</option>
{{/each}}
</select>
</div>
</div> </div>
</div> </div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment