in zookeeper-contrib/zookeeper-contrib-loggraph/src/main/resources/webapp/org/apache/zookeeper/graph/resources/raphael.js [1729:1912]
setFillAndStroke = function (o, params) {
o.attrs = o.attrs || {};
var node = o.node,
a = o.attrs,
s = node.style,
xy,
res = o;
for (var par in params) if (params[has](par)) {
a[par] = params[par];
}
params.href && (node.href = params.href);
params.title && (node.title = params.title);
params.target && (node.target = params.target);
params.cursor && (s.cursor = params.cursor);
"blur" in params && o.blur(params.blur);
if (params.path && o.type == "path") {
a.path = params.path;
node.path = path2vml(a.path);
}
if (params.rotation != null) {
o.rotate(params.rotation, true);
}
if (params.translation) {
xy = (params.translation + E)[split](separator);
translate.call(o, xy[0], xy[1]);
if (o._.rt.cx != null) {
o._.rt.cx +=+ xy[0];
o._.rt.cy +=+ xy[1];
o.setBox(o.attrs, xy[0], xy[1]);
}
}
if (params.scale) {
xy = (params.scale + E)[split](separator);
o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, +xy[2] || null, +xy[3] || null);
}
if ("clip-rect" in params) {
var rect = (params["clip-rect"] + E)[split](separator);
if (rect[length] == 4) {
rect[2] = +rect[2] + (+rect[0]);
rect[3] = +rect[3] + (+rect[1]);
var div = node.clipRect || doc.createElement("div"),
dstyle = div.style,
group = node.parentNode;
dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect);
if (!node.clipRect) {
dstyle.position = "absolute";
dstyle.top = 0;
dstyle.left = 0;
dstyle.width = o.paper.width + "px";
dstyle.height = o.paper.height + "px";
group.parentNode.insertBefore(div, group);
div[appendChild](group);
node.clipRect = div;
}
}
if (!params["clip-rect"]) {
node.clipRect && (node.clipRect.style.clip = E);
}
}
if (o.type == "image" && params.src) {
node.src = params.src;
}
if (o.type == "image" && params.opacity) {
node.filterOpacity = " progid:DXImageTransform.Microsoft.Alpha(opacity=" + (params.opacity * 100) + ")";
s.filter = (node.filterMatrix || E) + (node.filterOpacity || E);
}
params.font && (s.font = params.font);
params["font-family"] && (s.fontFamily = '"' + params["font-family"][split](",")[0][rp](/^['"]+|['"]+$/g, E) + '"'); //'
params["font-size"] && (s.fontSize = params["font-size"]);
params["font-weight"] && (s.fontWeight = params["font-weight"]);
params["font-style"] && (s.fontStyle = params["font-style"]);
if (params.opacity != null ||
params["stroke-width"] != null ||
params.fill != null ||
params.stroke != null ||
params["stroke-width"] != null ||
params["stroke-opacity"] != null ||
params["fill-opacity"] != null ||
params["stroke-dasharray"] != null ||
params["stroke-miterlimit"] != null ||
params["stroke-linejoin"] != null ||
params["stroke-linecap"] != null) {
node = o.shape || node;
var fill = (node.getElementsByTagName("fill") && node.getElementsByTagName("fill")[0]),
newfill = false;
!fill && (newfill = fill = createNode("fill"));
if ("fill-opacity" in params || "opacity" in params) {
var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1);
opacity < 0 && (opacity = 0);
opacity > 1 && (opacity = 1);
fill.opacity = opacity;
}
params.fill && (fill.on = true);
if (fill.on == null || params.fill == "none") {
fill.on = false;
}
if (fill.on && params.fill) {
var isURL = params.fill.match(ISURL);
if (isURL) {
fill.src = isURL[1];
fill.type = "tile";
} else {
fill.color = R.getRGB(params.fill).hex;
fill.src = E;
fill.type = "solid";
if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || (params.fill + E).charAt() != "r") && addGradientFill(res, params.fill)) {
a.fill = "none";
a.gradient = params.fill;
}
}
}
newfill && node[appendChild](fill);
var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),
newstroke = false;
!stroke && (newstroke = stroke = createNode("stroke"));
if ((params.stroke && params.stroke != "none") ||
params["stroke-width"] ||
params["stroke-opacity"] != null ||
params["stroke-dasharray"] ||
params["stroke-miterlimit"] ||
params["stroke-linejoin"] ||
params["stroke-linecap"]) {
stroke.on = true;
}
(params.stroke == "none" || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false);
stroke.on && params.stroke && (stroke.color = R.getRGB(params.stroke).hex);
opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1);
var width = (toFloat(params["stroke-width"]) || 1) * .75;
opacity < 0 && (opacity = 0);
opacity > 1 && (opacity = 1);
params["stroke-width"] == null && (width = a["stroke-width"]);
params["stroke-width"] && (stroke.weight = width);
width && width < 1 && (opacity *= width) && (stroke.weight = 1);
stroke.opacity = opacity;
params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter");
stroke.miterlimit = params["stroke-miterlimit"] || 8;
params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round");
if (params["stroke-dasharray"]) {
var dasharray = {
"-": "shortdash",
".": "shortdot",
"-.": "shortdashdot",
"-..": "shortdashdotdot",
". ": "dot",
"- ": "dash",
"--": "longdash",
"- .": "dashdot",
"--.": "longdashdot",
"--..": "longdashdotdot"
};
stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E;
}
newstroke && node[appendChild](stroke);
}
if (res.type == "text") {
s = res.paper.span.style;
a.font && (s.font = a.font);
a["font-family"] && (s.fontFamily = a["font-family"]);
a["font-size"] && (s.fontSize = a["font-size"]);
a["font-weight"] && (s.fontWeight = a["font-weight"]);
a["font-style"] && (s.fontStyle = a["font-style"]);
res.node.string && (res.paper.span.innerHTML = (res.node.string + E)[rp](/</g, "<")[rp](/&/g, "&")[rp](/\n/g, "<br>"));
res.W = a.w = res.paper.span.offsetWidth;
res.H = a.h = res.paper.span.offsetHeight;
res.X = a.x;
res.Y = a.y + round(res.H / 2);
// text-anchor emulationm
switch (a["text-anchor"]) {
case "start":
res.node.style["v-text-align"] = "left";
res.bbx = round(res.W / 2);
break;
case "end":
res.node.style["v-text-align"] = "right";
res.bbx = -round(res.W / 2);
break;
default:
res.node.style["v-text-align"] = "center";
break;
}
}
};