diff -r a276b36ae58e -r 4f92e61f87ba client/js/renderer/noderepr.js --- a/client/js/renderer/noderepr.js Wed Sep 10 16:58:01 2014 +0200 +++ b/client/js/renderer/noderepr.js Thu Sep 11 16:49:45 2014 +0200 @@ -1,5 +1,3 @@ - - define(['jquery', 'underscore', 'requtils', 'renderer/baserepresentation', 'renderer/shapebuilder'], function ($, _, requtils, BaseRepresentation, ShapeBuilder) { 'use strict'; @@ -18,10 +16,7 @@ _init: function() { this.renderer.node_layer.activate(); this.type = "Node"; - this.shapeBuilder = new ShapeBuilder(this.model.get("shape")); - // "circle" "rectangle" "ellipse" "regularpolygon" "star" "diamond" - this.circle = this.shapeBuilder.getShape(); - this.circle.__representation = this; + this.buildShape(); if (this.options.show_node_circles) { this.circle.strokeWidth = this.options.node_stroke_width; this.h_ratio = 1; @@ -29,6 +24,7 @@ this.h_ratio = 0; } this.title = $('
').appendTo(this.renderer.labels_$); + if (this.options.editor_mode) { var Renderer = requtils.getRenderer(); this.normal_buttons = [ @@ -42,6 +38,7 @@ new Renderer.NodeRevertButton(this.renderer, null) ]; this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons); + for (var i = 0; i < this.all_buttons.length; i++) { this.all_buttons[i].source_representation = this; } @@ -58,7 +55,34 @@ this.renderer.minimap.node_group.addChild(this.minimap_circle); } }, + buildShape: function(){ + console.log("buildShape");//, this.model.get("shape_changed"), this.model.get("shape")); + if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){ + this.model.set("shape_changed", false); + console.log("REMOVE IMG !!"); + this.img = "a"; + //delete this.renderer.image_cache[this.img]; + } + if(this.circle){ + this.circle.remove(); + delete this.circle; + } + // "circle" "rectangle" "ellipse" "polygon" "star" "diamond" + this.shapeBuilder = new ShapeBuilder(this.model.get("shape")); + this.circle = this.shapeBuilder.getShape(); + this.circle.__representation = this; + this.last_circle_radius = 1; + /*if (this.node_image) { + console.log("this.node_image.remove();") + this.node_image.remove(); + delete this.node_image; + }*/ + }, redraw: function(_dontRedrawEdges) { + //console.log("redraw"); + if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){ + this.buildShape(); + } var _model_coords = new paper.Point(this.model.get("position")), _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Utils._NODE_SIZE_STEP); if (!this.is_dragging || !this.paper_coords) { @@ -135,9 +159,11 @@ var lastImage = this.img; this.img = this.model.get("image"); if (this.img && this.img !== lastImage) { + console.log("test 1 = " + lastImage + ", img = " + this.img); this.showImage(); } if (this.node_image && !this.img) { + console.log("tes 2 = "); this.node_image.remove(); delete this.node_image; } @@ -169,16 +195,22 @@ }, showImage: function() { + console.log("showImage " + this.img); var _image = null; if (typeof this.renderer.image_cache[this.img] === "undefined") { + console.log("showImage 1"); _image = new Image(); this.renderer.image_cache[this.img] = _image; _image.src = this.img; } else { + console.log("showImage 2"); _image = this.renderer.image_cache[this.img]; } + console.log("showImage 3"); if (_image.width) { + console.log("showImage 4"); if (this.node_image) { + console.log("showImage 5"); this.node_image.remove(); } this.renderer.node_layer.activate(); @@ -415,6 +447,7 @@ this.minimap_circle.remove(); } if (this.node_image) { + console.log("remove image 1"); this.node_image.remove(); } }