From 6591a95910da132671012d71787a471c34bbe4cd Mon Sep 17 00:00:00 2001 From: Steve Dafer Date: Wed, 17 Jan 2018 20:06:28 -0400 Subject: [PATCH 1/3] merged with lradu's b37de64 --- cypher.js | 4 +- graph-diagram.js | 49 +- graph-editor.js | 110 +- .../alpha-horizontal.png | Bin 0 -> 557 bytes img/bootstrap-colorpicker/alpha.png | Bin 0 -> 488 bytes img/bootstrap-colorpicker/hue-horizontal.png | Bin 0 -> 478 bytes img/bootstrap-colorpicker/hue.png | Bin 0 -> 504 bytes img/bootstrap-colorpicker/saturation.png | Bin 0 -> 4143 bytes index.html | 123 +- lib/bootstrap-colorpicker.css | 222 ++++ lib/bootstrap-colorpicker.css.map | 1 + lib/bootstrap-colorpicker.js | 1116 +++++++++++++++++ style/graph-editor.css | 22 +- 13 files changed, 1585 insertions(+), 62 deletions(-) create mode 100644 img/bootstrap-colorpicker/alpha-horizontal.png create mode 100644 img/bootstrap-colorpicker/alpha.png create mode 100644 img/bootstrap-colorpicker/hue-horizontal.png create mode 100644 img/bootstrap-colorpicker/hue.png create mode 100644 img/bootstrap-colorpicker/saturation.png create mode 100644 lib/bootstrap-colorpicker.css create mode 100644 lib/bootstrap-colorpicker.css.map create mode 100644 lib/bootstrap-colorpicker.js diff --git a/cypher.js b/cypher.js index 8cdf6aa..ccf3608 100644 --- a/cypher.js +++ b/cypher.js @@ -35,8 +35,8 @@ function cypher(model) { model.relationshipList().forEach(function (rel) { statements.push("(" + quote(rel.start.id) + ")-[:`" + quote(rel.relationshipType()||"RELATED_TO") + - "` " + render(props(rel)) + - "]->("+ quote(rel.end.id) +")" + // " " + TODO render(props(rel)) + + "`]->("+ quote(rel.end.id) +")" ); }); if (statements.length==0) return ""; diff --git a/graph-diagram.js b/graph-diagram.js index f807134..5c87699 100644 --- a/graph-diagram.js +++ b/graph-diagram.js @@ -1,3 +1,4 @@ + gd = {}; (function() { @@ -57,6 +58,7 @@ gd = {}; var caption; var classes = []; var properties = new Properties(model.stylePrototype.nodeProperties); + var isRectangle = false; this.class = function(classesString) { if (arguments.length == 1) { @@ -174,6 +176,15 @@ gd = {}; return properties; }; + this.isRectangle = function(choice) { + //swap between shapes + if (arguments.length == 1) { + isRectangle = choice; + return isRectangle; + } + return isRectangle; + }; + this.style = styleSet(model.stylePrototype.node); }; @@ -1394,17 +1405,20 @@ gd = {}; return d.model.class().join(" ") + " " + "node-id-" + d.model.id; } - var circles = view.selectAll("circle.node") + var rectangles = view.selectAll("rect.node") .data(nodes); - circles.exit().remove(); + rectangles.exit().remove(); - circles.enter().append("svg:circle") - .attr("class", nodeClasses); + rectangles.enter().append("svg:rect") + .attr("class",nodeClasses); - circles - .attr("r", function(node) { - return node.radius.mid(); + rectangles + .attr("width", function(node) { + return node.radius.mid() * 2; + }) + .attr("height", function(node) { + return node.radius.mid() * 2; }) .attr("fill", function(node) { return node.model.style("background-color"); @@ -1415,8 +1429,25 @@ gd = {}; .attr("stroke-width", function(node) { return node.model.style("border-width"); }) - .attr("cx", field("x")) - .attr("cy", field("y")); + .attr("rx", function(node) { + if(node.model.isRectangle()) + return "30"; + else + return node.radius.mid(); + }) + .attr("ry", function(node) { + if(node.model.isRectangle()) + return "30"; + else + return node.radius.mid(); + }) + .attr("x", function(node) { + return node.x - node.radius.inside(); + }) + .attr("y", function(node) { + return node.y - node.radius.inside(); + }); + function captionClasses(d) { return "caption " + d.node.model.class(); diff --git a/graph-editor.js b/graph-editor.js index c0952a4..63cdfbf 100644 --- a/graph-editor.js +++ b/graph-editor.js @@ -21,50 +21,80 @@ window.onload = function() var diagram = gd.diagram() .scaling(gd.scaling.centerOrScaleDiagramToFitSvg) .overlay(function(layoutModel, view) { - var nodeOverlays = view.selectAll("circle.node.overlay") + var nodeOverlays = view.selectAll("rect.node.overlay") .data(layoutModel.nodes); nodeOverlays.exit().remove(); - nodeOverlays.enter().append("circle") + nodeOverlays.enter().append("rect") .attr("class", "node overlay") .call( d3.behavior.drag().on( "drag", drag ).on( "dragend", dragEnd ) ) .on( "dblclick", editNode ); nodeOverlays - .attr("r", function(node) { - return node.radius.outside(); + .attr("width", function(node) { + return node.radius.outside() * 2; + }) + .attr("height", function(node) { + return node.radius.outside() * 2; }) .attr("stroke", "none") .attr("fill", "rgba(255, 255, 255, 0)") - .attr("cx", function(node) { - return node.x; + .attr("rx", function(node) { + if(node.model.isRectangle()) + return "30"; + else + return node.radius.outside(); + }) + .attr("ry", function(node) { + if(node.model.isRectangle()) + return "30"; + else + return node.radius.outside(); + }) + .attr("x", function(node) { + return node.x - node.radius.outside() + node.radius.borderWidth / 2; }) - .attr("cy", function(node) { - return node.y; + .attr("y", function(node) { + return node.y - node.radius.outside() + node.radius.borderWidth / 2; }); - var nodeRings = view.selectAll("circle.node.ring") + var nodeRings = view.selectAll("rect.node.ring") .data(layoutModel.nodes); nodeRings.exit().remove(); - nodeRings.enter().append("circle") + nodeRings.enter().append("rect") .attr("class", "node ring") .call( d3.behavior.drag().on( "drag", dragRing ).on( "dragend", dragEnd ) ); nodeRings - .attr("r", function(node) { - return node.radius.outside() + 5; + .attr("width", function(node) { + return node.radius.outside() * 2 + node.radius.borderWidth; + }) + .attr("height", function(node) { + return node.radius.outside() * 2 + node.radius.borderWidth; }) .attr("fill", "none") .attr("stroke", "rgba(255, 255, 255, 0)") .attr("stroke-width", "10px") - .attr("cx", function(node) { - return node.x; + .attr("rx", function(node) { + if(node.model.isRectangle()) + return "35"; + else + return node.radius.outside() + node.radius.borderWidth; + }) + .attr("ry", function(node) { + if(node.model.isRectangle()) + return "35"; + else + return node.radius.outside() + node.radius.borderWidth; + }) + .attr("x", function(node) { + return node.x - node.radius.outside(); }) - .attr("cy", function(node) { - return node.y; + .attr("y", function(node) { + return node.y - node.radius.outside(); }); var relationshipsOverlays = view.selectAll("path.relationship.overlay") @@ -92,7 +122,7 @@ window.onload = function() svg .data([graphModel]) .call(diagram); - updateSvgDownloadLink(); + updateSvgDownloadLink(); } function save( markup ) @@ -203,13 +233,33 @@ window.onload = function() captionField.node().value = node.caption() || ""; captionField.node().select(); + var propertiesField = editor.select("#node_properties"); propertiesField.node().value = node.properties().list().reduce(function(previous, property) { return previous + property.key + ": " + property.value + "\n"; }, ""); + //current color values + var backgroundColor = editor.select("#node_bg_color").node(); + var textColor = editor.select("#node_txt_color").node(); + backgroundColor.value = node.style("background-color"); + textColor.value = node.style("color"); + function saveChange() { + //updating node's text and background color + node.style("background-color", backgroundColor.value); + node.style("color", textColor.value); + + //updating node's shape + selectedShape = editor.select("#node-shape").node().value; + if(selectedShape == "Circle") { + node.isRectangle(false); + } + else { + node.isRectangle(true); + } + node.caption( captionField.node().value ); node.properties().clearAll(); propertiesField.node().value.split("\n").forEach(function(line) { @@ -222,6 +272,7 @@ window.onload = function() } } }); + save( formatMarkup() ); draw(); cancelModal(); @@ -363,10 +414,12 @@ window.onload = function() d3.select( "#save_markup" ).on( "click", useMarkupFromMarkupEditor ); - function updateSvgDownloadLink() { - var rawSvg = new XMLSerializer().serializeToString(d3.select("#canvas svg" ).node()); - d3.select("#downloadSvgButton").attr('href', "data:image/svg+xml;base64," + btoa( rawSvg )); - } + function updateSvgDownloadLink() + { + var rawSvg = new XMLSerializer().serializeToString(d3.select("#canvas svg" ).node()); + var rawSvg = new XMLSerializer().serializeToString(d3.select("#canvas svg" ).node()); + d3.select("#downloadSvgButton").attr('href', "data:image/svg+xml;base64," + btoa( rawSvg )); + } var openConsoleWithCypher = function (evt) { @@ -412,6 +465,18 @@ window.onload = function() cancelModal(); }); + //updating diagram title + var editDiagramTitle = function() + { + appendModalBackdrop(); + d3.select( ".modal.edit-diagram-title" ).classed( "hide", false ); + }; + + d3.select("#save_diagram_title" ).on("click", function() { + d3.select("#editDiagramTitle").node().innerHTML = d3.select("#diagram_title").node().value; + cancelModal(); + }); + function changeInternalScale() { graphModel.internalScale(d3.select("#internalScale").node().value); draw(); @@ -421,8 +486,9 @@ window.onload = function() d3.select(window).on("resize", draw); d3.select("#internalScale" ).on("change", changeInternalScale); d3.select( "#exportMarkupButton" ).on( "click", exportMarkup ); - d3.select( "#exportCypherButton" ).on( "click", exportCypher ); + d3.select( "#exportCypherButton" ).on( "click", exportCypher ); d3.select( "#chooseStyleButton" ).on( "click", chooseStyle ); + d3.select( "#editDiagramTitle" ).on( "click", editDiagramTitle); d3.selectAll( ".modal-dialog" ).on( "click", function () { d3.event.stopPropagation(); diff --git a/img/bootstrap-colorpicker/alpha-horizontal.png b/img/bootstrap-colorpicker/alpha-horizontal.png new file mode 100644 index 0000000000000000000000000000000000000000..f83188951a8e4fab4ba847c8c89f3105354a9816 GIT binary patch literal 557 zcmV+|0@D47P)Nkl5JbD$mJ%t8>^MX+pA8q_5}cAta0DO|R@{IU5|M(GxNxgy+GBd8l;w&2Ec?5< zVo(HvFZxdJAnNTau8ZPXtKOAPtn2rp+IrX0nbY#4bkaNYzIIZLJrooctxYd|?rp8? z)cO+ap+cSA7pbEAUi(YitNzQ6mD^}>0x7Ez^ll73R_Xc-*~Q+Zpz#R`Ko|>@qj2QF zAcKncK;vstA0eL^`!E>xIk#_;8u-NduvaQXn$g$>7z4ttYmjqc8pS->gW&WGdI5U9QmYbj;6~_suM0VjVBk)9?FjGKLNzR9mK$u}% zJ?3)?fRmicTx%xVMC69^f7R;rWA8uZm)yve{K1EP8^1~E?L`XT8&R{cit@G7SGmNI zD-;bNVa)Z2Mil~Fb~9WBo8Kj@u3_#HiLFA<1-{qWmO2-=?0YdKVz6%S z2*9Wz8-&7K@4=W?VKkD82M*@cB4wmZ=tias{62*I43WQYJZEcwS<&N#Nal+GF`i11 zY=e+9d7#-KG!R}kc+3AQ$^6t@932p}V@@!QyyuhBvt_KD{nGq0=-+8wbOe^=^onsM vr1hwgCt@ro;xv+DFr+*}$b1+=kSNMOdLipIvOQ8u00000NkvXXu0mjf9#jU9 literal 0 HcmV?d00001 diff --git a/img/bootstrap-colorpicker/alpha.png b/img/bootstrap-colorpicker/alpha.png new file mode 100644 index 0000000000000000000000000000000000000000..2e53a30e73175009326fc030f00862d682ddfc45 GIT binary patch literal 488 zcmVP)B00056Nkl} zZ#=A8HwTy*Ji~Hui*DN)Xc=D2SbWU)JF^vFq?ipSE1)dQB?%2~zL;*2(|O#(oBR;O z#J!!4+zDc0I&77>T+tDIE@oI;6%kXWiptfQV#*c>2foJxnWs^#66pqri5SJi0v*Xc z_vjIT9?6}|hzFF05)=1g9#80;7y9mior*2jP95+vQ|{sWGtx)s=39zr^u6;HX^F`p zkx2{{y^wicti6Khm3Wyed%Eg2H=fbPc7D3VBcDWdj{r#qvrgUX$)#2lTEc%5bs}9E zZ`+UiVVyX}VI5jr+$k@C{pP8ABQF)*q|@k8ll1fgWY+Q?y|Zg0V9OmodqfH%3xo%V zF_0b~gfCME=jtfJ($v-Y^!<}BBQx2`+78RhRbxt$n5&{MunD^|({9#^#Hp{!+@o)R z!Ci&=u08T*r)OJ-Py8D;`eSXCiKA=ket6eR*LHXng}b_5r%ttFu8MwPi~vTbhPJwk eS?^O73H$>F-M_zn@}r;t0000ShR^6anYhsD}*2sixx#_ z;;N9)z(r=E(k3ElBO!xKg9K3|ZCX@f)afnmy=Qme_QYdH!ujj-fpFu|`s2Y~2olQ6 z2|AMd=Wf7d@urrB#gesBBwHjZbrP3WX_M>HCxbE~lQJV2S(N2p_yyDW7AJ5R`>_W* z@De7l32U$%Be)tvE2K~&QXw@GlZ2$CLwcoOp2~#0leB!5-{KN}!+D&+S2%(L*oR%% zhDnTLEkEmxDdue*zK#wJq_##5Q`F$=0GT~`-7ysSAOhUwhSHMLP5MN9R=S!a}6CtN3K7ctc(wrm-Pb|Ljm}_kZeK)QSKA literal 0 HcmV?d00001 diff --git a/img/bootstrap-colorpicker/hue.png b/img/bootstrap-colorpicker/hue.png new file mode 100644 index 0000000000000000000000000000000000000000..6f5ec2e502ae3e3e03f4725b0e868e8762d089ab GIT binary patch literal 504 zcmWlVPe_vi0L6c6Mj^~HS41FE*i8vzMTa!3jau0Ftck^RiETv4%*eh1etNgh#Z9kO+%DF(^hwQhXE(;=A}Olt({N8qK0N zXbe3;F%&_a$d3$k2-TpSsMI2>O_Yl&aZnr=K5;=@6TM_+u^<&@c2A zeL`>1OY{`=qnoG;wWCIK1notY$WDGs$^MZILnglaZfCu>$G?91_ND(cr{ke#6QRt+ zxJqh^itgTVIcMJOt{i?I4CJy~?T;TddFSW$ImQ!Le#{N~;{Hg%w%rj(^){Y+e`3H9 zTzq)u@>2EbL?Hd3spCs1l?Z0~Tf=MR2fDMV=&AFcTa(?n#hCBv@7kW#Y`U-c;y&>!CvSwpt@}Bttx69*vb-3-;Ki8A$y8r+H literal 0 HcmV?d00001 diff --git a/img/bootstrap-colorpicker/saturation.png b/img/bootstrap-colorpicker/saturation.png new file mode 100644 index 0000000000000000000000000000000000000000..170841cba2fe51c604a6ed63d9fa119dc4f7a73a GIT binary patch literal 4143 zcmV+~5YX?5P)+#sK+(JQRJ~A(_5>{!ukUR)i7jcSrf7+9fQH~lRI)qc5p5fP$Ioc!An4H= z%NP;FPmORvKp_F;eH0~_u{d=%(&6=qp`vB+dUNkoR;dv6{jpm2FGdQS-0 zkO&rONv#g|hQn2{-!^;ciBCQB9slSPO+jRcXo>jL0JAkU5cK~*ks!JHB>=hUsIVu z@+1V0SNEtlMF>cW{vad@AXRu0nPW;db+}bjtJqPs>v?)C4#Qs8F&IA$Z-(P{g$;9Ny5>td)kU%{Fb^%WKTZ z15Z?_+}qS)!L0;i3^lzm3d>ZbJ{N-Ss$( z+x^uK8s%jhxBjwPq&t&90$kHE*DBE2Gn&Bxm;@wjkEuv@;;MU=AP%L9IB%;0F*7Bx zFlJ&sPP+ASMApy)4Ldd+YH%wXs&;hgIwO(eY-P;5X5N*?dR_5%&*)Ci7t2Ex@MASb zTLRgQ*2{b@w{t$)VHLX_2DjJY%{8(v@uG;98mW#$SrJIU2$1H!pa;>ZLMTbYf<2Fu zB(cc%27Jbh7;p0#+T{I7qm8_yq7FTdN)?+`IzbAlNa{h4MvLg{AmMN&K=Ve>J;y2t ztYM~*)Mmv{CuV}aPDKcLMk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O)eH;oGro{{qbcPck5Ql{)|c002ovPDHLkV1nX9d?Nq= literal 0 HcmV?d00001 diff --git a/index.html b/index.html index 9de1066..6bba973 100644 --- a/index.html +++ b/index.html @@ -5,45 +5,55 @@ + - Arrow Tool - - + + + + - (function () - { - var ga = document.createElement( 'script' ); - ga.type = 'text/javascript'; - ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName( 'script' )[0]; - s.parentNode.insertBefore( ga, s ); - })(); + Arrow Tool - -
- - - - Download SVG - - - + - - + + + + + + +