Skip to content

Commit

Permalink
Removes a java.awt dependency
Browse files Browse the repository at this point in the history
There was a dependency to java.awt.Line2D in RectangleUtil.java. This commit replaces this with the project version Line2D.java to make it work on Android.
  • Loading branch information
a-mueller authored and davidmoten committed Feb 18, 2022
1 parent b033e6c commit c01ec97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public boolean intersectsLine(Line2D l) {
* otherwise.
* @since 1.2
*/
private static boolean linesIntersect(double x1, double y1, double x2, double y2, double x3,
double y3, double x4, double y4) {
static boolean linesIntersect(double x1, double y1, double x2, double y2, double x3,
double y3, double x4, double y4) {
return ((relativeCCW(x1, y1, x2, y2, x3, y3) * relativeCCW(x1, y1, x2, y2, x4, y4) <= 0)
&& (relativeCCW(x3, y3, x4, y4, x1, y1)
* relativeCCW(x3, y3, x4, y4, x2, y2) <= 0));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.davidmoten.rtree2.internal;

import java.awt.geom.Line2D;

public final class RectangleUtil {

private RectangleUtil() {
Expand Down Expand Up @@ -43,7 +41,7 @@ private RectangleUtil() {
public static boolean rectangleIntersectsLine(double rectX, double rectY, double rectWidth, double rectHeight,
double x1, double y1, double x2, double y2) {
return _rectangleIntersectsLine(rectX, rectY, rectWidth, rectHeight, x1, y1, x2, y2)
|| Line2D.Double.linesIntersect(rectX, rectY, rectX + rectWidth, rectY + rectHeight, x1, y1, x2, y2);
|| Line2D.linesIntersect(rectX, rectY, rectX + rectWidth, rectY + rectHeight, x1, y1, x2, y2);
}

private static boolean _rectangleIntersectsLine(double rectX, double rectY, double rectWidth,
Expand Down

0 comments on commit c01ec97

Please sign in to comment.