var radial = function (d, p, a) { this.drawing = d; this.parent = p; this.children = []; this.attr = { hubCenter: (a.hubCenter) ? a.hubCenter : {x: "0px", y: "0px"}, hubRadius: (a.hubRadius) ? a.hubRadius : "20px", hubTitle: (a.hubTitle) ? a.hubTitle : "", hubSelected: (a.hubSelected) ? a.hubSelected : false, hubVisible: (a.hubVisible) ? a.hubVisible : true, fillColor: (a.fillColor) ? a.fillColor : "#999", lineColor: (a.lineColor) ? a.lineColor : "#333", lineStroke: (a.lineStroke) ? a.lineStroke : "5px", hoverColor: (a.hoverColor) ? a.hoverColor : "#000888", hoverStroke: (a.hoverStroke) ? a.hoverStroke : "5px", selectColor: (a.selectColor) ? a.selectColor : "#f00", selectStroke: (a.selectStroke) ? a.selectStroke : "5px", titleVisible: (a.titleVisible) ? a.titleVisible : true, titleColor: (a.titleColor) ? a.titleColor : "#fff", titleOffset: (a.titleOffset) ? a.titleOffset : {x: "10px", y: "5px"}, childrenVisible: (a.childrenVisible) ? a.childrenVisible : true, childrenRadius: (a.childrenRadius) ? a.childrenRadius : "120px", childrenRotateRadians: (a.childrenRotateRadians) ? a.childrenRotateRadians : Math.PI/2, childrenConnector: (a.childrenConnector) ? a.childrenConnector : "polygon" }; var childConnectorTypes = ["none", "circle", "star", "spokes", "polygon"]; var anchors = []; var hub = []; var spokes = []; var circles = []; var starlines = []; var polygons = []; if (this.parent && this.parent.children) { this.parent.children.push(this); } else { } this.click = function() { return false; }; this.mousedown = function() { return false; }; this.mouseup = function() { if (this.attr.childrenVisible) { this.hideChildren(); } else { this.showChildren(); } this.draw(); }; this.mouseover = function() { this.hoverHub(); return false; }; this.mouseout = function() { this.plainHub(); return false; }; this.selectHub = function() { if(hub[0]) { hub[0].set( {strokecolor: this.attr.selectColor, strokeweight: this.attr.selectStroke } ); } }; this.unselectHub = function() { if(hub[0]) { hub[0].set( {strokecolor: this.attr.lineColor, strokeweight: this.attr.lineStroke } ); } }; this.hoverHub = function() { if(hub[0]) { hub[0].set( {strokecolor: this.attr.hoverColor, strokeweight: this.attr.hoverStroke } ); } }; this.plainHub = function() { if(hub[0]) { hub[0].set( {strokecolor: this.attr.lineColor, strokeweight: this.attr.lineStroke } ); } }; this.showHub = function () { this.attr.hubVisible = true; }; this.hideHub = function () { this.attr.hubVisible = false; } this.hideChildren = function () { this.attr.childrenVisible = false; for (var a=0; a c; c++) { var spokeattr = { x1: this.attr.hubCenter.x, y1: this.attr.hubCenter.y, x2: Math.round( r * Math.cos(c*d+rr) + cx ) + "px", y2: Math.round( r * Math.sin(c*d+rr) + cy ) + "px", strokewidth: this.attr.lineStroke, strokecolor: this.attr.lineColor }; if(!spokes[c]) { spokes[c] = this.drawing.line(this.drawing.drawing, spokeattr); } else { spokes[c].set(spokeattr); } } }; this.drawCircle = function() { // var d = (this.children.length) ? ((2*Math.PI)/this.children.length) : 0; var cx = parseInt(this.attr.hubCenter.x); var cy = parseInt(this.attr.hubCenter.y); var r = (this.attr.childrenVisible) ? parseInt(this.attr.childrenRadius) : parseInt(this.attr.hubRadius); var attr= { x: this.attr.hubCenter.x, y: this.attr.hubCenter.y, r: r, strokewidth: this.attr.lineStroke, strokecolor: this.attr.lineColor }; if(!circles[0]) { circles[0] = this.drawing.circle(this.drawing.drawing, attr); } else { circles[0].set(attr); } }; this.drawPoly = function() { var s = 2; var d = (this.children.length) ? ((2*Math.PI)/this.children.length) : 0; var cx = parseInt(this.attr.hubCenter.x); var cy = parseInt(this.attr.hubCenter.y); var r = (this.attr.childrenVisible) ? parseInt(this.attr.childrenRadius) : parseInt(this.attr.hubRadius); var rr = parseFloat(this.attr.childrenRotateRadians); for(var c=0; this.children.length > c; c++) { var spokeattr = { x1: Math.round( r * Math.cos(c*d+rr) + cx ) + "px", y1: Math.round( r * Math.sin(c*d+rr) + cy ) + "px", x2: Math.round( r * Math.cos((c+s)*d+rr) + cx ) + "px", y2: Math.round( r * Math.sin((c+s)*d+rr) + cy ) + "px", strokewidth: this.attr.lineStroke, strokecolor: this.attr.lineColor }; if(!spokes[c]) { spokes[c] = this.drawing.line(this.drawing.drawing, spokeattr); } else { spokes[c].set(spokeattr); } } }; /* this.drawCircle = function() { if(!this.circle) { this.circle = this.canvas.$createOval(this.sr, true); } this.circle.$strokeColor(this.lc); this.circle.$strokeWeight(this.ls); this.circle.$fillColor(this.fc); if(this.expanded) { this.circle.$move(this.center.x, this.center.y, this.sr); } else { this.circle.$move(this.center.x, this.center.y, 1); } }; this.drawStar = function() { var d = ((2*Math.PI)/this.ns); // spokeDistance var s = Math.floor((this.ns-1)/2); // skip for(var c = 0; this.ns > c; c++) { var l,o; if(!this.starlines[c]) { this.starlines[c] = this.canvas.$createLine(this.ls, this.lc); } if(this.expanded) { x = Math.round(this.sr * Math.cos(c*d+this.rr) + this.center.x); y = Math.round(this.sr * Math.sin(c*d+this.rr) + this.center.y); sx = Math.round(this.sr * Math.cos((c+s)*d+this.rr) + this.center.x); sy = Math.round(this.sr * Math.sin((c+s)*d+this.rr) + this.center.y); } else { x = Math.round(1 * Math.cos(c*d+this.rr) + this.center.x); y = Math.round(1 * Math.sin(c*d+this.rr) + this.center.y); sx = Math.round(1 * Math.cos((c+s)*d+this.rr) + this.center.x); sy = Math.round(1 * Math.sin((c+s)*d+this.rr) + this.center.y); } this.starlines[c].$move(x, y, sx, sy); } }; this.drawPoly = function() { var p = []; var d = ((2*Math.PI)/this.ns); var s = 1; for(var c = 0; this.ns > c; c++) { if(!this.polylines[c]) { this.polylines[c] = this.canvas.$createLine(this.ls, this.lc); } if(this.expanded) { x = Math.round(this.sr * Math.cos(c*d+this.rr) + this.center.x); y = Math.round(this.sr * Math.sin(c*d+this.rr) + this.center.y); sx = Math.round(this.sr * Math.cos((c+s)*d+this.rr) + this.center.x); sy = Math.round(this.sr * Math.sin((c+s)*d+this.rr) + this.center.y); } else { x = Math.round(1 * Math.cos(c*d+this.rr) + this.center.x); y = Math.round(1 * Math.sin(c*d+this.rr) + this.center.y); sx = Math.round(1 * Math.cos((c+s)*d+this.rr) + this.center.x); sy = Math.round(1 * Math.sin((c+s)*d+this.rr) + this.center.y); } this.polylines[c].$move(x, y, sx, sy); } }; */ };