Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecation from getDistanceOrthogonal #21 #673

Merged
merged 2 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void testGetDistancePoint() {
assertEquals(5, new Point(-1, -2).getDistance(new Point(-5, 1)), 0);
}

@SuppressWarnings({ "static-method", "removal" })
@SuppressWarnings("static-method")
@Test
public void testGetDistanceOrthogonal() {
assertEquals(53, new Point(10, 20).getDistanceOrthogonal(new Point(51, 32)));
Expand Down
4 changes: 0 additions & 4 deletions org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ public int getDistanceSquared(Point p) {
*
* @param p The reference Point
* @return the orthogonal distance
* @noreference This method is not intended to be referenced by clients.
* @deprecated May not be guaranteed by precision subclasses and should thus not
* be used any more.
*/
@Deprecated(since = "3.7", forRemoval = true)
public int getDistanceOrthogonal(Point p) {
return Math.abs(y - p.y()) + Math.abs(x - p.x());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class PrecisionPoint extends Point {
* Constructor for PrecisionPoint.
*/
public PrecisionPoint() {
super();
ptziegler marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -102,6 +101,34 @@ public Dimension getDifference(Point p) {
return new PrecisionDimension(this.preciseX() - p.preciseX(), this.preciseY() - p.preciseY());
}

/**
* provide a precision version of
* org.eclipse.draw2d.geometry.Point#getDistanceOrthogonal(org.eclipse.draw2d.geometry.Point)
*
* @since 3.19
*/
@Override
public int getDistanceOrthogonal(Point p) {
return (int) (Math.abs(this.preciseX() - p.preciseX()) + Math.abs(this.preciseY() - p.preciseY()));
}
ptziegler marked this conversation as resolved.
Show resolved Hide resolved

/**
* provide a precision version of
* org.eclipse.draw2d.geometry.Point#getDistanceSquared(org.eclipse.draw2d.geometry.Point)
*
* @since 3.19
*/
@Override
public int getDistanceSquared(Point p) {
double deltaX = p.preciseX() - this.preciseX();
double deltaY = p.preciseX() - this.preciseX();
long result = (long) (deltaX * deltaX + deltaY * deltaY);
if (result > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
return (int) result;
}

/**
* Returns a precise copy of this.
*
Expand Down
Loading