@Deprecated private static Bounds cloneBounds(Bounds bounds) { double lrx = (bounds.getLowerRight().getX() != null ? bounds.getLowerRight().getX() : 0.0); double lry = (bounds.getLowerRight().getY() != null ? bounds.getLowerRight().getY() : 0.0); double ulx = (bounds.getUpperLeft().getX() != null ? bounds.getUpperLeft().getX() : 0.0); double uly = (bounds.getUpperLeft().getY() != null ? bounds.getUpperLeft().getY() : 0.0); return new Bounds(new Point(lrx, lry), new Point(ulx, uly)); }
@Deprecated private static void setBounds(Bounds bounds, double offsetX, double offsetY) { Point ul = bounds.getUpperLeft(); ul.setX(ul.getX() + offsetX); ul.setY(ul.getY() + offsetY); Point lr = bounds.getLowerRight(); lr.setX(lr.getX() + offsetX); lr.setY(lr.getY() + offsetY); }
@Override protected BasicShape getBasicShapeWithChildren_Bounds_Dockers() { BasicShape testShape = new BasicDiagram("test1"); Bounds b = new Bounds(new Point(100.26535, 200.14159), new Point(300.89793, 400.23846)); testShape.setBounds(b); List<Point> dockers1 = new ArrayList<Point>(); dockers1.add(new Point(b.getCenter())); testShape.setDockers(dockers1); BasicShape testChild = new BasicNode("subshape", "SubShape"); // relative to parent shape! Bounds b2 = new Bounds(new Point(10.1, 10.2), new Point(120.3, 120.4)); testChild.setBounds(b2); List<Point> dockers2 = new ArrayList<Point>(); dockers2.add(new Point(b2.getCenter())); testChild.setDockers(dockers2); BasicShape testChildChild = new BasicNode("subsubshape2", "SubShape"); Bounds b3 = new Bounds(new Point(20.56, 30.57), new Point(100.00, 99.999)); testChildChild.setBounds(b3); List<Point> dockers3 = new ArrayList<Point>(); dockers3.add(new Point(b3.getCenter())); testChildChild.setDockers(dockers3); testChild.addChildShape(testChildChild); testShape.addChildShape(testChild); return testShape; }
@Deprecated public static Bounds getAbsoluteBounds(GenericShape shape) { /* Handle invalid diagram and prevent from crashing the transformation */ if (shape.getBounds() == null) { Bounds bounds = new Bounds(new Point(0.0, 0.0), new Point(0.0, 0.0)); return bounds; } // clone bounds Bounds bounds = cloneBounds(shape.getBounds()); GenericShape parent = shape.getParent(); if (parent != null) { Bounds parentBounds = getAbsoluteBounds(parent); setBounds( bounds, parentBounds.getUpperLeft().getX().doubleValue(), parentBounds.getUpperLeft().getY().doubleValue()); } return bounds; }