Comparing version 1.8.0 to 1.9.0
@@ -25,3 +25,3 @@ # A simple msgenny interpreter | ||
# generate the bundle | ||
webpack --optimize-minimize --optimize-dedupe sample-webpack.js sample-webpack.bundle.js | ||
webpack --optimize-minimize sample-webpack.js sample-webpack.bundle.js | ||
``` | ||
@@ -28,0 +28,0 @@ |
@@ -11,3 +11,4 @@ define(function (require) { | ||
elementId: "output", | ||
additionalTemplate: "fountainpen" | ||
additionalTemplate: "basic", | ||
includeSource: false | ||
}, | ||
@@ -14,0 +15,0 @@ function (pError, pSuccess) { |
@@ -143,3 +143,29 @@ # Xù - an MscGen super set | ||
### title - for tool tips | ||
From version 1.9.0 the xù language supports the `title` attribute. In SVG output | ||
the graphics renderer packaged with mscgenjs renders these as `<title>` tags. | ||
```xu | ||
xu { | ||
a, b; | ||
a => b [ | ||
label="the label", | ||
title="The title meister strikes again" | ||
]; | ||
a rbox b [ | ||
label="this is an rbox", | ||
title="This is a title for an rbox" | ||
]; | ||
b =>> b [ | ||
label="self reference", | ||
title="Title for a self referencing arc" | ||
]; | ||
} | ||
``` | ||
![rendered](title-attributes.gif) | ||
## MsGenny | ||
@@ -146,0 +172,0 @@ [MsGenny](./msgenny.md) also has support for inline expressions, the if-then-else construct above |
@@ -6,5 +6,8 @@ /* istanbul ignore else */ | ||
define(["./main/static-resolver", "./main/index"], function(resolver, main) { | ||
define(function(require) { | ||
"use strict"; | ||
var resolver = require("./main/static-resolver"); | ||
var main = require("./main/index"); | ||
return { | ||
@@ -11,0 +14,0 @@ /** |
@@ -7,5 +7,7 @@ /** | ||
*/ | ||
define(["./index"], function(index) { | ||
define(function(require) { | ||
"use strict"; | ||
var index = require("./index"); | ||
return { | ||
@@ -12,0 +14,0 @@ renderMsc : index.renderMsc, |
@@ -95,3 +95,3 @@ /* istanbul ignore else */ | ||
version: "1.8.0", | ||
version: "1.9.0", | ||
@@ -98,0 +98,0 @@ getAllowedValues: function() { |
@@ -7,25 +7,15 @@ /* istanbul ignore else */ | ||
/* eslint max-params: 0 */ | ||
define([ | ||
"../lib/lodash/lodash.custom", | ||
"../parse/mscgenparser", | ||
"../parse/xuparser", | ||
"../parse/msgennyparser", | ||
"../render/text/ast2mscgen", | ||
"../render/text/ast2msgenny", | ||
"../render/text/ast2xu", | ||
"../render/text/ast2dot", | ||
"../render/text/ast2doxygen", | ||
"../render/graphics/renderast"], function( | ||
_, | ||
mscgenparser, | ||
xuparser, | ||
msgennyparser, | ||
define(function(require) { | ||
"use strict"; | ||
ast2mscgen, | ||
ast2msgenny, | ||
ast2xu, | ||
ast2dot, | ||
ast2doxygen, | ||
renderast) { | ||
"use strict"; | ||
var mscgenparser = require("../parse/mscgenparser"); | ||
var xuparser = require("../parse/xuparser"); | ||
var msgennyparser = require("../parse/msgennyparser"); | ||
var ast2mscgen = require("../render/text/ast2mscgen"); | ||
var ast2xu = require("../render/text/ast2xu"); | ||
var ast2msgenny = require("../render/text/ast2msgenny"); | ||
var ast2dot = require("../render/text/ast2dot"); | ||
var ast2doxygen = require("../render/text/ast2doxygen"); | ||
var renderast = require("../render/graphics/renderast"); | ||
var DEFAULT_PARSER = mscgenparser; | ||
@@ -32,0 +22,0 @@ var DEFAULT_TEXT_RENDERER = ast2mscgen; |
{ | ||
"name": "mscgenjs", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Implementation of MscGen in JavaScript", | ||
@@ -13,6 +13,7 @@ "main": "index.js", | ||
"chai-xml": "0.3.1", | ||
"dependency-cruiser": "1.15.5", | ||
"eslint": "3.15.0", | ||
"istanbul": "0.4.5", | ||
"js-makedepend": "2.2.1", | ||
"jsdom": "9.10.0", | ||
"jsdom": "9.11.0", | ||
"lodash-cli": "4.17.4", | ||
@@ -26,4 +27,6 @@ "mocha": "3.2.0", | ||
"scripts": { | ||
"test": "mocha -R dot --timeout 6000 --recursive test", | ||
"test": "mocha -R dot --bail --timeout 6000 --recursive test", | ||
"cover": "istanbul cover node_modules/mocha/bin/_mocha -- --timeout 8000 --recursive test", | ||
"depcruise": "depcruise -v -T err main parse render *.js", | ||
"depcruise:graph": "depcruise -v -T dot -M amd -x \"amdefine|lodash\" main parse render *.js | dot -T svg > tmp_deps.svg", | ||
"nsp": "nsp check", | ||
@@ -30,0 +33,0 @@ "plato": "plato -r -d platoreports -x \"parser|test|lib|platoreports|node_modules|coverage|indexAMD|csstemplates\" ./", |
@@ -6,7 +6,5 @@ /* istanbul ignore else */ | ||
define([], function() { | ||
define(function() { | ||
"use strict"; | ||
return { | ||
SVGNS: "http://www.w3.org/2000/svg", | ||
XLINKNS: "http://www.w3.org/1999/xlink", | ||
LINE_WIDTH: 2, // px | ||
@@ -13,0 +11,0 @@ FONT_SIZE: 12 // px |
@@ -6,3 +6,3 @@ /* istanbul ignore else */ | ||
define([], function() { | ||
define(function() { | ||
"use strict"; | ||
@@ -9,0 +9,0 @@ return { |
@@ -6,5 +6,8 @@ /* istanbul ignore else */ | ||
define(["./renderlabels", "./constants"], function(labels, C) { | ||
define(function(require){ | ||
"use strict"; | ||
var renderlabels = require("./renderlabels"); | ||
var constants = require("./constants"); | ||
var DEFAULT_INTER_ENTITY_SPACING = 160; // px | ||
@@ -55,3 +58,3 @@ var DEFAULT_ENTITY_WIDTH = 100; // px | ||
getNoEntityLines: function(pLabel){ | ||
return labels.splitLabel(pLabel, "box", gEntityDims.width, C.FONT_SIZE).length; | ||
return renderlabels.splitLabel(pLabel, "box", gEntityDims.width, constants.FONT_SIZE).length; | ||
} | ||
@@ -58,0 +61,0 @@ }; |
@@ -6,3 +6,3 @@ /* istanbul ignore else */ | ||
define([], function() { | ||
define(function() { | ||
"use strict"; | ||
@@ -9,0 +9,0 @@ var INNERELEMENTPREFIX = "mscgen_js-svg-"; |
@@ -6,5 +6,8 @@ /* istanbul ignore else */ | ||
define(["../../lib/lodash/lodash.custom", "../text/arcmappings"], function(_, map) { | ||
define(function(require){ | ||
"use strict"; | ||
var _ = require("../../lib/lodash/lodash.custom"); | ||
var normalizekind = require("../astmassage/normalizekind"); | ||
var KINDS = { | ||
@@ -213,3 +216,3 @@ "->" : { | ||
function makeKindColorCombi (pKind, pColor) { | ||
return KINDS[map.getNormalizedKind(pKind)].marker.name + | ||
return KINDS[normalizekind.getNormalizedKind(pKind)].marker.name + | ||
(Boolean(pColor) ? " " + pColor : " black"); | ||
@@ -228,4 +231,4 @@ } | ||
} | ||
if (!!pArc.kind && !!KINDS[map.getNormalizedKind(pArc.kind)] && | ||
!!(KINDS[map.getNormalizedKind(pArc.kind)].marker) && | ||
if (!!pArc.kind && !!KINDS[normalizekind.getNormalizedKind(pArc.kind)] && | ||
!!(KINDS[normalizekind.getNormalizedKind(pArc.kind)].marker) && | ||
pKindColorCombis.indexOf(makeKindColorCombi(pArc.kind, pArc.linecolor)) < 0){ | ||
@@ -232,0 +235,0 @@ pKindColorCombis.push(makeKindColorCombi(pArc.kind, pArc.linecolor)); |
# Rendering - graphics | ||
In this section we motivate our choice for | ||
[scalable vector graphics](#scalable-vector-graphics), desribe how | ||
[scalable vector graphics](#scalable-vector-graphics), describe how | ||
our template or [skeleton](#the-scalable-vector-graphics-skeleton) looks and | ||
@@ -5,0 +5,0 @@ explain how the rendering functions fill it. |
@@ -6,19 +6,3 @@ /* istanbul ignore else */ | ||
define([ | ||
"./svgelementfactory", | ||
"./svglowlevelfactory", | ||
"./svgutensils", | ||
"./renderutensils", | ||
"./renderskeleton", | ||
"../text/flatten", | ||
"../text/arcmappings", | ||
"./rowmemory", | ||
"./idmanager", | ||
"./markermanager", | ||
"./entities", | ||
"./renderlabels", | ||
"./constants", | ||
"../../lib/lodash/lodash.custom"], | ||
/* eslint max-params: 0 */ | ||
function(fact, llfact, svgutl, utl, skel, flatten, map, rowmemory, id, mark, entities, labels, C, _) { | ||
define(function(require) { | ||
/** | ||
@@ -38,2 +22,17 @@ * | ||
var svgelementfactory = require("./svgelementfactory/index"); | ||
var svgutensils = require("./svgutensils"); | ||
var renderutensils = require("./renderutensils"); | ||
var renderskeleton = require("./renderskeleton"); | ||
var flatten = require("../astmassage/flatten"); | ||
var kind2class = require("./kind2class"); | ||
var aggregatekind = require("../astmassage/aggregatekind"); | ||
var rowmemory = require("./rowmemory"); | ||
var idmanager = require("./idmanager"); | ||
var markermanager = require("./markermanager"); | ||
var entities = require("./entities"); | ||
var renderlabels = require("./renderlabels"); | ||
var constants = require("./constants"); | ||
var _ = require("../../lib/lodash/lodash.custom"); | ||
var PAD_VERTICAL = 3; | ||
@@ -85,5 +84,5 @@ var DEFAULT_ARCROW_HEIGHT = 38; // chart only | ||
if (lElement) { | ||
return svgutl.webkitNamespaceBugWorkaround(lElement.innerHTML); | ||
return svgutensils.webkitNamespaceBugWorkaround(lElement.innerHTML); | ||
} else { | ||
return svgutl.webkitNamespaceBugWorkaround(pWindow.document.body.innerHTML); | ||
return svgutensils.webkitNamespaceBugWorkaround(pWindow.document.body.innerHTML); | ||
} | ||
@@ -108,9 +107,9 @@ } | ||
function renderASTPre(pAST, pWindow, pParentElementId, pOptions){ | ||
id.setPrefix(pParentElementId); | ||
idmanager.setPrefix(pParentElementId); | ||
gChart.document = skel.bootstrap( | ||
gChart.document = renderskeleton.bootstrap( | ||
pWindow, | ||
pParentElementId, | ||
id.get(), | ||
mark.getMarkerDefs(id.get(), pAST), | ||
idmanager.get(), | ||
markermanager.getMarkerDefs(idmanager.get(), pAST), | ||
pOptions | ||
@@ -120,3 +119,3 @@ ); | ||
gChart.regularArcTextVerticalAlignment = normalizeVerticalAlignment(pOptions.regularArcTextVerticalAlignment); | ||
svgutl.init(gChart.document); | ||
svgutensils.init(gChart.document); | ||
@@ -154,8 +153,8 @@ gChart.layer = createLayerShortcuts(gChart.document); | ||
return { | ||
defs : pDocument.getElementById(id.get("__defs")), | ||
lifeline : pDocument.getElementById(id.get("__lifelinelayer")), | ||
sequence : pDocument.getElementById(id.get("__sequencelayer")), | ||
notes : pDocument.getElementById(id.get("__notelayer")), | ||
inline : pDocument.getElementById(id.get("__arcspanlayer")), | ||
watermark : pDocument.getElementById(id.get("__watermark")) | ||
defs : pDocument.getElementById(idmanager.get("__defs")), | ||
lifeline : pDocument.getElementById(idmanager.get("__lifelinelayer")), | ||
sequence : pDocument.getElementById(idmanager.get("__sequencelayer")), | ||
notes : pDocument.getElementById(idmanager.get("__notelayer")), | ||
inline : pDocument.getElementById(idmanager.get("__arcspanlayer")), | ||
watermark : pDocument.getElementById(idmanager.get("__watermark")) | ||
}; | ||
@@ -198,3 +197,3 @@ } | ||
function calculateCanvasDimensions(pAST){ | ||
var lDepthCorrection = utl.determineDepthCorrection(pAST.depth, C.LINE_WIDTH); | ||
var lDepthCorrection = renderutensils.determineDepthCorrection(pAST.depth, constants.LINE_WIDTH); | ||
var lRowInfo = rowmemory.getLast(); | ||
@@ -222,4 +221,4 @@ var lCanvas = { | ||
function renderBackground(pCanvas) { | ||
gChart.document.getElementById(id.get("__background")).appendChild( | ||
fact.createRect(pCanvas, "bglayer") | ||
gChart.document.getElementById(idmanager.get("__background")).appendChild( | ||
svgelementfactory.createRect(pCanvas, "bglayer") | ||
); | ||
@@ -230,3 +229,3 @@ } | ||
gChart.layer.watermark.appendChild( | ||
fact.createDiagonalText(pWatermark, pCanvas, "watermark") | ||
svgelementfactory.createDiagonalText(pWatermark, pCanvas, "watermark") | ||
); | ||
@@ -241,3 +240,3 @@ } | ||
if (pOptions.width && pOptions.width !== "auto") { | ||
utl.scaleCanvasToWidth(pOptions.width, pCanvas); | ||
renderutensils.scaleCanvasToWidth(pOptions.width, pCanvas); | ||
} | ||
@@ -248,5 +247,5 @@ } | ||
function renderSvgElement(pCanvas) { | ||
var lSvgElement = gChart.document.getElementById(id.get()); | ||
var body = gChart.document.getElementById(id.get("__body")); | ||
body.setAttribute( | ||
var lSvgElement = gChart.document.getElementById(idmanager.get()); | ||
var lBody = gChart.document.getElementById(idmanager.get("__body")); | ||
lBody.setAttribute( | ||
"transform", | ||
@@ -257,13 +256,19 @@ "translate(" + pCanvas.horizontaltransform + "," + pCanvas.verticaltransform + | ||
if (!!pCanvas.autoscale && pCanvas.autoscale === true){ | ||
llfact.setAttributes(lSvgElement, { | ||
width: "100%", | ||
height: "100%", | ||
viewBox: "0 0 " + pCanvas.width.toString() + " " + pCanvas.height.toString() | ||
}); | ||
svgelementfactory.updateSVG( | ||
lSvgElement, | ||
{ | ||
width: "100%", | ||
height: "100%", | ||
viewBox: "0 0 " + pCanvas.width.toString() + " " + pCanvas.height.toString() | ||
} | ||
); | ||
} else { | ||
llfact.setAttributes(lSvgElement, { | ||
width: pCanvas.width.toString(), | ||
height: pCanvas.height.toString(), | ||
viewBox: "0 0 " + pCanvas.width.toString() + " " + pCanvas.height.toString() | ||
}); | ||
svgelementfactory.updateSVG( | ||
lSvgElement, | ||
{ | ||
width: pCanvas.width.toString(), | ||
height: pCanvas.height.toString(), | ||
viewBox: "0 0 " + pCanvas.width.toString() + " " + pCanvas.height.toString() | ||
} | ||
); | ||
} | ||
@@ -298,3 +303,3 @@ } | ||
entities.getDims().height, | ||
svgutl.getBBox( | ||
svgutensils.getBBox( | ||
renderEntity(lHighestEntity) | ||
@@ -308,7 +313,7 @@ ).height | ||
function renderEntity(pEntity, pX) { | ||
var lGroup = fact.createGroup(id.get(pEntity.name)); | ||
var lGroup = svgelementfactory.createGroup(idmanager.get(pEntity.name)); | ||
var lBBox = entities.getDims(); | ||
lBBox.x = pX ? pX : 0; | ||
lGroup.appendChild( | ||
fact.createRect( | ||
svgelementfactory.createRect( | ||
lBBox, | ||
@@ -321,3 +326,3 @@ "entity", | ||
lGroup.appendChild( | ||
labels.createLabel( | ||
renderlabels.createLabel( | ||
pEntity, | ||
@@ -341,3 +346,3 @@ { | ||
gChart.layer.lifeline.appendChild( | ||
fact.createUse( | ||
svgelementfactory.createUse( | ||
{ | ||
@@ -347,7 +352,7 @@ x:0, | ||
}, | ||
id.get("arcrow") | ||
idmanager.get("arcrow") | ||
) | ||
); | ||
gChart.layer.sequence.appendChild( | ||
fact.createUse( | ||
svgelementfactory.createUse( | ||
{ | ||
@@ -357,3 +362,3 @@ x:0, | ||
}, | ||
id.get("entities") | ||
idmanager.get("entities") | ||
) | ||
@@ -371,6 +376,6 @@ ); | ||
var lEntityXPos = 0; | ||
var lEntityGroup = fact.createGroup(id.get("entities")); | ||
var lEntityGroup = svgelementfactory.createGroup(idmanager.get("entities")); | ||
if (pEntities) { | ||
entities.setHeight(getMaxEntityHeight(pEntities) + C.LINE_WIDTH * 2); | ||
entities.setHeight(getMaxEntityHeight(pEntities) + constants.LINE_WIDTH * 2); | ||
@@ -384,3 +389,3 @@ pEntities.forEach(function(pEntity){ | ||
gChart.layer.sequence.appendChild( | ||
fact.createUse({x:0, y:0}, id.get("entities")) | ||
svgelementfactory.createUse({x:0, y:0}, idmanager.get("entities")) | ||
); | ||
@@ -427,3 +432,3 @@ } | ||
lElement = | ||
labels.createLabel( | ||
renderlabels.createLabel( | ||
pArc, | ||
@@ -443,5 +448,5 @@ { | ||
pRowMemory.push({ | ||
id : pCurrentId + "_lbl", | ||
tooltip : pArc.from + ' ' + pArc.kind + ' ' + pArc.to, | ||
layer : gChart.layer.sequence | ||
id : pCurrentId + "_lbl", | ||
title : pArc.title, | ||
layer : gChart.layer.sequence | ||
}); | ||
@@ -457,5 +462,5 @@ } else { // it's a regular arc | ||
pRowMemory.push({ | ||
id : pCurrentId, | ||
tooltip : pArc.from + ' ' + pArc.kind + ' ' + pArc.to, | ||
layer : gChart.layer.sequence | ||
id : pCurrentId, | ||
title : pArc.title, | ||
layer : gChart.layer.sequence | ||
}); | ||
@@ -472,6 +477,6 @@ } // / lTo or pArc.from === "*" | ||
pArcRow.forEach(function(pArc, pArcNumber){ | ||
var lCurrentId = id.get(pRowNumber.toString() + "_" + pArcNumber.toString()); | ||
var lCurrentId = idmanager.get(pRowNumber.toString() + "_" + pArcNumber.toString()); | ||
var lElement = {}; | ||
switch (map.getAggregate(pArc.kind)) { | ||
switch (aggregatekind.getAggregate(pArc.kind)) { | ||
case ("emptyarc"): | ||
@@ -491,2 +496,3 @@ lElement = renderEmptyArc(pArc, lCurrentId); | ||
id : lCurrentId, | ||
title : pArc.title, | ||
layer : gChart.layer.notes | ||
@@ -515,3 +521,3 @@ }); | ||
rowmemory.get(pRowNumber).height, | ||
svgutl.getBBox(lElement).height + 2 * C.LINE_WIDTH | ||
svgutensils.getBBox(lElement).height + 2 * constants.LINE_WIDTH | ||
) | ||
@@ -532,11 +538,11 @@ ); | ||
rowmemory.get(pRowNumber).height, | ||
id.get(lArcRowId) | ||
idmanager.get(lArcRowId) | ||
) | ||
); | ||
gChart.layer.lifeline.appendChild( | ||
fact.createUse({x:0, y:rowmemory.get(pRowNumber).y}, id.get(lArcRowId)) | ||
svgelementfactory.createUse({x:0, y:rowmemory.get(pRowNumber).y}, idmanager.get(lArcRowId)) | ||
); | ||
lRowMemory.forEach(function(pRowMemoryLine){ | ||
var lUse = fact.createUse( | ||
var lUse = svgelementfactory.createUse( | ||
{ | ||
@@ -548,7 +554,4 @@ x:0, | ||
); | ||
if (pRowMemoryLine.tooltip) { | ||
var lTitle = llfact.createElement('title'); | ||
var lText = llfact.createTextNode(pRowMemoryLine.tooltip); | ||
lTitle.appendChild(lText); | ||
lUse.appendChild(lTitle); | ||
if (pRowMemoryLine.title) { | ||
lUse.appendChild(svgelementfactory.createTitle(pRowMemoryLine.title)); | ||
} | ||
@@ -566,11 +569,11 @@ pRowMemoryLine.layer.appendChild(lUse); | ||
gInlineExpressionMemory = []; | ||
gChart.layer.defs.appendChild(renderLifeLines(pEntities, "arcrow", null, id.get("arcrow"))); | ||
gChart.layer.defs.appendChild(renderLifeLines(pEntities, "arcrow", null, idmanager.get("arcrow"))); | ||
/* put some space between the entities and the arcs */ | ||
gChart.layer.lifeline.appendChild( | ||
fact.createUse( | ||
svgelementfactory.createUse( | ||
{ | ||
x:0, | ||
y:rowmemory.get(-1).y}, | ||
id.get("arcrow") | ||
idmanager.get("arcrow") | ||
) | ||
@@ -599,20 +602,20 @@ ); | ||
var lMaxDepthCorrection = gChart.maxDepth * 2 * C.LINE_WIDTH; | ||
var lMaxDepthCorrection = gChart.maxDepth * 2 * constants.LINE_WIDTH; | ||
var lMaxWidth = | ||
(lOnD.to - lOnD.from) + | ||
(entities.getDims().interEntitySpacing - 2 * C.LINE_WIDTH) - | ||
(entities.getDims().interEntitySpacing - 2 * constants.LINE_WIDTH) - | ||
FOLD_SIZE - | ||
C.LINE_WIDTH; | ||
constants.LINE_WIDTH; | ||
var lStart = | ||
(lOnD.from - ((entities.getDims().interEntitySpacing - 3 * C.LINE_WIDTH - lMaxDepthCorrection) / 2) - | ||
(gChart.maxDepth - pArc.depth) * 2 * C.LINE_WIDTH); | ||
(lOnD.from - ((entities.getDims().interEntitySpacing - 3 * constants.LINE_WIDTH - lMaxDepthCorrection) / 2) - | ||
(gChart.maxDepth - pArc.depth) * 2 * constants.LINE_WIDTH); | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
pArc.label = pArc.kind + (pArc.label ? ": " + pArc.label : ""); | ||
var lTextGroup = labels.createLabel( | ||
var lTextGroup = renderlabels.createLabel( | ||
pArc, | ||
{ | ||
x: lStart + C.LINE_WIDTH - (lMaxWidth / 2), | ||
x: lStart + constants.LINE_WIDTH - (lMaxWidth / 2), | ||
y: gChart.arcRowHeight / 4, width:lMaxWidth | ||
@@ -627,12 +630,12 @@ }, | ||
var lBBox = svgutl.getBBox(lTextGroup); | ||
var lBBox = svgutensils.getBBox(lTextGroup); | ||
var lHeight = | ||
Math.max( | ||
lBBox.height + 2 * C.LINE_WIDTH, | ||
(gChart.arcRowHeight / 2) - 2 * C.LINE_WIDTH | ||
lBBox.height + 2 * constants.LINE_WIDTH, | ||
(gChart.arcRowHeight / 2) - 2 * constants.LINE_WIDTH | ||
); | ||
var lWidth = | ||
Math.min( | ||
lBBox.width + 2 * C.LINE_WIDTH, | ||
lBBox.width + 2 * constants.LINE_WIDTH, | ||
lMaxWidth | ||
@@ -642,5 +645,5 @@ ); | ||
var lBox = | ||
fact.createEdgeRemark( | ||
svgelementfactory.createEdgeRemark( | ||
{ | ||
width: lWidth - C.LINE_WIDTH + FOLD_SIZE, | ||
width: lWidth - constants.LINE_WIDTH + FOLD_SIZE, | ||
height: lHeight, | ||
@@ -668,3 +671,3 @@ x: lStart, | ||
gChart.layer.inline.appendChild( | ||
fact.createUse( | ||
svgelementfactory.createUse( | ||
{ | ||
@@ -702,6 +705,6 @@ x:0, | ||
} | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
pEntities.forEach(function(pEntity) { | ||
var lLine = fact.createLine( | ||
var lLine = svgelementfactory.createLine( | ||
{ | ||
@@ -732,10 +735,10 @@ xFrom: entities.getX(pEntity.name), | ||
var lRetval = {}; | ||
var lClass = "arc " + map.getAggregateClass(pKind) + " " + map.getClass(pKind); | ||
var lClass = "arc " + kind2class.getAggregateClass(pKind) + " " + kind2class.getClass(pKind); | ||
if (pDouble) { | ||
lRetval = fact.createGroup(); | ||
var lInnerTurn = fact.createUTurn( | ||
lRetval = svgelementfactory.createGroup(); | ||
var lInnerTurn = svgelementfactory.createUTurn( | ||
{x:pFrom, y:lHeight / 2}, | ||
(pYTo + lHeight - 2 * C.LINE_WIDTH), | ||
lWidth - 2 * C.LINE_WIDTH, | ||
(pYTo + lHeight - 2 * constants.LINE_WIDTH), | ||
lWidth - 2 * constants.LINE_WIDTH, | ||
lClass, | ||
@@ -745,8 +748,8 @@ pKind !== "::" | ||
/* we need a middle turn to attach the arrow to */ | ||
var lMiddleTurn = fact.createUTurn( | ||
var lMiddleTurn = svgelementfactory.createUTurn( | ||
{x:pFrom, y:lHeight / 2}, | ||
(pYTo + lHeight - C.LINE_WIDTH), | ||
(pYTo + lHeight - constants.LINE_WIDTH), | ||
lWidth | ||
); | ||
var lOuterTurn = fact.createUTurn( | ||
var lOuterTurn = svgelementfactory.createUTurn( | ||
{x:pFrom, y:lHeight / 2}, | ||
@@ -761,3 +764,3 @@ (pYTo + lHeight), | ||
} | ||
mark.getAttributes(id.get(), pKind, pLineColor, pFrom, pFrom).forEach(function(pAttribute){ | ||
markermanager.getAttributes(idmanager.get(), pKind, pLineColor, pFrom, pFrom).forEach(function(pAttribute){ | ||
lMiddleTurn.setAttribute(pAttribute.name, pAttribute.value); | ||
@@ -774,3 +777,3 @@ }); | ||
} else { | ||
lRetval = fact.createUTurn( | ||
lRetval = svgelementfactory.createUTurn( | ||
{ | ||
@@ -785,3 +788,3 @@ x:pFrom, | ||
); | ||
mark.getAttributes(id.get(), pKind, pLineColor, pFrom, pFrom).forEach( | ||
markermanager.getAttributes(idmanager.get(), pKind, pLineColor, pFrom, pFrom).forEach( | ||
function(pAttribute){ | ||
@@ -818,6 +821,6 @@ lRetval.setAttribute(pAttribute.name, pAttribute.value); | ||
function createArc(pId, pArc, pFrom, pTo) { | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
var lClass = "arc "; | ||
lClass += determineDirectionClass(pArc.kind); | ||
lClass += map.getAggregateClass(pArc.kind) + " " + map.getClass(pArc.kind); | ||
lClass += kind2class.getAggregateClass(pArc.kind) + " " + kind2class.getClass(pArc.kind); | ||
var lDoubleLine = [":>", "::", "<:>"].indexOf(pArc.kind) > -1; | ||
@@ -827,3 +830,3 @@ var lYTo = determineArcYTo(pArc); | ||
pTo = utl.determineArcXTo(pArc.kind, pFrom, pTo); | ||
pTo = renderutensils.determineArcXTo(pArc.kind, pFrom, pTo); | ||
@@ -838,7 +841,7 @@ if (pFrom === pTo) { | ||
lGroup.appendChild( | ||
labels.createLabel( | ||
renderlabels.createLabel( | ||
pArc, | ||
{ | ||
x:pFrom + 1.5 * C.LINE_WIDTH - (lTextWidth / 2), | ||
y:0 - (gChart.arcRowHeight / 5) - C.LINE_WIDTH / 2, | ||
x:pFrom + 1.5 * constants.LINE_WIDTH - (lTextWidth / 2), | ||
y:0 - (gChart.arcRowHeight / 5) - constants.LINE_WIDTH / 2, | ||
width:lTextWidth | ||
@@ -855,3 +858,3 @@ }, | ||
} else { | ||
var lLine = fact.createLine( | ||
var lLine = svgelementfactory.createLine( | ||
{xFrom: pFrom, yFrom: 0, xTo: pTo, yTo: lArcGradient}, | ||
@@ -863,4 +866,4 @@ { | ||
); | ||
mark.getAttributes( | ||
id.get(), pArc.kind, pArc.linecolor, pFrom, pTo | ||
markermanager.getAttributes( | ||
idmanager.get(), pArc.kind, pArc.linecolor, pFrom, pTo | ||
).forEach(function(pAttribute){ | ||
@@ -873,3 +876,3 @@ lLine.setAttribute(pAttribute.name, pAttribute.value); | ||
lGroup.appendChild( | ||
labels.createLabel( | ||
renderlabels.createLabel( | ||
pArc, | ||
@@ -901,3 +904,3 @@ {x: pFrom, y: 0, width: pTo - pFrom}, | ||
var lArcEnd = gChart.arcEndX; | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
@@ -909,3 +912,3 @@ if (pArc.from && pArc.to) { | ||
lGroup.appendChild( | ||
labels.createLabel( | ||
renderlabels.createLabel( | ||
pArc, | ||
@@ -930,15 +933,15 @@ {x:lArcStart, y:0, width:lArcEnd}, | ||
var lClass = "comment"; | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
if (pArc.from && pArc.to) { | ||
var lMaxDepthCorrection = gChart.maxDepth * 1 * C.LINE_WIDTH; | ||
var lArcDepthCorrection = (gChart.maxDepth - pArc.depth) * 2 * C.LINE_WIDTH; | ||
var lMaxDepthCorrection = gChart.maxDepth * 1 * constants.LINE_WIDTH; | ||
var lArcDepthCorrection = (gChart.maxDepth - pArc.depth) * 2 * constants.LINE_WIDTH; | ||
lStartX = | ||
(pOAndD.from - | ||
(entities.getDims().interEntitySpacing + 2 * C.LINE_WIDTH) / 2) - | ||
(entities.getDims().interEntitySpacing + 2 * constants.LINE_WIDTH) / 2) - | ||
(lArcDepthCorrection - lMaxDepthCorrection); | ||
lEndX = | ||
(pOAndD.to + | ||
(entities.getDims().interEntitySpacing + 2 * C.LINE_WIDTH) / 2) + | ||
(entities.getDims().interEntitySpacing + 2 * constants.LINE_WIDTH) / 2) + | ||
(lArcDepthCorrection - lMaxDepthCorrection); | ||
@@ -948,3 +951,3 @@ lClass = "inline_expression_divider"; | ||
var lLine = | ||
fact.createLine( | ||
svgelementfactory.createLine( | ||
{ | ||
@@ -973,20 +976,20 @@ xFrom: lStartX, | ||
/* begin: same as createBox */ | ||
var lMaxDepthCorrection = gChart.maxDepth * 2 * C.LINE_WIDTH; | ||
var lMaxDepthCorrection = gChart.maxDepth * 2 * constants.LINE_WIDTH; | ||
var lWidth = | ||
(pOAndD.to - pOAndD.from) + | ||
entities.getDims().interEntitySpacing - 2 * C.LINE_WIDTH - lMaxDepthCorrection; // px | ||
entities.getDims().interEntitySpacing - 2 * constants.LINE_WIDTH - lMaxDepthCorrection; // px | ||
var lStart = | ||
pOAndD.from - | ||
((entities.getDims().interEntitySpacing - 2 * C.LINE_WIDTH - lMaxDepthCorrection) / 2); | ||
((entities.getDims().interEntitySpacing - 2 * constants.LINE_WIDTH - lMaxDepthCorrection) / 2); | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
/* end: same as createBox */ | ||
var lArcDepthCorrection = (gChart.maxDepth - pArc.depth) * 2 * C.LINE_WIDTH; | ||
var lArcDepthCorrection = (gChart.maxDepth - pArc.depth) * 2 * constants.LINE_WIDTH; | ||
lGroup.appendChild( | ||
fact.createRect( | ||
svgelementfactory.createRect( | ||
{ | ||
width: lWidth + lArcDepthCorrection * 2, | ||
height: pHeight ? pHeight : gChart.arcRowHeight - 2 * C.LINE_WIDTH, | ||
height: pHeight ? pHeight : gChart.arcRowHeight - 2 * constants.LINE_WIDTH, | ||
x: lStart - lArcDepthCorrection, | ||
@@ -1018,16 +1021,16 @@ y: 0 | ||
/* begin: same as createInlineExpressionBox */ | ||
var lMaxDepthCorrection = gChart.maxDepth * 2 * C.LINE_WIDTH; | ||
var lMaxDepthCorrection = gChart.maxDepth * 2 * constants.LINE_WIDTH; | ||
var lWidth = | ||
(pOAndD.to - pOAndD.from) + | ||
entities.getDims().interEntitySpacing - 2 * C.LINE_WIDTH - lMaxDepthCorrection; // px | ||
entities.getDims().interEntitySpacing - 2 * constants.LINE_WIDTH - lMaxDepthCorrection; // px | ||
var lStart = | ||
pOAndD.from - | ||
((entities.getDims().interEntitySpacing - 2 * C.LINE_WIDTH - lMaxDepthCorrection) / 2); | ||
((entities.getDims().interEntitySpacing - 2 * constants.LINE_WIDTH - lMaxDepthCorrection) / 2); | ||
/* end: same as createInlineExpressionBox */ | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
var lBox = {}; | ||
var lTextGroup = labels.createLabel(pArc, {x:lStart, y:0, width:lWidth}); | ||
var lTextBBox = svgutl.getBBox(lTextGroup); | ||
var lHeight = Math.max(lTextBBox.height + 2 * C.LINE_WIDTH, gChart.arcRowHeight - 2 * C.LINE_WIDTH); | ||
var lTextGroup = renderlabels.createLabel(pArc, {x:lStart, y:0, width:lWidth}); | ||
var lTextBBox = svgutensils.getBBox(lTextGroup); | ||
var lHeight = Math.max(lTextBBox.height + 2 * constants.LINE_WIDTH, gChart.arcRowHeight - 2 * constants.LINE_WIDTH); | ||
var lBBox = {width: lWidth, height: lHeight, x: lStart, y: (0 - lHeight / 2)}; | ||
@@ -1037,12 +1040,12 @@ | ||
case ("rbox"): | ||
lBox = fact.createRBox(lBBox, "box rbox", pArc.linecolor, pArc.textbgcolor); | ||
lBox = svgelementfactory.createRBox(lBBox, "box rbox", pArc.linecolor, pArc.textbgcolor); | ||
break; | ||
case ("abox"): | ||
lBox = fact.createABox(lBBox, "box abox", pArc.linecolor, pArc.textbgcolor); | ||
lBox = svgelementfactory.createABox(lBBox, "box abox", pArc.linecolor, pArc.textbgcolor); | ||
break; | ||
case ("note"): | ||
lBox = fact.createNote(lBBox, "box note", pArc.linecolor, pArc.textbgcolor); | ||
lBox = svgelementfactory.createNote(lBBox, "box note", pArc.linecolor, pArc.textbgcolor); | ||
break; | ||
default: // "box" | ||
lBox = fact.createRect(lBBox, "box", pArc.linecolor, pArc.textbgcolor); | ||
lBox = svgelementfactory.createRect(lBBox, "box", pArc.linecolor, pArc.textbgcolor); | ||
break; | ||
@@ -1068,5 +1071,5 @@ } | ||
clean : function (pParentElementId, pWindow) { | ||
gChart.document = skel.init(pWindow); | ||
svgutl.init(gChart.document); | ||
svgutl.removeRenderedSVGFromElement(pParentElementId); | ||
gChart.document = renderskeleton.init(pWindow); | ||
svgutensils.init(gChart.document); | ||
svgutensils.removeRenderedSVGFromElement(pParentElementId); | ||
}, | ||
@@ -1073,0 +1076,0 @@ |
@@ -6,5 +6,10 @@ /* istanbul ignore else */ | ||
define(["./svgelementfactory", "./svgutensils", "./constants", "../text/textutensils", "../text/arcmappings"], | ||
function(fact, svgutl, C, txt, map) { | ||
define(function(require) { | ||
"use strict"; | ||
var svgelementfactory = require("./svgelementfactory/index"); | ||
var svgutensils = require("./svgutensils"); | ||
var constants = require("./constants"); | ||
var wrap = require("../textutensils/wrap"); | ||
var kind2class = require("./kind2class"); | ||
var aggregatekind = require("../astmassage/aggregatekind"); | ||
@@ -36,3 +41,3 @@ /** | ||
function renderArcLabelLineBackground(lLabelElement, pTextbgcolor){ | ||
var lRect = fact.createRect(svgutl.getBBox(lLabelElement), "label-text-background"); | ||
var lRect = svgelementfactory.createRect(svgutensils.getBBox(lLabelElement), "label-text-background"); | ||
if (pTextbgcolor) { | ||
@@ -47,3 +52,3 @@ lRect.setAttribute("style", "fill:" + pTextbgcolor + "; stroke:" + pTextbgcolor + ";"); | ||
if (pPosition === 0) { | ||
lText = fact.createText( | ||
lText = svgelementfactory.createText( | ||
pLine, | ||
@@ -62,3 +67,3 @@ { | ||
} else { | ||
lText = fact.createText( | ||
lText = svgelementfactory.createText( | ||
pLine, | ||
@@ -80,4 +85,4 @@ { | ||
var lKind = pOptionsKind || pArcKind; | ||
var lClass = map.getClass(lKind); | ||
var lAggregateClass = map.getAggregateClass(lKind); | ||
var lClass = kind2class.getClass(lKind); | ||
var lAggregateClass = kind2class.getAggregateClass(lKind); | ||
@@ -90,3 +95,3 @@ return lClass === lAggregateClass | ||
function createLabelLine(pLine, pMiddle, pStartY, pArc, pPosition, pOptions) { | ||
var lY = pStartY + ((pPosition + 1 / 4) * svgutl.calculateTextHeight()); | ||
var lY = pStartY + ((pPosition + 1 / 4) * svgutensils.calculateTextHeight()); | ||
var lClass = ""; | ||
@@ -99,3 +104,3 @@ lClass = determineClasses(pArc.kind, pOptions && pOptions.kind, "-text "); | ||
if (pOptions.alignAround){ | ||
lY = pStartY + ((pPosition + 1 / 4) * (svgutl.calculateTextHeight() + C.LINE_WIDTH)); | ||
lY = pStartY + ((pPosition + 1 / 4) * (svgutensils.calculateTextHeight() + constants.LINE_WIDTH)); | ||
} | ||
@@ -112,3 +117,3 @@ } | ||
function _createLabel(pArc, pDims, pOptions, pId) { | ||
var lGroup = fact.createGroup(pId); | ||
var lGroup = svgelementfactory.createGroup(pId); | ||
@@ -121,3 +126,3 @@ if (pArc.label) { | ||
pDims.width, | ||
C.FONT_SIZE, | ||
constants.FONT_SIZE, | ||
pOptions ? pOptions.wordWrapArcs : false | ||
@@ -132,3 +137,3 @@ ); | ||
var lStartY = pDims.y - (lLines.length - 1) / 2 * (svgutl.calculateTextHeight() + 1); | ||
var lStartY = pDims.y - (lLines.length - 1) / 2 * (svgutensils.calculateTextHeight() + 1); | ||
if (!!pOptions && pOptions.alignAround){ | ||
@@ -138,3 +143,3 @@ if (lLines.length === 1) { | ||
} | ||
lStartY = pDims.y - (lLines.length - 1) / 2 * (svgutl.calculateTextHeight() + C.LINE_WIDTH + 1); | ||
lStartY = pDims.y - (lLines.length - 1) / 2 * (svgutensils.calculateTextHeight() + constants.LINE_WIDTH + 1); | ||
} | ||
@@ -189,4 +194,4 @@ lLines | ||
function _splitLabel(pLabel, pKind, pWidth, pFontSize, pWordWrapArcs) { | ||
if ("box" === map.getAggregate(pKind) || typeof pKind === 'undefined' || pWordWrapArcs){ | ||
return txt.wrap(pLabel, _determineMaxTextWidthInChars(pWidth, pFontSize)); | ||
if ("box" === aggregatekind.getAggregate(pKind) || typeof pKind === 'undefined' || pWordWrapArcs){ | ||
return wrap.wrap(pLabel, _determineMaxTextWidthInChars(pWidth, pFontSize)); | ||
} else { | ||
@@ -193,0 +198,0 @@ return pLabel.split('\\n'); |
@@ -6,3 +6,3 @@ /* istanbul ignore else */ | ||
define(["./svgelementfactory", "./constants", "./csstemplates"], function(fact, C, csstemplates) { | ||
define(function(require) { | ||
/** | ||
@@ -30,2 +30,6 @@ * sets up a skeleton svg, with the skeleton for rendering an msc ready | ||
var svgelementfactory = require("./svgelementfactory/index"); | ||
var constants = require("./constants"); | ||
var csstemplates = require("./csstemplates"); | ||
var gDocument = {}; | ||
@@ -36,5 +40,5 @@ | ||
if (pMarker.type === "method"){ | ||
pDefs.appendChild(fact.createMarkerPolygon(pMarker.name, pMarker.path, pMarker.color)); | ||
pDefs.appendChild(svgelementfactory.createMarkerPolygon(pMarker.name, pMarker.path, pMarker.color)); | ||
} else { | ||
pDefs.appendChild(fact.createMarkerPath(pMarker.name, pMarker.path, pMarker.color)); | ||
pDefs.appendChild(svgelementfactory.createMarkerPath(pMarker.name, pMarker.path, pMarker.color)); | ||
} | ||
@@ -60,6 +64,6 @@ }); | ||
*/ | ||
var lDefs = fact.createDefs(); | ||
var lDefs = svgelementfactory.createDefs(); | ||
lDefs.appendChild(setupStyle(pOptions, pElementId)); | ||
lDefs = setupMarkers(lDefs, pMarkerDefs); | ||
lDefs.appendChild(fact.createGroup(pElementId + "__defs")); | ||
lDefs.appendChild(svgelementfactory.createGroup(pElementId + "__defs")); | ||
return lDefs; | ||
@@ -69,10 +73,10 @@ } | ||
function setupBody(pElementId) { | ||
var lBody = fact.createGroup(pElementId + "__body"); | ||
var lBody = svgelementfactory.createGroup(pElementId + "__body"); | ||
lBody.appendChild(fact.createGroup(pElementId + "__background")); | ||
lBody.appendChild(fact.createGroup(pElementId + "__arcspanlayer")); | ||
lBody.appendChild(fact.createGroup(pElementId + "__lifelinelayer")); | ||
lBody.appendChild(fact.createGroup(pElementId + "__sequencelayer")); | ||
lBody.appendChild(fact.createGroup(pElementId + "__notelayer")); | ||
lBody.appendChild(fact.createGroup(pElementId + "__watermark")); | ||
lBody.appendChild(svgelementfactory.createGroup(pElementId + "__background")); | ||
lBody.appendChild(svgelementfactory.createGroup(pElementId + "__arcspanlayer")); | ||
lBody.appendChild(svgelementfactory.createGroup(pElementId + "__lifelinelayer")); | ||
lBody.appendChild(svgelementfactory.createGroup(pElementId + "__sequencelayer")); | ||
lBody.appendChild(svgelementfactory.createGroup(pElementId + "__notelayer")); | ||
lBody.appendChild(svgelementfactory.createGroup(pElementId + "__watermark")); | ||
return lBody; | ||
@@ -82,3 +86,10 @@ } | ||
function _init(pWindow) { | ||
fact.init(pWindow.document); | ||
svgelementfactory.init( | ||
pWindow.document, | ||
{ | ||
LINE_WIDTH: constants.LINE_WIDTH, | ||
FONT_SIZE: constants.FONT_SIZE | ||
} | ||
); | ||
return pWindow.document; | ||
@@ -95,3 +106,3 @@ } | ||
} | ||
var lSkeletonSvg = fact.createSVG(pSvgElementId, pSvgElementId, distillRenderMagic(pOptions)); | ||
var lSkeletonSvg = svgelementfactory.createSVG(pSvgElementId, pSvgElementId, distillRenderMagic(pOptions)); | ||
lSkeletonSvg.appendChild(setupDesc(pWindow, pSvgElementId, pOptions.source)); | ||
@@ -106,3 +117,3 @@ lSkeletonSvg.appendChild(setupDefs(pSvgElementId, pMarkerDefs, pOptions)); | ||
function setupDesc(pWindow, pSvgElementId, pSource) { | ||
var lDesc = fact.createDesc(pSvgElementId + "__msc_source"); | ||
var lDesc = svgelementfactory.createDesc(pSvgElementId + "__msc_source"); | ||
if (Boolean(pSource)){ | ||
@@ -183,4 +194,4 @@ lDesc.appendChild(pWindow.document.createTextNode( | ||
return (distillBeforeCSS(pOptions) + csstemplates.baseTemplate + distillAfterCSS(pOptions)) | ||
.replace(/<%=fontSize%>/g, C.FONT_SIZE) | ||
.replace(/<%=lineWidth%>/g, C.LINE_WIDTH) | ||
.replace(/<%=fontSize%>/g, constants.FONT_SIZE) | ||
.replace(/<%=lineWidth%>/g, constants.LINE_WIDTH) | ||
.replace(/<%=id%>/g, pSvgElementId); | ||
@@ -187,0 +198,0 @@ |
@@ -6,3 +6,3 @@ /* istanbul ignore else */ | ||
define([], function() { | ||
define(function() { | ||
"use strict"; | ||
@@ -9,0 +9,0 @@ |
@@ -6,3 +6,3 @@ /* istanbul ignore else */ | ||
define([], function() { | ||
define(function() { | ||
"use strict"; | ||
@@ -9,0 +9,0 @@ |
@@ -6,3 +6,3 @@ /* istanbul ignore else */ | ||
define([], function() { | ||
define(function() { | ||
"use strict"; | ||
@@ -9,0 +9,0 @@ return { |
@@ -6,15 +6,19 @@ /* istanbul ignore else */ | ||
define(["./constants", "./idmanager", "./svgelementfactory", "./svglowlevelfactory", "../../lib/lodash/lodash.custom"], | ||
function(C, id, fact, llfact, _) { | ||
define(function(require) { | ||
"use strict"; | ||
var idmanager = require("./idmanager"); | ||
var svgelementfactory = require("./svgelementfactory/index"); | ||
var _ = require("../../lib/lodash/lodash.custom"); | ||
/** | ||
* Some SVG specific calculations & workarounds | ||
*/ | ||
"use strict"; | ||
var gDocument = {}; | ||
var gSvgBBoxerId = id.get("bboxer"); | ||
var gSvgBBoxerId = idmanager.get("bboxer"); | ||
/* istanbul ignore next */ | ||
function _createBBoxerSVG(pId){ | ||
var lSvg = fact.createSVG(pId, id.get()); | ||
var lSvg = svgelementfactory.createSVG(pId, idmanager.get()); | ||
gDocument.body.appendChild(lSvg); | ||
@@ -76,15 +80,2 @@ | ||
function createTSpan(pLabel){ | ||
var lTSpanLabel = gDocument.createElementNS(C.SVGNS, "tspan"); | ||
lTSpanLabel.appendChild(gDocument.createTextNode(pLabel)); | ||
return lTSpanLabel; | ||
} | ||
function createText(pLabel) { | ||
var lText = llfact.createElement("text", {x: "0", y: "0"}); | ||
lText.appendChild(createTSpan(pLabel)); | ||
return lText; | ||
} | ||
function _calculateTextHeight(){ | ||
@@ -98,3 +89,11 @@ /* Uses a string with some characters that tend to stick out | ||
*/ | ||
return _getBBox(createText("\u00C1jy\u00CE9\u0192@\uD83D\uDCA9")).height; | ||
return _getBBox( | ||
svgelementfactory.createText( | ||
"\u00C1jy\u00CE9\u0192@\uD83D\uDCA9", | ||
{ | ||
x: 0, | ||
y: 0 | ||
} | ||
) | ||
).height; | ||
} | ||
@@ -104,5 +103,5 @@ | ||
function _removeRenderedSVGFromElement(pElementId){ | ||
id.setPrefix(pElementId); | ||
var lChildElement = gDocument.getElementById(id.get()); | ||
if (!!lChildElement) { | ||
idmanager.setPrefix(pElementId); | ||
var lChildElement = gDocument.getElementById(idmanager.get()); | ||
if (Boolean(lChildElement)) { | ||
var lParentElement = gDocument.getElementById(pElementId); | ||
@@ -109,0 +108,0 @@ if (lParentElement) { |
@@ -16,5 +16,7 @@ /* | ||
define(["../../lib/lodash/lodash.custom"], function(_) { | ||
define(function(require) { | ||
"use strict"; | ||
var _ = require("../../lib/lodash/lodash.custom"); | ||
var EMPTY_ARC = [{kind:"|||"}]; | ||
@@ -21,0 +23,0 @@ |
@@ -11,6 +11,11 @@ /* | ||
define(["./flatten", "./textutensils", "./arcmappings", "../../lib/lodash/lodash.custom"], | ||
function(flatten, txt, map, utl) { | ||
define(function(require) { | ||
"use strict"; | ||
var wrap = require("../textutensils/wrap"); | ||
var flatten = require("../astmassage/flatten"); | ||
var dotMappings = require("./dotMappings"); | ||
var aggregatekind = require("../astmassage/aggregatekind"); | ||
var _ = require("../../lib/lodash/lodash.custom"); | ||
var INDENT = " "; | ||
@@ -52,3 +57,3 @@ var MAX_TEXT_WIDTH = 40; | ||
function renderString(pString) { | ||
var lStringAry = txt.wrap(pString.replace(/"/g, "\\\""), MAX_TEXT_WIDTH); | ||
var lStringAry = wrap.wrap(pString.replace(/"/g, "\\\""), MAX_TEXT_WIDTH); | ||
var lString = lStringAry.slice(0, -1).reduce(function(pPrev, pLine){ | ||
@@ -120,4 +125,4 @@ return pPrev + pLine + "\n"; | ||
var lAttrs = translateAttributes(pArc); | ||
pushAttribute(lAttrs, map.getStyle(pArc.kind), "style"); | ||
pushAttribute(lAttrs, map.getShape(pArc.kind), "shape"); | ||
pushAttribute(lAttrs, dotMappings.getStyle(pArc.kind), "style"); | ||
pushAttribute(lAttrs, dotMappings.getShape(pArc.kind), "shape"); | ||
@@ -141,7 +146,7 @@ lRetVal += renderAttributeBlock(lAttrs) + "\n" + INDENT + pIndent; | ||
pushAttribute(lAttrs, map.getStyle(pArc.kind), "style"); | ||
pushAttribute(lAttrs, dotMappings.getStyle(pArc.kind), "style"); | ||
switch (pAggregatedKind) { | ||
case ("directional") : | ||
{ | ||
pushAttribute(lAttrs, map.getArrow(pArc.kind), "arrowhead"); | ||
pushAttribute(lAttrs, dotMappings.getArrow(pArc.kind), "arrowhead"); | ||
} | ||
@@ -151,4 +156,4 @@ break; | ||
{ | ||
pushAttribute(lAttrs, map.getArrow(pArc.kind), "arrowhead"); | ||
pushAttribute(lAttrs, map.getArrow(pArc.kind), "arrowtail"); | ||
pushAttribute(lAttrs, dotMappings.getArrow(pArc.kind), "arrowhead"); | ||
pushAttribute(lAttrs, dotMappings.getArrow(pArc.kind), "arrowtail"); | ||
pushAttribute(lAttrs, "both", "dir"); | ||
@@ -176,3 +181,3 @@ } | ||
var lRetVal = ""; | ||
var lAggregatedKind = map.getAggregate(pArc.kind); | ||
var lAggregatedKind = aggregatekind.getAggregate(pArc.kind); | ||
@@ -216,3 +221,3 @@ if (lAggregatedKind === "box") { | ||
render : function(pAST) { | ||
return _renderAST(flatten.dotFlatten(utl.cloneDeep(pAST))); | ||
return _renderAST(flatten.dotFlatten(_.cloneDeep(pAST))); | ||
} | ||
@@ -219,0 +224,0 @@ }; |
@@ -13,5 +13,9 @@ /* | ||
define(["./arcmappings", "./textutensils", "./ast2thing"], function(map, utl, thing) { | ||
define(function(require) { | ||
"use strict"; | ||
var aggregatekind = require("../astmassage/aggregatekind"); | ||
var escape = require("../textutensils/escape"); | ||
var ast2thing = require("./ast2thing"); | ||
var INDENT = " "; | ||
@@ -23,3 +27,3 @@ var SP = " "; | ||
function renderKind(pKind) { | ||
if ("inline_expression" === map.getAggregate(pKind)) { | ||
if ("inline_expression" === aggregatekind.getAggregate(pKind)) { | ||
return "--"; | ||
@@ -34,3 +38,3 @@ } | ||
if (pAttribute.name && pAttribute.value) { | ||
lRetVal += pAttribute.name + "=\"" + utl.escapeString(pAttribute.value) + "\""; | ||
lRetVal += pAttribute.name + "=\"" + escape.escapeString(pAttribute.value) + "\""; | ||
} | ||
@@ -62,3 +66,3 @@ return lRetVal; | ||
render : function(pAST) { | ||
return thing.render(pAST, { | ||
return ast2thing.render(pAST, { | ||
"renderCommentfn" : renderComments, | ||
@@ -65,0 +69,0 @@ "renderAttributefn" : renderAttribute, |
@@ -11,5 +11,9 @@ /* | ||
define(["./arcmappings", "./textutensils", "./ast2thing"], function(map, utl, thing) { | ||
define(function(require) { | ||
"use strict"; | ||
var aggregatekind = require("../astmassage/aggregatekind"); | ||
var escape = require("../textutensils/escape"); | ||
var ast2thing = require("./ast2thing"); | ||
var INDENT = " "; | ||
@@ -32,3 +36,3 @@ var SP = " "; | ||
function renderKind(pKind) { | ||
if ("inline_expression" === map.getAggregate(pKind)) { | ||
if ("inline_expression" === aggregatekind.getAggregate(pKind)) { | ||
return "--"; | ||
@@ -42,3 +46,3 @@ } | ||
if (pAttribute.name && pAttribute.value) { | ||
lRetVal += pAttribute.name + "=\"" + utl.escapeString(pAttribute.value) + "\""; | ||
lRetVal += pAttribute.name + "=\"" + escape.escapeString(pAttribute.value) + "\""; | ||
} | ||
@@ -58,3 +62,3 @@ return lRetVal; | ||
init(pMinimal); | ||
return thing.render(pAST, { | ||
return ast2thing.render(pAST, { | ||
"renderAttributefn" : renderAttribute, | ||
@@ -61,0 +65,0 @@ "optionIsValidfn": optionIsValid, |
@@ -11,5 +11,7 @@ /* | ||
define(['./ast2thing'], function(thing) { | ||
define(function(require) { | ||
"use strict"; | ||
var ast2thing = require("./ast2thing"); | ||
function gennyStringisQuotable(pString) { | ||
@@ -50,3 +52,3 @@ var lMatchResult = pString.match(/[;,{]/); | ||
render : function(pAST) { | ||
return thing.render(pAST, { | ||
return ast2thing.render(pAST, { | ||
"renderAttributefn" : renderAttribute, | ||
@@ -53,0 +55,0 @@ "renderEntityNamefn" : renderEntityName |
@@ -11,5 +11,7 @@ /* | ||
define(["./textutensils"], function(utl) { | ||
define(function(require) { | ||
"use strict"; | ||
var escape = require("../textutensils/escape"); | ||
var INDENT = " "; | ||
@@ -146,3 +148,3 @@ var SP = " "; | ||
(typeof pOption.value === "string" | ||
? "\"" + utl.escapeString(pOption.value) + "\"" | ||
? "\"" + escape.escapeString(pOption.value) + "\"" | ||
: pOption.value.toString()); | ||
@@ -149,0 +151,0 @@ } |
@@ -11,5 +11,8 @@ /* | ||
define(["./textutensils", "./ast2thing"], function(utl, thing) { | ||
define(function(require) { | ||
"use strict"; | ||
var escape = require("../textutensils/escape"); | ||
var ast2thing = require("./ast2thing"); | ||
var INDENT = " "; | ||
@@ -34,3 +37,3 @@ var SP = " "; | ||
if (pAttribute.name && pAttribute.value) { | ||
lRetVal += pAttribute.name + "=\"" + utl.escapeString(pAttribute.value) + "\""; | ||
lRetVal += pAttribute.name + "=\"" + escape.escapeString(pAttribute.value) + "\""; | ||
} | ||
@@ -43,3 +46,3 @@ return lRetVal; | ||
init(pMinimal); | ||
return thing.render(pAST, { | ||
return ast2thing.render(pAST, { | ||
"renderAttributefn" : renderAttribute, | ||
@@ -54,3 +57,4 @@ "supportedEntityAttributes" : [ | ||
"linecolor", "textcolor", "textbgcolor", | ||
"arclinecolor", "arctextcolor", "arctextbgcolor", "arcskip" | ||
"arclinecolor", "arctextcolor", "arctextbgcolor", "arcskip", | ||
"title" | ||
], | ||
@@ -57,0 +61,0 @@ "program" : { |
@@ -25,19 +25,2 @@ # Rendering text: other script languages | ||
## Flattening | ||
To ease rendering the [flatten.js](flatten.js) module massages the | ||
syntax tree in several ways: | ||
- makes sure each entity has a 'label' attribute | ||
- distributes the arc*colors from entities to the appropriate lines and arcs | ||
- make sure arcs point from left to right | ||
- takes care of 'unwinding' nested inline expressions | ||
- makes individual arcs of broadcast arcs | ||
:page_with_curl: code in [flatten.js](flatten.js) | ||
## Coloring | ||
:page_with_curl: code in [colorize.js](colorize.js) | ||
## Utensils | ||
:page_with_curl: code in [textutensils.js](textutensils.js) | ||
## dot | ||
@@ -44,0 +27,0 @@ Each sequence chart can be expressed as a communications diagram. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
908740
105
19123
13