client/js/renderer/noderepr.js
changeset 459 98cae534083d
parent 458 423bdf56d103
child 461 48235ed6b07d
--- a/client/js/renderer/noderepr.js	Tue Jun 02 00:39:47 2015 +0200
+++ b/client/js/renderer/noderepr.js	Wed Jun 03 13:16:46 2015 +0200
@@ -55,6 +55,14 @@
                 this.renderer.minimap.node_group.addChild(this.minimap_circle);
             }
         },
+        _getStrokeWidth: function() {
+            var thickness = (this.model.has('style') && this.model.get('style').thickness) || 1;
+            return this.options.node_stroke_width + (thickness-1) * (this.options.node_stroke_max_width - this.options.node_stroke_width) / (this.options.node_stroke_witdh_scale-1);
+        },
+        _getSelectedStrokeWidth: function() {
+            var thickness = (this.model.has('style') && this.model.get('style').thickness) || 1;
+            return this.options.selected_node_stroke_width + (thickness-1) * (this.options.selected_node_stroke_max_width - this.options.selected_node_stroke_width) / (this.options.node_stroke_witdh_scale-1);
+        },
         buildShape: function(){
             if( 'shape' in this.model.changed ) {
                 delete this.img;
@@ -137,13 +145,15 @@
                 this.title.text(_text);
             }
 
+            var _strokeWidth = this._getStrokeWidth();
             this.title.css({
                 left: this.paper_coords.x,
-                top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,
+                top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance + 0.5*_strokeWidth,
                 opacity: opacity
             });
             var _color = (this.model.has("style") && this.model.get("style").color) || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
                 _dash = (this.model.has("style") && this.model.get("style").dash) ? this.options.default_dash_array : null;
+            this.circle.strokeWidth = _strokeWidth;
             this.circle.strokeColor = _color;
             this.circle.dashArray = _dash;
             var _pc = this.paper_coords;
@@ -337,7 +347,7 @@
         },
         select: function() {
             this.selected = true;
-            this.circle.strokeWidth = this.options.selected_node_stroke_width;
+            this.circle.strokeWidth = this._getSelectedStrokeWidth();
             if (this.renderer.isEditable()) {
                 this.active_buttons.forEach(function(b) {
                     b.show();
@@ -373,7 +383,7 @@
                 this.selected = false;
                 var _this = this;
                 this.buttons_timeout = setTimeout(function() { _this.hideButtons(); }, 200);
-                this.circle.strokeWidth = this.options.node_stroke_width;
+                this.circle.strokeWidth = this._getStrokeWidth();
                 $('.Rk-Bin-Item').removeClass("selected");
                 if (this.renderer.minimap) {
                     this.minimap_circle.strokeColor = undefined;