in zookeeper-contrib/zookeeper-contrib-loggraph/src/main/resources/webapp/org/apache/zookeeper/graph/resources/raphael.js [1039:1295]
var setFillAndStroke = function (o, params) {
var dasharray = {
"": [0],
"none": [0],
"-": [3, 1],
".": [1, 1],
"-.": [3, 1, 1, 1],
"-..": [3, 1, 1, 1, 1, 1],
". ": [1, 3],
"- ": [4, 3],
"--": [8, 3],
"- .": [4, 3, 1, 3],
"--.": [8, 3, 1, 3],
"--..": [8, 3, 1, 3, 1, 3]
},
node = o.node,
attrs = o.attrs,
rot = o.rotate(),
addDashes = function (o, value) {
value = dasharray[lowerCase.call(value)];
if (value) {
var width = o.attrs["stroke-width"] || "1",
butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
dashes = [];
var i = value[length];
while (i--) {
dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;
}
$(node, {"stroke-dasharray": dashes[join](",")});
}
};
params[has]("rotation") && (rot = params.rotation);
var rotxy = (rot + E)[split](separator);
if (!(rotxy.length - 1)) {
rotxy = null;
} else {
rotxy[1] = +rotxy[1];
rotxy[2] = +rotxy[2];
}
toFloat(rot) && o.rotate(0, true);
for (var att in params) {
if (params[has](att)) {
if (!availableAttrs[has](att)) {
continue;
}
var value = params[att];
attrs[att] = value;
switch (att) {
case "blur":
o.blur(value);
break;
case "rotation":
o.rotate(value, true);
break;
// Hyperlink
case "href":
case "title":
case "target":
var pn = node.parentNode;
if (lowerCase.call(pn.tagName) != "a") {
var hl = $("a");
pn.insertBefore(hl, node);
hl[appendChild](node);
pn = hl;
}
pn.setAttributeNS(o.paper.xlink, att, value);
break;
case "cursor":
node.style.cursor = value;
break;
case "clip-rect":
var rect = (value + E)[split](separator);
if (rect[length] == 4) {
o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);
var el = $("clipPath"),
rc = $("rect");
el.id = "r" + (R._id++)[toString](36);
$(rc, {
x: rect[0],
y: rect[1],
width: rect[2],
height: rect[3]
});
el[appendChild](rc);
o.paper.defs[appendChild](el);
$(node, {"clip-path": "url(#" + el.id + ")"});
o.clip = rc;
}
if (!value) {
var clip = doc.getElementById(node.getAttribute("clip-path")[rp](/(^url\(#|\)$)/g, E));
clip && clip.parentNode.removeChild(clip);
$(node, {"clip-path": E});
delete o.clip;
}
break;
case "path":
if (o.type == "path") {
$(node, {d: value ? attrs.path = roundPath(pathToAbsolute(value)) : "M0,0"});
}
break;
case "width":
node[setAttribute](att, value);
if (attrs.fx) {
att = "x";
value = attrs.x;
} else {
break;
}
case "x":
if (attrs.fx) {
value = -attrs.x - (attrs.width || 0);
}
case "rx":
if (att == "rx" && o.type == "rect") {
break;
}
case "cx":
rotxy && (att == "x" || att == "cx") && (rotxy[1] += value - attrs[att]);
node[setAttribute](att, round(value));
o.pattern && updatePosition(o);
break;
case "height":
node[setAttribute](att, value);
if (attrs.fy) {
att = "y";
value = attrs.y;
} else {
break;
}
case "y":
if (attrs.fy) {
value = -attrs.y - (attrs.height || 0);
}
case "ry":
if (att == "ry" && o.type == "rect") {
break;
}
case "cy":
rotxy && (att == "y" || att == "cy") && (rotxy[2] += value - attrs[att]);
node[setAttribute](att, round(value));
o.pattern && updatePosition(o);
break;
case "r":
if (o.type == "rect") {
$(node, {rx: value, ry: value});
} else {
node[setAttribute](att, value);
}
break;
case "src":
if (o.type == "image") {
node.setAttributeNS(o.paper.xlink, "href", value);
}
break;
case "stroke-width":
node.style.strokeWidth = value;
// Need following line for Firefox
node[setAttribute](att, value);
if (attrs["stroke-dasharray"]) {
addDashes(o, attrs["stroke-dasharray"]);
}
break;
case "stroke-dasharray":
addDashes(o, value);
break;
case "translation":
var xy = (value + E)[split](separator);
xy[0] = +xy[0] || 0;
xy[1] = +xy[1] || 0;
if (rotxy) {
rotxy[1] += xy[0];
rotxy[2] += xy[1];
}
translate.call(o, xy[0], xy[1]);
break;
case "scale":
xy = (value + E)[split](separator);
o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, isNaN(toFloat(xy[2])) ? null : +xy[2], isNaN(toFloat(xy[3])) ? null : +xy[3]);
break;
case "fill":
var isURL = (value + E).match(ISURL);
if (isURL) {
el = $("pattern");
var ig = $("image");
el.id = "r" + (R._id++)[toString](36);
$(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1});
$(ig, {x: 0, y: 0});
ig.setAttributeNS(o.paper.xlink, "href", isURL[1]);
el[appendChild](ig);
var img = doc.createElement("img");
img.style.cssText = "position:absolute;left:-9999em;top-9999em";
img.onload = function () {
$(el, {width: this.offsetWidth, height: this.offsetHeight});
$(ig, {width: this.offsetWidth, height: this.offsetHeight});
doc.body.removeChild(this);
o.paper.safari();
};
doc.body[appendChild](img);
img.src = isURL[1];
o.paper.defs[appendChild](el);
node.style.fill = "url(#" + el.id + ")";
$(node, {fill: "url(#" + el.id + ")"});
o.pattern = el;
o.pattern && updatePosition(o);
break;
}
if (!R.getRGB(value).error) {
delete params.gradient;
delete attrs.gradient;
!R.is(attrs.opacity, "undefined") &&
R.is(params.opacity, "undefined") &&
$(node, {opacity: attrs.opacity});
!R.is(attrs["fill-opacity"], "undefined") &&
R.is(params["fill-opacity"], "undefined") &&
$(node, {"fill-opacity": attrs["fill-opacity"]});
} else if ((({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper)) {
attrs.gradient = value;
attrs.fill = "none";
break;
}
case "stroke":
node[setAttribute](att, R.getRGB(value).hex);
break;
case "gradient":
(({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper);
break;
case "opacity":
case "fill-opacity":
if (attrs.gradient) {
var gradient = doc.getElementById(node.getAttribute("fill")[rp](/^url\(#|\)$/g, E));
if (gradient) {
var stops = gradient.getElementsByTagName("stop");
stops[stops[length] - 1][setAttribute]("stop-opacity", value);
}
break;
}
default:
att == "font-size" && (value = toInt(value, 10) + "px");
var cssrule = att[rp](/(\-.)/g, function (w) {
return upperCase.call(w.substring(1));
});
node.style[cssrule] = value;
// Need following line for Firefox
node[setAttribute](att, value);
break;
}
}
}
tuneText(o, params);
if (rotxy) {
o.rotate(rotxy.join(S));
} else {
toFloat(rot) && o.rotate(rot, true);
}
};