List of usage examples for org.jdom2 Element getAttributeValue
public String getAttributeValue(final String attname)
This returns the attribute value for the attribute with the given name and within no namespace, null if there is no such attribute, and the empty string if the attribute value is empty.
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts the YAWL net layout bounds/*w w w . ja v a 2s . co m*/ * * <pre> * <net id=""> * <bounds x="" y="" w="" h="" /> * <frame x="" y="" w="" h="" /> * <viewport x="" y="0" w="" h="" /> * <vertex> .. </vertex> * ... * </net> * </pre> * * @param yawlNet * @return */ private NetLayout convertNetLayout(final Element yawlNet) { String yawlId = yawlNet.getAttributeValue("id"); Element yawlBounds = yawlNet.getChild("bounds", yawlNamespace); Bounds bounds = convertToOryxBounds(fixNetBoundsElement(yawlBounds), 0.0, 0.0); NetLayout netLayout = new NetLayout(bounds); context.putNetLayout(yawlId, netLayout); return netLayout; }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * If the viewport inside YAWL Editor is adjusted, then YAWL stores negative values in "bounds" element. For Oryx this has to be adjusted, simply * by setting each negative value to zero! * //from ww w .j av a 2 s .c o m * @param boundsElement * original "bounds" element of YAWL Net * @return Element containing only positive dimensions */ private Element fixNetBoundsElement(final Element boundsElement) { Element clonedElement = boundsElement.clone(); clonedElement.setAttribute("x", fixBoundsAttribute(boundsElement.getAttributeValue("x"))); clonedElement.setAttribute("y", fixBoundsAttribute(boundsElement.getAttributeValue("y"))); clonedElement.setAttribute("h", fixBoundsAttribute(boundsElement.getAttributeValue("h"))); clonedElement.setAttribute("w", fixBoundsAttribute(boundsElement.getAttributeValue("w"))); return clonedElement; }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts a YAWL Vertex, which may be a condition or a task. * /*from ww w . j a va 2 s. c o m*/ * <pre> * <vertex id="XY"> * <attributes> * </attributes> * </vertex> * </pre> * * @param netLayout * @param yawlVertex */ private void convertVertexLayout(final NetLayout netLayout, final Element yawlVertex) { if (isCondition(yawlVertex.getAttributeValue("id"))) { convertConditionLayout(netLayout, null, yawlVertex); } else { convertTaskLayout(netLayout, null, yawlVertex); } }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts a YAWL Container, which may be a condition or a task. * // w w w. j ava2s. co m * <pre> * <container id="XY"> * <vertex> * </vertex> * <decorator type="XYJoin"> * </decorator> * <decorator type="XYSplit"> * </decorator> * </container> * </pre> * * @param netLayout * @param yawlContainer */ private void convertContainerLayout(final NetLayout netLayout, final Element yawlContainer) { Element yawlVertex = yawlContainer.getChild("vertex", yawlNamespace); if (yawlVertex != null) { if (isCondition(yawlContainer.getAttributeValue("id"))) { convertConditionLayout(netLayout, yawlContainer, yawlVertex); } else { convertTaskLayout(netLayout, yawlContainer, yawlVertex); } } else { // Should not happen. TODO: Log warning } }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts the layout of a YAWL condition from a vertex or container element * /*from w ww . j av a 2s . c om*/ * @param netLayout * @param yawlContainer * may be NULL if the condition has no label * @param yawlVertex * containing the bounds of the condition */ private void convertConditionLayout(final NetLayout netLayout, final Element yawlContainer, final Element yawlVertex) { Element yawlVertexBounds = yawlVertex.getChild("attributes", yawlNamespace).getChild("bounds", yawlNamespace); NetElementLayout layoutInformation = new NetElementLayout(true); layoutInformation.setBounds(convertToOryxBounds(yawlVertexBounds, 0.0, 0.0)); if (yawlContainer != null) { netLayout.putVertexLayout(yawlContainer.getAttributeValue("id"), layoutInformation); } else { netLayout.putVertexLayout(yawlVertex.getAttributeValue("id"), layoutInformation); } }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts the layout of a YAWL task from container element * /*from ww w . java 2 s . c om*/ * @param netLayout * @param yawlContainer * may be NULL if the task has no labels and decorators * @param yawlVertex * bounds of the vertex element inside the container */ private void convertTaskLayout(final NetLayout netLayout, final Element yawlContainer, final Element yawlVertex) { Element yawlVertexBounds = yawlVertex.getChild("attributes", yawlNamespace).getChild("bounds", yawlNamespace); NetElementLayout layoutInformation = new NetElementLayout(false); // Task has to be adjusted to Oryx coordinates, // as the JOIN/SPLIT decorator is part of the BasicShape in Oryx layoutInformation.setBounds(convertToOryxBounds(yawlVertexBounds, 24.0, 24.0)); layoutInformation.setIconPath(convertIconPath(yawlVertex)); if (yawlContainer != null) { convertDecorator(yawlContainer, layoutInformation); netLayout.putVertexLayout(yawlContainer.getAttributeValue("id"), layoutInformation); } else { netLayout.putVertexLayout(yawlVertex.getAttributeValue("id"), layoutInformation); } }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts the all decorators of a YAWL task. There may be two decorators, each with alignment TOP, LEFT, RIGHT, BOTTOM. * // w ww .j ava 2 s .c o m * @param yawlContainer * the container element of the YAWL task * @param layoutInformation * already converted layout of the YAWL task */ private void convertDecorator(final Element yawlContainer, final NetElementLayout layoutInformation) { @SuppressWarnings("rawtypes") List yawlDecoratorList = yawlContainer.getChildren("decorator", yawlNamespace); if (yawlDecoratorList != null) { for (Object o : yawlDecoratorList) { Element yawlDecorator = (Element) o; NetElementLayout.DecoratorType decoratorType = convertDecoratorType(yawlDecorator); if (yawlDecorator.getAttributeValue("type").contains("join")) { layoutInformation.setJoinDecorator(decoratorType); } if (yawlDecorator.getAttributeValue("type").contains("split")) { layoutInformation.setSplitDecorator(decoratorType); } } } }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * @param netLayout// w w w. j a va 2 s. c om * @param yawlFlow */ private void convertFlowLayout(final NetLayout netLayout, final Element yawlFlow) { FlowLayout layoutInformation = new FlowLayout(); // Flow apparently doesn't need correct Bounds, but it // needs NOT NULL Bounds layoutInformation.setBounds(DEFAULT_FLOW_BOUNDS); // Flow does need corrects dockers (ports in YAWL) layoutInformation.setDockers(convertFlowDockers(netLayout, yawlFlow)); layoutInformation.setLabel(convertFlowLabel(yawlFlow)); layoutInformation.setLineStyle(convertFlowLineStyle(yawlFlow)); netLayout.putFlowLayout(yawlFlow.getAttributeValue("source") + "|" + yawlFlow.getAttributeValue("target"), layoutInformation); }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * @param netLayout//from w w w. j av a 2s .com * @param yawlFlow * @return */ private ArrayList<Point> convertFlowDockers(final NetLayout netLayout, final Element yawlFlow) { Element flowPorts = yawlFlow.getChild("ports", yawlNamespace); Integer inPort = Integer.valueOf(flowPorts.getAttributeValue("in")); Integer outPort = Integer.valueOf(flowPorts.getAttributeValue("out")); Point inDocker; Point outDocker; String targetId = yawlFlow.getAttributeValue("target"); String sourceId = yawlFlow.getAttributeValue("source"); // Source may have a SPLIT decorator or may be a condition if (netLayout.getVertexLayout(sourceId).isCondition()) { inDocker = YAWLMapping.CONDITION_PORT_MAP.get(inPort); } else { inDocker = convertTaskDocker(netLayout.getVertexLayout(sourceId).getSplitDecorator(), inPort); } // Target may have a JOIN decorator or may be a condition if (netLayout.getVertexLayout(targetId).isCondition()) { outDocker = YAWLMapping.CONDITION_PORT_MAP.get(outPort); } else { outDocker = convertTaskDocker(netLayout.getVertexLayout(targetId).getJoinDecorator(), outPort); } // Fallback in case the values in XML are wrong if (outDocker == null) { outDocker = YAWLMapping.TASK_PORT_MAP.get(14); } if (inDocker == null) { inDocker = YAWLMapping.TASK_PORT_MAP.get(14); } ArrayList<Point> dockers = new ArrayList<Point>(); // Important to add as first Docker with source BasicShape coordinates dockers.add(inDocker); // Add bends from YAWL with coordinates of Diagram Element pointElement = yawlFlow.getChild("attributes", yawlNamespace).getChild("points", yawlNamespace); // points may be omitted in YAWL if (pointElement != null) { @SuppressWarnings("rawtypes") List pointList = pointElement.getChildren(); if (pointList.size() > 2) { // Skip the first and last element, // as those will be added according to the port information for (int i = 1; i < pointList.size() - 1; i++) { if (pointList.get(i) instanceof Element) { Element point = (Element) pointList.get(i); String x = point.getAttributeValue("x"); String y = point.getAttributeValue("y"); dockers.add(new Point(parseDouble(x), parseDouble(y))); } } } } // Important to add as last Docker with target BasicShape coordinates dockers.add(outDocker); return dockers; }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts the x,y,w,h attributes to an Oryx Bounds object. * /*from w ww. j a va2 s .com*/ * @param yawlBounds * @param heightAdjusment * enlarge the height, without affecting the position * @param widthAdjustment * enlarge the width, without affecting the position * @return */ private Bounds convertToOryxBounds(final Element yawlBounds, final double heightAdjusment, final double widthAdjustment) { double x = parseDouble(yawlBounds.getAttributeValue("x")) - (widthAdjustment / 2); double y = parseDouble(yawlBounds.getAttributeValue("y")) - (heightAdjusment / 2); double w = parseDouble(yawlBounds.getAttributeValue("w")) + widthAdjustment; double h = parseDouble(yawlBounds.getAttributeValue("h")) + heightAdjusment; return new Bounds(new Point(x + w, y + h), new Point(x, y)); }