@Test public void testWithMargin() { IVector2 p1 = Vector2.fromXY(-1, -1); IVector2 p2 = Vector2.fromXY(1, 1); IRectangle baseRect = Rectangle.fromPoints(p1, p2); IRectangle marginRect = baseRect.withMargin(2); assertThat(marginRect.getCorners()).containsExactlyInAnyOrder( Vector2.fromXY(-3, 3), Vector2.fromXY(-3, -3), Vector2.fromXY(3, 3), Vector2.fromXY(3, -3)); marginRect = baseRect.withMargin(-0.5); assertThat(marginRect.getCorners()).containsExactlyInAnyOrder( Vector2.fromXY(-0.5, 0.5), Vector2.fromXY(-0.5, -0.5), Vector2.fromXY(0.5, 0.5), Vector2.fromXY(0.5, -0.5)); baseRect = Rectangle.fromCenter(Vector2.fromXY(1, 1), 40, 40); marginRect = baseRect.withMargin(2); assertThat(marginRect.getCorners()).containsExactlyInAnyOrder( Vector2.fromXY(-21, -21), Vector2.fromXY(-21, 23), Vector2.fromXY(23, 23), Vector2.fromXY(23, -21)); baseRect = Rectangle.fromCenter(Vector2.fromXY(1, 1), 44, 44); marginRect = baseRect.withMargin(-1); assertThat(marginRect.getCorners()).containsExactlyInAnyOrder( Vector2.fromXY(-20, 22), Vector2.fromXY(-20, -20), Vector2.fromXY(22, 22), Vector2.fromXY(22, -20)); }
@Override public IRectangle withMargin(final double margin) { return withMarginXy(margin, margin); }
Rectangle extends ARectangle { @Override public IRectangle withMargin(final double margin) { return withMarginXy(margin, margin); } }
Rectangle extends ARectangle { @Override public IRectangle withMargin(final double margin) { return withMarginXy(margin, margin); } @SuppressWarnings("unused") protected  Rectangle(); private  Rectangle(final IVector2 center, final double xExtent, final double yExtent); protected  Rectangle(final IRectangle rec); }
Rectangle extends ARectangle { @Override public IRectangle withMargin(final double margin) { return withMarginXy(margin, margin); } @SuppressWarnings("unused") protected  Rectangle(); private  Rectangle(final IVector2 center, final double xExtent, final double yExtent); protected  Rectangle(final IRectangle rec); static Rectangle aroundLine(final IVector2 p0, final IVector2 p1, final double radius); static Rectangle fromLineSegment(final ILineSegment lineSegment); static Rectangle fromPoints(final IVector2 p1, final IVector2 p2); static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent); @Override IRectangle withMargin(final double margin); @Override IRectangle withMarginXy(double xMargin, double yMargin); @Override IRectangle mirror(); @Override double yExtent(); @Override double xExtent(); @Override IVector2 center(); @Override final boolean equals(final Object o); @Override final int hashCode(); @Override String toString(); }
Rectangle extends ARectangle { @Override public IRectangle withMargin(final double margin) { return withMarginXy(margin, margin); } @SuppressWarnings("unused") protected  Rectangle(); private  Rectangle(final IVector2 center, final double xExtent, final double yExtent); protected  Rectangle(final IRectangle rec); static Rectangle aroundLine(final IVector2 p0, final IVector2 p1, final double radius); static Rectangle fromLineSegment(final ILineSegment lineSegment); static Rectangle fromPoints(final IVector2 p1, final IVector2 p2); static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent); @Override IRectangle withMargin(final double margin); @Override IRectangle withMarginXy(double xMargin, double yMargin); @Override IRectangle mirror(); @Override double yExtent(); @Override double xExtent(); @Override IVector2 center(); @Override final boolean equals(final Object o); @Override final int hashCode(); @Override String toString();  }