public static Bounds of(double ulx, double uly, double lrx, double lry) { return new Bounds(ulx, uly, lrx, lry); }
public static Bounds of(double ulx, double uly, double lrx, double lry) { return new Bounds(ulx, uly, lrx, lry); }
public Diagram addNode(String activityId, double ulx, double uly, double lrx, double lry) { ensureCanvas(); canvas.addNode(new Node() .elementId(activityId) .bounds(new Bounds(ulx, uly, lrx, lry))); return this; }
public Diagram addNode(String activityId, double ulx, double uly, double lrx, double lry) { ensureCanvas(); canvas.addNode(new Node() .elementId(activityId) .bounds(new Bounds(ulx, uly, lrx, lry))); return this; }
@Test public void testCreateEmptyBounds() { Bounds bounds = new Bounds(); assertNull(bounds.upperLeft); assertNull(bounds.lowerRight); }
double width = Double.valueOf(currentXml.removeAttribute(OMG_DC_URI, "width")); double height = Double.valueOf(currentXml.removeAttribute(OMG_DC_URI, "height")); node.bounds(new Bounds(new Point(x, y), width, height));
@Test public void testEquals() { double ulx = 11.0; double uly = 12.0; double lrx = 22.0; double lry = 23.0; Bounds b1 = Bounds.of(ulx, uly, lrx, lry); Bounds b2 = Bounds.of(ulx, uly, lrx, lry); assertEquals(b1, b2); assertEquals(b1.hashCode(), b2.hashCode()); b1 = new Bounds().upperLeft(Point.of(ulx, uly)); b2 = new Bounds().upperLeft(Point.of(ulx, uly)); assertEquals(b1, b2); b1 = new Bounds().lowerRight(Point.of(ulx, uly)); b2 = new Bounds().lowerRight(Point.of(ulx, uly)); assertEquals(b1, b2); b1 = new Bounds().upperLeft(Point.of(ulx, uly)); b2 = new Bounds().upperLeft(Point.of(lrx, lry)); assertNotEquals(b1, b2); }
@Test public void testSetLowerRight() { Bounds bounds = new Bounds(); bounds.lowerRight(Point.of(1.0, 2.0)); assertEquals(1.0, bounds.lowerRight.x, 0.0); assertEquals(2.0, bounds.lowerRight.y, 0.0); assertNull(bounds.upperLeft); }
@Test public void testCreateBoundsWithPoints() { Point ul = Point.of(10.0, 11.0); Point lr = Point.of(22.0, 23.0); Bounds bounds = new Bounds(ul, lr); assertEquals(ul, bounds.upperLeft); assertEquals(lr, bounds.lowerRight); assertNotEquals(ul, bounds.lowerRight); }
@Test public void testSetUpperLeft() { Bounds bounds = new Bounds(); bounds.upperLeft(Point.of(1.0, 2.0)); assertEquals(1.0, bounds.upperLeft.x, 0.0); assertEquals(2.0, bounds.upperLeft.y, 0.0); assertNull(bounds.lowerRight); }
@Test public void testCreateBoundsWithCoordinates() { double ulx = 11.0; double uly = 12.0; double lrx = 22.0; double lry = 23.0; Bounds bounds = new Bounds(ulx, uly, lrx, lry); assertNotNull(bounds.upperLeft); assertEquals(ulx, bounds.upperLeft.x, 0.0); assertEquals(uly, bounds.upperLeft.y, 0.0); assertNotNull(bounds.lowerRight); assertEquals(lrx, bounds.lowerRight.x, 0.0); assertEquals(lry, bounds.lowerRight.y, 0.0); }
@Test public void testEquals() { List<Node> children = new ArrayList<>(); children.add(new Node().id("n1")); children.add(new Node().id("n2")); String actId = "a1"; Bounds bounds = new Bounds(Point.of(1, 2), Point.of(3, 4)); Node node1 = new Node() .elementId(actId) .bounds(bounds) .children(children); Node node2 = new Node() .elementId(actId) .bounds(bounds) .children(children); assertEquals(node1, node2); assertEquals(node1.hashCode(), node2.hashCode()); }
@Test public void testEmptyDiagram() throws Exception { ExecutableWorkflow workflow = new ExecutableWorkflow().id(new WorkflowId(getWorkflowIdInternal())); workflow.setDiagram(new Diagram().canvas(new Node().addNode(new Node().bounds(new Bounds(0, 0, 10, 10))))); workflow = serializeWorkflow(workflow); // No execptions due to empty workflow and diagram. } }
@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()); } }