List of usage examples for org.w3c.dom Element setAttributeNS
public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException;
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ActivityImpl.java
/** * Get the arrow flows/paths from the coordinates given by getArrows() * * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @param startX x-coordinate of the start point * @param startY y-coordinate of the start point * @param endX x-coordinate of the end point * @param endY y-coordinate of the end point * @param id previous activity id + current activity id * @return An element which contains the arrow flows/paths of the activity */// www .j a va 2 s . c om protected Element getArrowDefinition(SVGDocument doc, int startX, int startY, int endX, int endY, String id) { Element path = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "path"); /*Arrows are created using <path> : An element in svg used to create smooth, flowing lines using relatively few control points. A path element is defined by attribute: d. This attribute contains a series of commands for path data : M = move to L = line to Arrow flows will be generated according to the coordinates given */ if (startX == endX || startY == endY) { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + endX + "," + endY); } else { if (layoutManager.isVerticalLayout()) { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + startX + "," + ((startY + 2 * endY) / 3) + " L " + endX + "," + ((startY + 2 * endY) / 3) + " L " + endX + "," + endY); } else { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + ((startX + 1 * endX) / 2) + "," + startY + " L " + ((startX + 1 * endX) / 2) + "," + endY + " L " + endX + "," + endY); } } //Set the id of the path path.setAttributeNS(null, "id", id); //Add styles to the arrows path.setAttributeNS(null, "style", getArrowStyle()); return path; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ActivityImpl.java
/** * Get the arrow flows/paths from the coordinates given by getArrows() * * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @param startX x-coordinate of the start point * @param startY y-coordinate of the start point * @param midX x-coordinate of the mid point * @param midY y-coordinate of the mid point * @param endX x-coordinate of the end point * @param endY y-coordinate of the end point * @param id previous activity id + current activity id * @return An element which contains the arrow flows/paths of the activity *///from w w w. j a v a 2s.com protected Element getArrowDefinition(SVGDocument doc, int startX, int startY, int midX, int midY, int endX, int endY, String id) { Element path = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "path"); path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + midX + "," + midY + "L " + endX + "," + endY); //Set the id of the path path.setAttributeNS(null, "id", id); //Add styles to the arrows path.setAttributeNS(null, "style", getArrowStyle()); return path; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ActivityImpl.java
/** * Defines the box i.e . the scope of a composite activity represented as a box * * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @param boxXLeft x-coordinate of the box * @param boxYTop y-coordinate of the box * @param boxWidth width of the box/*from w w w.ja v a 2 s . c o m*/ * @param boxHeight height of the box * @param id id of the box/activity * @return */ protected Element getBoxDefinition(SVGDocument doc, int boxXLeft, int boxYTop, int boxWidth, int boxHeight, String id) { Element group = null; group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g"); //Set the id of the box group.setAttributeNS(null, "id", "Layer-" + id); //Check whether Sequence boxes can be shown/ is true if (layoutManager.isShowSequenceBoxes()) { //Rectangle/Box to hold the subActivities inside the Sequence Element rect = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "rect"); //Attributes of the box is defined rect.setAttributeNS(null, "width", String.valueOf(boxWidth)); rect.setAttributeNS(null, "height", String.valueOf(boxHeight)); rect.setAttributeNS(null, "x", String.valueOf(boxXLeft)); rect.setAttributeNS(null, "y", String.valueOf(boxYTop)); rect.setAttributeNS(null, "id", "Rect" + id); rect.setAttributeNS(null, "rx", "10"); rect.setAttributeNS(null, "ry", "10"); rect.setAttributeNS(null, "style", boxStyle); //Embed the box to the container group.appendChild(rect); } return group; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ElseIfImpl.java
/** * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @return Element(represents an element in a XML/HTML document) which contains the components of the ElseIf * composite activity// www . ja v a2s . c o m */ public Element getSVGString(SVGDocument doc) { Element group1 = null; group1 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g"); //Get the id of the activity group1.setAttributeNS(null, "id", getLayerId()); //Add opacity to the icons if (isAddOpacity()) { group1.setAttributeNS(null, "style", "opacity:" + getOpacity()); } //Get the icons of the activities i.e. create/define the activity icons group1.appendChild(getImageDefinition(doc)); //Get sub activities group1.appendChild(getSubActivitiesSVGString(doc)); //Get the arrow flows of the subActivities inside the ElseIf composite activity group1.appendChild(getArrows(doc)); return group1; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ElseIfImpl.java
/** * Get the arrow flows/paths from the coordinates given by getArrows() * * @param doc/* w w w.j a va 2 s.c om*/ * @param startX x-coordinate of the start point * @param startY y-coordinate of the start point * @param endX x-coordinate of the end point * @param endY y-coordinate of the end point * @param id previous activity id + current activity id * @return An element which contains the arrow flows/paths of the ElseIf activity and its subActivities */ protected Element getArrowDefinition(SVGDocument doc, int startX, int startY, int endX, int endY, String id) { Element path = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "path"); /*Arrows are created using <path> : An element in svg used to create smooth, flowing lines using relatively few control points. A path element is defined by attribute: d. This attribute contains a series of commands for path data : M = move to L = line to Arrow flows will be generated according to the coordinates given */ if (startX == endX || startY == endY) { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + endX + "," + endY); } else { if (layoutManager.isVerticalLayout()) { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + startX + "," + ((startY + 2 * endY) / 3) + " L " + endX + "," + ((startY + 2 * endY) / 3) + " L " + endX + "," + endY); } else { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + ((startX + 1 * endX) / 2) + "," + startY + " L " + ((startX + 1 * endX) / 2) + "," + endY + " L " + endX + "," + endY); //use constants for these propotions } } //Set the id of the path path.setAttributeNS(null, "id", id); //Add styles to the arrows path.setAttributeNS(null, "style", getArrowStyle()); return path; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ElseImpl.java
/** * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @return Element(represents an element in a XML/HTML document) which contains the components of the Else * composite activity//w ww . j a va 2 s . c om */ public Element getSVGString(SVGDocument doc) { Element group1 = null; group1 = doc.createElementNS(SVG_NAMESPACE, "g"); //Get the id of the activity group1.setAttributeNS(null, "id", getLayerId()); //Get the icons of the activities i.e. create/define the activity icons group1.appendChild(getImageDefinition(doc)); //Get sub activities group1.appendChild(getSubActivitiesSVGString(doc)); //Get the arrow flows of the subActivities inside the Else composite activity if (getArrows(doc) != null) { group1.appendChild(getArrows(doc)); } return group1; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ElseImpl.java
/** * Get the arrow flows/paths from the coordinates given by getArrows() * * @param doc//from ww w .jav a 2 s .co m * @param startX x-coordinate of the start point * @param startY y-coordinate of the start point * @param endX x-coordinate of the end point * @param endY y-coordinate of the end point * @param id previous activity id + current activity id * @return An element which contains the arrow flows/paths of the Else activity and its subActivities */ protected Element getArrowDefinition(SVGDocument doc, int startX, int startY, int endX, int endY, String id) { //here we have to find whether Element path = doc.createElementNS(SVG_NAMESPACE, "path"); /*Arrows are created using <path> : An element in svg used to create smooth, flowing lines using relatively few control points. A path element is defined by attribute: d. This attribute contains a series of commands for path data : M = move to L = line to Arrow flows will be generated according to the coordinates given */ if (startX == endX || startY == endY) { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + endX + "," + endY); } else { if (layoutManager.isVerticalLayout()) { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + startX + "," + ((startY + CONSTANT_VALUE_TWO * endY) / CONSTANT_VALUE_THREE) + " L " + endX + "," + ((startY + CONSTANT_VALUE_TWO * endY) / CONSTANT_VALUE_THREE) + " L " + endX + "," + endY); } else { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + ((startX + CONSTANT_VALUE_ONE * endX) / CONSTANT_VALUE_TWO) + "," + startY + " L " + ((startX + CONSTANT_VALUE_ONE * endX) / CONSTANT_VALUE_TWO) + "," + endY + " L " + endX + "," + endY); //use constants for these // propotions } } //Set the id of the path path.setAttributeNS(null, "id", id); //Add styles to the arrows path.setAttributeNS(null, "style", getArrowStyle()); return path; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.IfImpl.java
/** * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @return Element(represents an element in a XML/HTML document) which contains the components of the If * composite activity//from w ww. j ava2 s.c o m */ public Element getSVGString(SVGDocument doc) { Element group1 = null; group1 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g"); //Get the id of the activity group1.setAttributeNS(null, "id", getLayerId()); //Checks for the icon opacity if (isAddOpacity()) { group1.setAttributeNS(null, "style", "opacity:" + getOpacity()); } //Get the If composite activity box/scope where the subActivities are placed group1.appendChild(getBoxDefinition(doc)); //Get the icon definition of the activity group1.appendChild(getImageDefinition(doc)); //Get the start icon/image text of the activity group1.appendChild(getStartImageText(doc)); // Get Sub Activities group1.appendChild(getSubActivitiesSVGString(doc)); //Get the end icon of the activity group1.appendChild(getEndImageDefinition(doc)); //Get the arrow flows of the subActivities inside the Sequence composite activity group1.appendChild(getArrows(doc)); return group1; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.IfImpl.java
/** * Get the arrow flows/paths from the coordinates given by getArrows() * * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @param startX x-coordinate of the start point * @param startY y-coordinate of the start point * @param endX x-coordinate of the end point * @param endY y-coordinate of the end point * @param id previous activity id + current activity id * @return An element which contains the arrow flows/paths of the If activity and its subActivities *///from ww w .ja v a 2s .c om protected Element getArrowDefinition(SVGDocument doc, int startX, int startY, int endX, int endY, String id) { Element path = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "path"); /*Arrows are created using <path> : An element in svg used to create smooth, flowing lines using relatively few control points. A path element is defined by attribute: d. This attribute contains a series of commands for path data : M = move to L = line to Arrow flows will be generated according to the coordinates given */ if (startX == endX || startY == endY) { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + endX + "," + endY); } else { if (layoutManager.isVerticalLayout()) { int middleX, middleY; if ((startX < endX)) { middleY = startY; middleX = endX; } else { middleY = endY; middleX = startX; } path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + middleX + "," + middleY + " L " + endX + "," + endY); } else { path.setAttributeNS(null, "d", "M " + startX + "," + startY + " L " + ((startX + 1 * endX) / 2) + "," + startY + " L " + ((startX + 1 * endX) / 2) + "," + endY + " L " + endX + "," + endY); //use constants for these propotions } } //Set the id of the path path.setAttributeNS(null, "id", id); //Add styles to the arrows path.setAttributeNS(null, "style", getArrowStyle()); return path; }
From source file:org.wso2.carbon.bpel.ui.bpel2svg.impl.ProcessImpl.java
/** * All Elements are described inline//www . j a v a 2 s.co m * * @param doc SVG document which defines the components including shapes, gradients etc. of the activity * @return Element(represents an element in a XML) which contains the components of the Process */ protected Element getDefs(SVGDocument doc) { /* SVG <defs> element is used to embed definitions that can be reused inside an SVG image. For instance, you can group SVG shapes together and reuse them as a single shape. */ Element defs = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "defs"); defs.setAttributeNS(null, "id", "defs4"); /*SVG markers are used to mark the start, mid and end of a line or path refx= Position where the marker connects with the vertex (default 0) refy= Position where the marker connects with the vertex (default 0) orient='auto' or an angle to always show the marker at. 'auto' will compute an angle that makes the x-axis a tangent of the vertex (default 0) */ Element marker1 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "marker"); //Defining the attributes marker1.setAttributeNS(null, "refX", "0"); marker1.setAttributeNS(null, "refY", "0"); marker1.setAttributeNS(null, "orient", "auto"); marker1.setAttributeNS(null, "id", "Arrow1Lend"); marker1.setAttributeNS(null, "style", "overflow:visible"); /*Creating a SVG path and defining its attributes d=a set of commands which define the path pathLength=If present, the path will be scaled so that the computed path length of the points equals this value transform=a list of transformations */ Element path1 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "path"); //Defining the attributes path1.setAttributeNS(null, "d", "M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"); path1.setAttributeNS(null, "transform", "matrix(-0.8,0,0,-0.8,-10,0)"); path1.setAttributeNS(null, "id", "path3166"); path1.setAttributeNS(null, "style", "fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"); //Creating a SVG marker element and defining the attributes Element marker2 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "marker"); marker2.setAttributeNS(null, "refX", "0"); marker2.setAttributeNS(null, "refY", "0"); marker2.setAttributeNS(null, "orient", "auto"); marker2.setAttributeNS(null, "id", "Arrow1Mend"); marker2.setAttributeNS(null, "style", "overflow:visible"); //Creating a SVG path element and defining the attributes Element path2 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "path"); path2.setAttributeNS(null, "d", "M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"); path2.setAttributeNS(null, "transform", "matrix(-0.8,0,0,-0.8,-10,0)"); path2.setAttributeNS(null, "id", "path3193"); path2.setAttributeNS(null, "style", "fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"); //Creating a SVG marker element and defining the attributes Element linkMarker = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "marker"); linkMarker.setAttributeNS(null, "refX", "0"); linkMarker.setAttributeNS(null, "refY", "0"); linkMarker.setAttributeNS(null, "orient", "auto"); linkMarker.setAttributeNS(null, "id", "LinkArrow"); linkMarker.setAttributeNS(null, "style", "overflow:visible"); //Creating a SVG path element and defining the attributes Element linkPath = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "path"); linkPath.setAttributeNS(null, "d", "M -11.5,0 L -7,-7.5 L -12.5,0 L -7,7.5 L -11.5,0 z"); linkPath.setAttributeNS(null, "transform", "matrix(-0.8,0,0,-0.8,-10,0)"); linkPath.setAttributeNS(null, "id", "linkPath"); linkPath.setAttributeNS(null, "style", "fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"); /* Defines a linear gradient. Linear gradients fill the object by using a vector, and can be defined as horizontal, vertical or angular gradients x1- x start point of the gradient vector x2- x end point of the gradient vector y1- y start point of the gradient vector y2- y end point of the gradient vector */ Element linearGradient = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "linearGradient"); linearGradient.setAttributeNS(null, "id", "orange_red"); linearGradient.setAttributeNS(null, "x1", "0%"); linearGradient.setAttributeNS(null, "y1", "0%"); linearGradient.setAttributeNS(null, "x2", "0%"); linearGradient.setAttributeNS(null, "y2", "100%"); /* The stops for a gradient offset= The offset for this stop (0 to 1/0% to 100%) --> Required. */ Element stop1 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "stop"); stop1.setAttributeNS(null, "offset", "0%"); stop1.setAttributeNS(null, "style", "stop-color:rgb(255,255,255);stop-opacity:1"); Element stop2 = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "stop"); stop2.setAttributeNS(null, "offset", "100%"); stop2.setAttributeNS(null, "style", "stop-color:rgb(0,0,255);stop-opacity:1"); //Embeds the SVG components defined into the <def> container for referenced elements marker1.appendChild(path1); marker2.appendChild(path2); linkMarker.appendChild(linkPath); defs.appendChild(marker1); defs.appendChild(marker2); defs.appendChild(linkMarker); linearGradient.appendChild(stop1); linearGradient.appendChild(stop2); defs.appendChild(linearGradient); return defs; }