/** * A Node is considered valid if its Bounds are valid * and all the contained children are valid. */ public boolean isValid() { if (bounds == null || !bounds.isValid()) { return false; } if (children != null) { for (Node node : children) { if (!node.isValid()) { return false; } } } return true; }
/** * A Node is considered valid if its Bounds are valid * and all the contained children are valid. */ public boolean isValid() { if (bounds == null || !bounds.isValid()) { return false; } if (children != null) { for (Node node : children) { if (!node.isValid()) { return false; } } } return true; }
@Test public void testIsValid() { Bounds b = Bounds.of(10.0, 10.0, 13.0, 14.0); assertTrue(b.isValid()); b = Bounds.of(0.0, 0.0, 0.0, 0.0); assertFalse(b.isValid()); b = new Bounds(); assertFalse(b.isValid()); b = Bounds.of(0.0, 10.0, 0.0, 14.0); assertFalse(b.isValid()); b = Bounds.of(10.0, 0.0, 13.0, 0.0); assertFalse(b.isValid()); } }
private void writeBpmnDiagramBounds(Bounds bounds) { if (bounds != null && bounds.isValid()) { startElement(xml.createElement(OMG_DC_URI, "Bounds")); xml.addAttribute(OMG_DC_URI, "height", bounds.getHeight()); xml.addAttribute(OMG_DC_URI, "width", bounds.getWidth()); xml.addAttribute(OMG_DC_URI, "x", bounds.upperLeft.x-xOffset); xml.addAttribute(OMG_DC_URI, "y", bounds.upperLeft.y-yOffset); endElement(); } }