/** * Parses the description of this shape. */ protected void parseDescription() { // LATER: Preprocess nodes for faster painting fgNode = (Element) desc.getElementsByTagName("foreground").item(0); bgNode = (Element) desc.getElementsByTagName("background").item(0); w0 = getDouble(desc, "w", w0); h0 = getDouble(desc, "h", h0); // Possible values for aspect are: variable and fixed where // variable means fill the available space and fixed means // use w0 and h0 to compute the aspect. aspect = getString(desc, "aspect", "variable"); // Possible values for strokewidth are all numbers and "inherit" // where the inherit means take the value from the style (ie. the // user-defined stroke-width). Note that the strokewidth is scaled // by the minimum scaling that is used to draw the shape (sx, sy). strokewidth = getString(desc, "strokewidth", "1"); }
/** * Sets the description. */ public void setDescription(Element value) { desc = value; parseDescription(); }
drawElement(canvas, state, (Element) childNode, aspect); lastMoveX = x0 + getDouble(node, "x") * sx; lastMoveY = y0 + getDouble(node, "y") * sy; canvas.moveTo(lastMoveX, lastMoveY); lastMoveX = x0 + getDouble(node, "x") * sx; lastMoveY = y0 + getDouble(node, "y") * sy; canvas.lineTo(lastMoveX, lastMoveY); lastMoveX = x0 + getDouble(node, "x2") * sx; lastMoveY = y0 + getDouble(node, "y2") * sy; canvas.quadTo(x0 + getDouble(node, "x1") * sx, y0 + getDouble(node, "y1") * sy, lastMoveX, lastMoveY); lastMoveX = x0 + getDouble(node, "x3") * sx; lastMoveY = y0 + getDouble(node, "y3") * sy; canvas.curveTo(x0 + getDouble(node, "x1") * sx, y0 + getDouble(node, "y1") * sy, x0 + getDouble(node, "x2") * sx, y0 + getDouble(node, "y2") * sy, lastMoveX, lastMoveY); double r1 = getDouble(node, "rx") * sx; double r2 = getDouble(node, "ry") * sy; double angle = getDouble(node, "x-axis-rotation"); double largeArcFlag = getDouble(node, "large-arc-flag"); double sweepFlag = getDouble(node, "sweep-flag"); double x = x0 + getDouble(node, "x") * sx; double y = y0 + getDouble(node, "y") * sy;
mxGraphicsCanvas2D canvas = createCanvas(gc); mxRectangle aspect = computeAspect(state, state, direction); double minScale = Math.min(aspect.getWidth(), aspect.getHeight()); double sw = strokewidth.equals("inherit") ? mxUtils.getDouble( drawShadow(canvas, state, rotation, flipH, flipV, state, alpha, fillColor != null, aspect); drawShape(canvas, state, state, aspect, true); drawShape(canvas, state, state, aspect, false);
mxGraphicsCanvas2D canvas = createCanvas(gc); drawShadow(canvas, state, rotation, flipH, flipV, state, alpha, fillColor != null); drawShape(canvas, state, state, true); drawShape(canvas, state, state, false);
mxRectangle aspect = computeAspect(state, bounds, direction); double minScale = Math.min(aspect.getWidth(), aspect.getHeight()); double sw = strokewidth.equals("inherit") ? mxUtils.getDouble( drawElement(canvas, state, (Element) tmp, aspect);
/** * Returns the given attribute or 0. */ protected double getDouble(Element elt, String attribute) { return getDouble(elt, attribute, 0); }
if (drawShape(canvas, state, bounds, aspect, true))
/** * Draws this stencil inside the given bounds. */ public boolean drawShape(mxGraphicsCanvas2D canvas, mxCellState state, mxRectangle bounds, mxRectangle aspect, boolean background) { Element elt = (background) ? bgNode : fgNode; if (elt != null) { lastMoveX = 0; lastMoveY = 0; Node tmp = elt.getFirstChild(); while (tmp != null) { if (tmp.getNodeType() == Node.ELEMENT_NODE) { drawElement(canvas, state, (Element) tmp, aspect); } tmp = tmp.getNextSibling(); } return true; } return false; }
drawElement(canvas, state, (Element) childNode, aspect); lastMoveX = x0 + getDouble(node, "x") * sx; lastMoveY = y0 + getDouble(node, "y") * sy; canvas.moveTo(lastMoveX, lastMoveY); lastMoveX = x0 + getDouble(node, "x") * sx; lastMoveY = y0 + getDouble(node, "y") * sy; canvas.lineTo(lastMoveX, lastMoveY); lastMoveX = x0 + getDouble(node, "x2") * sx; lastMoveY = y0 + getDouble(node, "y2") * sy; canvas.quadTo(x0 + getDouble(node, "x1") * sx, y0 + getDouble(node, "y1") * sy, lastMoveX, lastMoveY); lastMoveX = x0 + getDouble(node, "x3") * sx; lastMoveY = y0 + getDouble(node, "y3") * sy; canvas.curveTo(x0 + getDouble(node, "x1") * sx, y0 + getDouble(node, "y1") * sy, x0 + getDouble(node, "x2") * sx, y0 + getDouble(node, "y2") * sy, lastMoveX, lastMoveY); double r1 = getDouble(node, "rx") * sx; double r2 = getDouble(node, "ry") * sy; double angle = getDouble(node, "x-axis-rotation"); double largeArcFlag = getDouble(node, "large-arc-flag"); double sweepFlag = getDouble(node, "sweep-flag"); double x = x0 + getDouble(node, "x") * sx; double y = y0 + getDouble(node, "y") * sy;
/** * Returns the given attribute or 0. */ protected double getDouble(Element elt, String attribute) { return getDouble(elt, attribute, 0); }
if (drawShape(canvas, state, bounds, true))
/** * Parses the description of this shape. */ protected void parseDescription() { // LATER: Preprocess nodes for faster painting fgNode = (Element) desc.getElementsByTagName("foreground").item(0); bgNode = (Element) desc.getElementsByTagName("background").item(0); w0 = getDouble(desc, "w", w0); h0 = getDouble(desc, "h", h0); // Possible values for aspect are: variable and fixed where // variable means fill the available space and fixed means // use w0 and h0 to compute the aspect. aspect = getString(desc, "aspect", "variable"); // Possible values for strokewidth are all numbers and "inherit" // where the inherit means take the value from the style (ie. the // user-defined stroke-width). Note that the strokewidth is scaled // by the minimum scaling that is used to draw the shape (sx, sy). strokewidth = getString(desc, "strokewidth", "1"); }
/** * Sets the description. */ public void setDescription(Element value) { desc = value; parseDescription(); }