client/js/renderer/noderepr.js
changeset 331 0628ed75e8d3
parent 330 4f92e61f87ba
child 396 b51c25ef4292
equal deleted inserted replaced
330:4f92e61f87ba 331:0628ed75e8d3
    54                 this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;
    54                 this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;
    55                 this.renderer.minimap.node_group.addChild(this.minimap_circle);
    55                 this.renderer.minimap.node_group.addChild(this.minimap_circle);
    56             }
    56             }
    57         },
    57         },
    58         buildShape: function(){
    58         buildShape: function(){
    59             console.log("buildShape");//, this.model.get("shape_changed"), this.model.get("shape"));
       
    60             if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
    59             if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
    61                 this.model.set("shape_changed", false);
    60                 this.model.set("shape_changed", false);
    62                 console.log("REMOVE IMG !!");
    61                 delete this.img;
    63                 this.img = "a";
       
    64                 //delete this.renderer.image_cache[this.img];
       
    65             }
    62             }
    66             if(this.circle){
    63             if(this.circle){
    67                 this.circle.remove();
    64                 this.circle.remove();
    68                 delete this.circle;
    65                 delete this.circle;
    69             }
    66             }
    70             // "circle" "rectangle" "ellipse" "polygon" "star" "diamond"
    67             // "circle" "rectangle" "ellipse" "polygon" "star" "diamond"
    71             this.shapeBuilder = new ShapeBuilder(this.model.get("shape"));
    68             this.shapeBuilder = new ShapeBuilder(this.model.get("shape"));
    72             this.circle = this.shapeBuilder.getShape();
    69             this.circle = this.shapeBuilder.getShape();
    73             this.circle.__representation = this;
    70             this.circle.__representation = this;
    74             this.last_circle_radius = 1;
    71             this.last_circle_radius = 1;
    75             /*if (this.node_image) {
       
    76                 console.log("this.node_image.remove();")
       
    77                 this.node_image.remove();
       
    78                 delete this.node_image;
       
    79             }*/
       
    80         },
    72         },
    81         redraw: function(_dontRedrawEdges) {
    73         redraw: function(_dontRedrawEdges) {
    82             //console.log("redraw");
       
    83             if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
    74             if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
    84                 this.buildShape();
    75                 this.buildShape();
    85             }
    76             }
    86             var _model_coords = new paper.Point(this.model.get("position")),
    77             var _model_coords = new paper.Point(this.model.get("position")),
    87             _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Utils._NODE_SIZE_STEP);
    78             _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Utils._NODE_SIZE_STEP);
   157                 b.moveTo(_pc);
   148                 b.moveTo(_pc);
   158             });
   149             });
   159             var lastImage = this.img;
   150             var lastImage = this.img;
   160             this.img = this.model.get("image");
   151             this.img = this.model.get("image");
   161             if (this.img && this.img !== lastImage) {
   152             if (this.img && this.img !== lastImage) {
   162                 console.log("test 1 = " + lastImage + ", img = " + this.img);
       
   163                 this.showImage();
   153                 this.showImage();
   164             }
   154             }
   165             if (this.node_image && !this.img) {
   155             if (this.node_image && !this.img) {
   166                 console.log("tes 2 = ");
       
   167                 this.node_image.remove();
   156                 this.node_image.remove();
   168                 delete this.node_image;
   157                 delete this.node_image;
   169             }
   158             }
   170 
   159 
   171             if (this.renderer.minimap) {
   160             if (this.renderer.minimap) {
   193                 );
   182                 );
   194             }
   183             }
   195 
   184 
   196         },
   185         },
   197         showImage: function() {
   186         showImage: function() {
   198             console.log("showImage " + this.img);
       
   199             var _image = null;
   187             var _image = null;
   200             if (typeof this.renderer.image_cache[this.img] === "undefined") {
   188             if (typeof this.renderer.image_cache[this.img] === "undefined") {
   201                 console.log("showImage 1");
       
   202                 _image = new Image();
   189                 _image = new Image();
   203                 this.renderer.image_cache[this.img] = _image;
   190                 this.renderer.image_cache[this.img] = _image;
   204                 _image.src = this.img;
   191                 _image.src = this.img;
   205             } else {
   192             } else {
   206                 console.log("showImage 2");
       
   207                 _image = this.renderer.image_cache[this.img];
   193                 _image = this.renderer.image_cache[this.img];
   208             }
   194             }
   209             console.log("showImage 3");
       
   210             if (_image.width) {
   195             if (_image.width) {
   211                 console.log("showImage 4");
       
   212                 if (this.node_image) {
   196                 if (this.node_image) {
   213                     console.log("showImage 5");
       
   214                     this.node_image.remove();
   197                     this.node_image.remove();
   215                 }
   198                 }
   216                 this.renderer.node_layer.activate();
   199                 this.renderer.node_layer.activate();
   217                 var width = _image.width,
   200                 var width = _image.width,
   218                 height = _image.height,
   201                 height = _image.height,
   445             this.title.remove();
   428             this.title.remove();
   446             if (this.renderer.minimap) {
   429             if (this.renderer.minimap) {
   447                 this.minimap_circle.remove();
   430                 this.minimap_circle.remove();
   448             }
   431             }
   449             if (this.node_image) {
   432             if (this.node_image) {
   450                 console.log("remove image 1");
       
   451                 this.node_image.remove();
   433                 this.node_image.remove();
   452             }
   434             }
   453         }
   435         }
   454     });
   436     });
   455 
   437