@Override public BaseBounds deriveWithUnion(BaseBounds other) { if (other.getBoundsType() == BoundsType.RECTANGLE) { RectBounds rb = (RectBounds) other; unionWith(rb); } else if (other.getBoundsType() == BoundsType.BOX) { BoxBounds bb = new BoxBounds((BoxBounds) other); bb.unionWith(this); return bb; } else { throw new UnsupportedOperationException("Unknown BoundsType"); } return this; }
@Override public BaseBounds deriveWithNewBounds(BaseBounds other) { if (other.isEmpty()) return makeEmpty(); if (other.getBoundsType() == BoundsType.RECTANGLE) { RectBounds rb = (RectBounds) other; minX = rb.getMinX(); minY = rb.getMinY(); maxX = rb.getMaxX(); maxY = rb.getMaxY(); } else if (other.getBoundsType() == BoundsType.BOX) { return new BoxBounds((BoxBounds) other); } else { throw new UnsupportedOperationException("Unknown BoundsType"); } return this; }