mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Move of drawLoop to svgDraw
This commit is contained in:
parent
786d9ddb54
commit
7741f49ed8
111
dist/mermaid.full.js
vendored
111
dist/mermaid.full.js
vendored
@ -16158,58 +16158,6 @@ var drawNote = function(elem, startx, verticalPos, msg){
|
||||
exports.bounds.bumpVerticalPos(textHeight+ 2*conf.noteMargin);
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws an actor in the diagram with the attaced line
|
||||
* @param center - The center of the the actor
|
||||
* @param pos The position if the actor in the list of actors
|
||||
* @param description The text in the box
|
||||
*/
|
||||
exports.drawLoop = function(elem,bounds,labelText){
|
||||
var g = elem.append("g");
|
||||
var drawLoopLine = function(startx,starty,stopx,stopy){
|
||||
g.append("line")
|
||||
.attr("x1", startx)
|
||||
.attr("y1", starty)
|
||||
.attr("x2", stopx )
|
||||
.attr("y2", stopy )
|
||||
.attr("stroke-width", 2)
|
||||
.attr("stroke", "#526e52")
|
||||
.attr('class','loopLine');
|
||||
};
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty);
|
||||
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy );
|
||||
if(typeof bounds.elsey !== 'undefined'){
|
||||
drawLoopLine(bounds.startx, bounds.elsey, bounds.stopx, bounds.elsey );
|
||||
}
|
||||
|
||||
var txt = svgDraw.getTextObj();
|
||||
txt.text = labelText;
|
||||
txt.x = bounds.startx;
|
||||
txt.y = bounds.starty;
|
||||
txt.labelMargin = 1.5 * conf.boxMargin;
|
||||
txt.class = 'labelText';
|
||||
txt.fill = 'white';
|
||||
|
||||
svgDraw.drawLabel(g,txt);
|
||||
|
||||
txt = svgDraw.getTextObj();
|
||||
txt.text = '[ ' + bounds.title + ' ]';
|
||||
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2;
|
||||
txt.y = bounds.starty + 1.5 * conf.boxMargin;
|
||||
txt.anchor = 'middle';
|
||||
txt.class = 'loopText';
|
||||
|
||||
svgDraw.drawText(g,txt);
|
||||
|
||||
if(typeof bounds.elseText !== 'undefined') {
|
||||
txt.text = '[ ' + bounds.elseText + ' ]';
|
||||
txt.y = bounds.elsey + 1.5 * conf.boxMargin;
|
||||
svgDraw.drawText(g, txt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Draws a message
|
||||
@ -16355,7 +16303,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.LOOP_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData,'loop');
|
||||
svgDraw.drawLoop(diagram, loopData,'loop', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
case sq.yy.LINETYPE.OPT_START:
|
||||
@ -16366,7 +16314,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.OPT_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData, 'opt');
|
||||
svgDraw.drawLoop(diagram, loopData, 'opt', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
case sq.yy.LINETYPE.ALT_START:
|
||||
@ -16384,7 +16332,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.ALT_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData,'alt');
|
||||
svgDraw.drawLoop(diagram, loopData,'alt', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
default:
|
||||
@ -16507,6 +16455,59 @@ exports.drawActor = function(elem, left,description,conf){
|
||||
.text(description)
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws an actor in the diagram with the attaced line
|
||||
* @param center - The center of the the actor
|
||||
* @param pos The position if the actor in the list of actors
|
||||
* @param description The text in the box
|
||||
*/
|
||||
exports.drawLoop = function(elem,bounds,labelText, conf){
|
||||
var g = elem.append("g");
|
||||
var drawLoopLine = function(startx,starty,stopx,stopy){
|
||||
g.append("line")
|
||||
.attr("x1", startx)
|
||||
.attr("y1", starty)
|
||||
.attr("x2", stopx )
|
||||
.attr("y2", stopy )
|
||||
.attr("stroke-width", 2)
|
||||
.attr("stroke", "#526e52")
|
||||
.attr('class','loopLine');
|
||||
};
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty);
|
||||
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy );
|
||||
if(typeof bounds.elsey !== 'undefined'){
|
||||
drawLoopLine(bounds.startx, bounds.elsey, bounds.stopx, bounds.elsey );
|
||||
}
|
||||
|
||||
var txt = exports.getTextObj();
|
||||
txt.text = labelText;
|
||||
txt.x = bounds.startx;
|
||||
txt.y = bounds.starty;
|
||||
txt.labelMargin = 1.5 * conf.boxMargin;
|
||||
txt.class = 'labelText';
|
||||
txt.fill = 'white';
|
||||
|
||||
exports.drawLabel(g,txt);
|
||||
|
||||
txt = exports.getTextObj();
|
||||
txt.text = '[ ' + bounds.title + ' ]';
|
||||
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2;
|
||||
txt.y = bounds.starty + 1.5 * conf.boxMargin;
|
||||
txt.anchor = 'middle';
|
||||
txt.class = 'loopText';
|
||||
|
||||
exports.drawText(g,txt);
|
||||
|
||||
if(typeof bounds.elseText !== 'undefined') {
|
||||
txt.text = '[ ' + bounds.elseText + ' ]';
|
||||
txt.y = bounds.elsey + 1.5 * conf.boxMargin;
|
||||
exports.drawText(g, txt);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*/
|
||||
|
4
dist/mermaid.full.min.js
vendored
4
dist/mermaid.full.min.js
vendored
File diff suppressed because one or more lines are too long
111
dist/mermaid.slim.js
vendored
111
dist/mermaid.slim.js
vendored
@ -16126,58 +16126,6 @@ var drawNote = function(elem, startx, verticalPos, msg){
|
||||
exports.bounds.bumpVerticalPos(textHeight+ 2*conf.noteMargin);
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws an actor in the diagram with the attaced line
|
||||
* @param center - The center of the the actor
|
||||
* @param pos The position if the actor in the list of actors
|
||||
* @param description The text in the box
|
||||
*/
|
||||
exports.drawLoop = function(elem,bounds,labelText){
|
||||
var g = elem.append("g");
|
||||
var drawLoopLine = function(startx,starty,stopx,stopy){
|
||||
g.append("line")
|
||||
.attr("x1", startx)
|
||||
.attr("y1", starty)
|
||||
.attr("x2", stopx )
|
||||
.attr("y2", stopy )
|
||||
.attr("stroke-width", 2)
|
||||
.attr("stroke", "#526e52")
|
||||
.attr('class','loopLine');
|
||||
};
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty);
|
||||
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy );
|
||||
if(typeof bounds.elsey !== 'undefined'){
|
||||
drawLoopLine(bounds.startx, bounds.elsey, bounds.stopx, bounds.elsey );
|
||||
}
|
||||
|
||||
var txt = svgDraw.getTextObj();
|
||||
txt.text = labelText;
|
||||
txt.x = bounds.startx;
|
||||
txt.y = bounds.starty;
|
||||
txt.labelMargin = 1.5 * conf.boxMargin;
|
||||
txt.class = 'labelText';
|
||||
txt.fill = 'white';
|
||||
|
||||
svgDraw.drawLabel(g,txt);
|
||||
|
||||
txt = svgDraw.getTextObj();
|
||||
txt.text = '[ ' + bounds.title + ' ]';
|
||||
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2;
|
||||
txt.y = bounds.starty + 1.5 * conf.boxMargin;
|
||||
txt.anchor = 'middle';
|
||||
txt.class = 'loopText';
|
||||
|
||||
svgDraw.drawText(g,txt);
|
||||
|
||||
if(typeof bounds.elseText !== 'undefined') {
|
||||
txt.text = '[ ' + bounds.elseText + ' ]';
|
||||
txt.y = bounds.elsey + 1.5 * conf.boxMargin;
|
||||
svgDraw.drawText(g, txt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Draws a message
|
||||
@ -16323,7 +16271,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.LOOP_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData,'loop');
|
||||
svgDraw.drawLoop(diagram, loopData,'loop', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
case sq.yy.LINETYPE.OPT_START:
|
||||
@ -16334,7 +16282,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.OPT_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData, 'opt');
|
||||
svgDraw.drawLoop(diagram, loopData, 'opt', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
case sq.yy.LINETYPE.ALT_START:
|
||||
@ -16352,7 +16300,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.ALT_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData,'alt');
|
||||
svgDraw.drawLoop(diagram, loopData,'alt', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
default:
|
||||
@ -16475,6 +16423,59 @@ exports.drawActor = function(elem, left,description,conf){
|
||||
.text(description)
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws an actor in the diagram with the attaced line
|
||||
* @param center - The center of the the actor
|
||||
* @param pos The position if the actor in the list of actors
|
||||
* @param description The text in the box
|
||||
*/
|
||||
exports.drawLoop = function(elem,bounds,labelText, conf){
|
||||
var g = elem.append("g");
|
||||
var drawLoopLine = function(startx,starty,stopx,stopy){
|
||||
g.append("line")
|
||||
.attr("x1", startx)
|
||||
.attr("y1", starty)
|
||||
.attr("x2", stopx )
|
||||
.attr("y2", stopy )
|
||||
.attr("stroke-width", 2)
|
||||
.attr("stroke", "#526e52")
|
||||
.attr('class','loopLine');
|
||||
};
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty);
|
||||
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy );
|
||||
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy );
|
||||
if(typeof bounds.elsey !== 'undefined'){
|
||||
drawLoopLine(bounds.startx, bounds.elsey, bounds.stopx, bounds.elsey );
|
||||
}
|
||||
|
||||
var txt = exports.getTextObj();
|
||||
txt.text = labelText;
|
||||
txt.x = bounds.startx;
|
||||
txt.y = bounds.starty;
|
||||
txt.labelMargin = 1.5 * conf.boxMargin;
|
||||
txt.class = 'labelText';
|
||||
txt.fill = 'white';
|
||||
|
||||
exports.drawLabel(g,txt);
|
||||
|
||||
txt = exports.getTextObj();
|
||||
txt.text = '[ ' + bounds.title + ' ]';
|
||||
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2;
|
||||
txt.y = bounds.starty + 1.5 * conf.boxMargin;
|
||||
txt.anchor = 'middle';
|
||||
txt.class = 'loopText';
|
||||
|
||||
exports.drawText(g,txt);
|
||||
|
||||
if(typeof bounds.elseText !== 'undefined') {
|
||||
txt.text = '[ ' + bounds.elseText + ' ]';
|
||||
txt.y = bounds.elsey + 1.5 * conf.boxMargin;
|
||||
exports.drawText(g, txt);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*/
|
||||
|
4
dist/mermaid.slim.min.js
vendored
4
dist/mermaid.slim.min.js
vendored
File diff suppressed because one or more lines are too long
@ -292,7 +292,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.LOOP_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData,'loop', conf);
|
||||
svgDraw.drawLoop(diagram, loopData,'loop', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
case sq.yy.LINETYPE.OPT_START:
|
||||
@ -303,7 +303,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.OPT_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData, 'opt', conf);
|
||||
svgDraw.drawLoop(diagram, loopData, 'opt', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
case sq.yy.LINETYPE.ALT_START:
|
||||
@ -321,7 +321,7 @@ module.exports.draw = function (text, id) {
|
||||
case sq.yy.LINETYPE.ALT_END:
|
||||
loopData = exports.bounds.endLoop();
|
||||
|
||||
exports.drawLoop(diagram, loopData,'alt', conf);
|
||||
svgDraw.drawLoop(diagram, loopData,'alt', conf);
|
||||
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user