Skip to content

Commit

Permalink
rename to avoid confusion with library
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-pol committed Oct 15, 2021
1 parent d5172a0 commit 3a3d93b
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/API/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function showGraph(container, diagram, stroke, width, height, scale, config) {
var nodeDefs = diagram.jsNodes()
var linkDefs = diagram.jsLinks()//can't inline
var markers = true // use false for slow devices and IE-11, set them at onEnd
container.html(D3jsSVG.render(diagram, stroke, markers, width, height))
container.html(DiagramSvg.render(diagram, stroke, markers, width, height))

// nudge nodes with force graph of the D3js library

Expand All @@ -68,7 +68,7 @@ function showGraph(container, diagram, stroke, width, height, scale, config) {
var s = jsLink.source
var t = jsLink.target
var l = diagram.link(jsLink.index)
return D3jsSVG.pathDescription(l, s.x, s.y, t.x, t.y)
return DiagramSvg.pathDescription(l, s.x, s.y, t.x, t.y)
}
function onTick() {
links.attr("d", drawPath);
Expand Down
6 changes: 3 additions & 3 deletions docs/js/GroundForge-opt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/js/nets.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function showGraph(caption, q) {
const width = 180
const stroke = "2px"
const markers = false // use true for pair diagrams on fast devices and other browsers than IE-11
const svg = D3jsSVG.render(diagram, stroke, markers, width, height)
const svg = DiagramSvg.render(diagram, stroke, markers, width, height)
const fig = d3.select(`#diagrams`).append("figure")
const container = fig.append("div")
container.html(svg.replace("<g>","<g transform='scale(0.5,0.5)'>"))
Expand All @@ -105,7 +105,7 @@ function showGraph(caption, q) {
const s = jsLink.source
const t = jsLink.target
const l = diagram.link(jsLink.index)
return D3jsSVG.pathDescription(l, s.x, s.y, t.x, t.y)
return DiagramSvg.pathDescription(l, s.x, s.y, t.x, t.y)
}
function onTick() {
links.attr("d", drawPath);
Expand Down
8 changes: 4 additions & 4 deletions docs/js/tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function showDiagrams(config) {
if (!config)
config = TilesConfig(submitQuery())
var pairDiagram = pairContainerNode.data = NewPairDiagram.create(config)
pairContainer.html(D3jsSVG.render(pairDiagram, "1px", markers, 744, 1052))
pairContainer.html(DiagramSvg.render(pairDiagram, "1px", markers, 744, 1052))
scrollToIfPossible(pairContainerNode,0,0)
if (pairDiagram.jsNodes().length == 1) return

Expand All @@ -146,7 +146,7 @@ function animateDiagram(container, forceCenterX, forceCenterY) {
var s = jsLink.source
var t = jsLink.target
var l = diagram.link(jsLink.index)
return D3jsSVG.pathDescription(l, s.x, s.y, t.x, t.y)
return DiagramSvg.pathDescription(l, s.x, s.y, t.x, t.y)
}
var tickCounter = 0
function onTick() {
Expand Down Expand Up @@ -415,13 +415,13 @@ function showDroste(level) {
function setPairDiagram(containerID, diagram) {
var container = d3.select(containerID)
container.node().data = diagram
container.html(D3jsSVG.render(diagram, "1px", markers = true, 744, 1052, 0.0))
container.html(DiagramSvg.render(diagram, "1px", markers = true, 744, 1052, 0.0))
animateDiagram(container, 350, 526)
}
function setThreadDiagram(containerID, diagram) {
var container = d3.select(containerID)
container.node().data = diagram
container.html(D3jsSVG.render(diagram, "2px", markers = true, 744, 1052, 0.0).replace("<g>","<g transform='scale(0.5,0.5)'>"))
container.html(DiagramSvg.render(diagram, "2px", markers = true, 744, 1052, 0.0).replace("<g>","<g transform='scale(0.5,0.5)'>"))
animateDiagram(container, 744, 1052)
container.selectAll(".threadStart").on("click", paintThreadByStart)
container.selectAll(".bobbin").on("click", paintThreadByBobbin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import dibl.LinkProps.Path

import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}

@JSExportTopLevel("D3jsSVG") object D3jsSVG {
@JSExportTopLevel("DiagramSvg") object DiagramSvg {

@JSExport
def circle(r: Int): String = s"M $r,0 A $r,$r 0 0 1 0,$r $r,$r 0 0 1 -$r,0 $r,$r 0 0 1 0,-$r $r,$r 0 0 1 $r,0 Z"
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/dibl/Props.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package dibl
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport

/** Object required by D3js and [[D3jsSVG]]. For D3js see also drawNode and drawLink on
/** Object required by D3js and [[DiagramSvg]]. For D3js see also drawNode and drawLink on
* https://bl.ocks.org/mbostock/1b64ec067fcfc51e7471d944f51f1611
*/
trait Props {
Expand Down
7 changes: 3 additions & 4 deletions src/test/scala/Demo4Java.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import dibl.*;
import dibl.proto.TilesConfig;
import dibl.sheet.SheetSVG;
import scala.Tuple2;

import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -79,7 +78,7 @@ private static void drosteSteps(String urlQuery, int i) throws IOException {
// System.out.println("-------------- " + i);
TilesConfig config = new TilesConfig(urlQuery);
new FileOutputStream(dir + "/" + i + "-prototype.svg")
.write((D3jsSVG.prolog() + dibl.proto.PrototypeDiagram.create(config)).getBytes());
.write((DiagramSvg.prolog() + dibl.proto.PrototypeDiagram.create(config)).getBytes());

Diagram pairs = NewPairDiagram.create(config);
writeNudgedDiagram(i + "-pairs", "1px", pairs, config, 1);
Expand Down Expand Up @@ -111,10 +110,10 @@ private static Diagram writeNudgedDiagram(String fileName, String strokeWidth, D

private static Diagram writeDiagram(String fileName, String strokeWidth, Diagram diagram, String bounds)
throws IOException {
String svg = D3jsSVG.render(diagram, strokeWidth, true, 744, 1052, 0d)
String svg = DiagramSvg.render(diagram, strokeWidth, true, 744, 1052, 0d)
.replace("</svg>",bounds + "</svg>");
new FileOutputStream(dir + "/" + fileName + ".svg") //
.write((D3jsSVG.prolog() + svg).getBytes());
.write((DiagramSvg.prolog() + svg).getBytes());
return diagram;
}
}
2 changes: 1 addition & 1 deletion src/test/scala/dibl/FlandersThumbs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package dibl

import dibl.D3jsSVG.{prolog, render}
import dibl.DiagramSvg.{prolog, render}
import dibl.Force.Point
import dibl.proto.TilesConfig

Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/dibl/NewPairDiagramSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NewPairDiagramSpec extends FlatSpec with Matchers {
}

it should "return something that can be rendered" in {
val svgString = D3jsSVG.render(NewPairDiagram.create(paris4(9,9)))
val svgString = DiagramSvg.render(NewPairDiagram.create(paris4(9,9)))
svgString should include ("marker-end: url('#end-purple')")
svgString should include ("marker-start: url('#start-purple')")
svgString should include ("marker-end: url('#end-red')")
Expand All @@ -45,7 +45,7 @@ class NewPairDiagramSpec extends FlatSpec with Matchers {
}

it should "produce valid SVG" in {
val content = D3jsSVG.render(NewPairDiagram.create(paris4(9,9)))
val content = DiagramSvg.render(NewPairDiagram.create(paris4(9,9)))
File("target/new-diagram.html").writeAll(s"<html><body>$content</body></html>")
}
}
2 changes: 1 addition & 1 deletion src/test/scala/dibl/Permutations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package dibl

import dibl.D3jsSVG.{ prolog, render }
import dibl.DiagramSvg.{ prolog, render }
import dibl.Force.{ Point, nudgeNodes }
import dibl.proto.TilesConfig

Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/dibl/TesselaceThumbs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object TesselaceThumbs extends DemoFixture {
val nudgedDiagram = Force
.nudgeNodes(NewPairDiagram.create(config), Point(100, 100))
.getOrElse(throw new Exception("whoops"))
val svg = D3jsSVG.render(nudgedDiagram, width = 200, height = 200)
val svg = DiagramSvg.render(nudgedDiagram, width = 200, height = 200)
File(s"$testDir/$nr.svg").writeAll(svg)
}
// '/C/Program Files/Inkscape/inkscape.exe' 001.svg --export-png=001.png -w78 -h78
Expand Down

0 comments on commit 3a3d93b

Please sign in to comment.