RFE: Shape Intersection
Kay, Jim
Jim.Kay at snclavalin.com
Mon Jan 18 12:46:51 UTC 2021
Michael
I think I agree, I would not like to see JavaFX incorporated into JTS, for the reasons you mention.
But I would like to see JTS, or at least the structure and logic incorporated into JavaFX. This would then give the JavaFX world a useful set of tools that would greatly extend its rather limited existing functionality.
Jim
-----Original Message-----
From: openjfx-dev <openjfx-dev-retn at openjdk.java.net> On Behalf Of Michael Paus
Sent: 18 January 2021 12:11
To: openjfx-dev at openjdk.java.net
Subject: Re: RFE: Shape Intersection
I just mentioned JTS in a tweet myself
(https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_MichaelPaus_status_1351133904409915395&d=DwIDaQ&c=ukT25UmkSFgENae3bmQPWw&r=4CcGGNkvpQC43k2S_CRiSDUcCYYGpfGF1AetrfAv2Mw&m=biryV2m8HpSXo8rw1EUe0QmCrmnlN1upcYHdN8w-DpM&s=2wIFL0e2ON6mlE3HXVcSvuook7ipK-x_O62Br__7FxM&e= ) but I think it would be a mistake to integrate that into JavaFX for various reasons. The main problem is that Java never provided and used a graphics system independent geometry and math library. That's why I like JTS because it is not tied to any specific graphics system and therefore it is much easier for me to get my code running on different graphics systems. The latest being Jetbrains Compose and Skija.
Michael
Am 18.01.21 um 12:57 schrieb Kay, Jim:
> I have used the JTS library (https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_locationtech_jts&d=DwIDaQ&c=ukT25UmkSFgENae3bmQPWw&r=4CcGGNkvpQC43k2S_CRiSDUcCYYGpfGF1AetrfAv2Mw&m=biryV2m8HpSXo8rw1EUe0QmCrmnlN1upcYHdN8w-DpM&s=nvXIMl8MC1jFYb7rGgQYyrRZ5r7Y00q-1F2s51hGZR0&e= ) a lot over the years; this is my 'go to' library for all 2D geometry routines. It is very extensive and very well written by it’s main author Martin Davis. This library has entities such as Geometry, LineString, Polygon etc and shows how to do all geometric operations such as: intersect, intersection, difference, union, touches, overlaps etc.
> It would be great to incorporate this type of library into JavaFX. I know it would require a bit of a rewrite but I think it would be worth it!
> Jim Kay
>
> -----Original Message-----
> From: openjfx-dev <openjfx-dev-retn at openjdk.java.net> On Behalf Of Nir
> Lisker
> Sent: 18 January 2021 11:42
> To: Dirk Lemmermann <dlemmermann at gmail.com>
> Cc: OpenJFX <openjfx-dev at openjdk.java.net>
> Subject: Re: RFE: Shape Intersection
>
> If this is to be implemented in JavaFX, then it's better to do (not tested):
>
> 1. Extract the intersection computation from Shape.intersect
>
> private static Area intersectionArea(Shape shape1, Shape shape2) {
> Area result = shape1.getTransformedArea();
> return result.intersect(shape2.getTransformedArea());
> }
>
> 2. Shape.intersect becomes
>
> public static Shape Shape.intersects(Shape shape1, Shape shape2) {
> var intersectionArea = intersectionArea(Shape shape1, Shape shape2);
> return createFromGeomShape(intersectionArea);
> }
>
> 3. Add the new method Shape.intersects
>
> public static boolean Shape.intersects( Shape shape1, Shape shape2) {
> var intersectionArea = intersectionArea(Shape shape1, Shape shape2);
> return !intersectionArea.isEmpty(); }
>
> Regardless, I wonder why the geometry methods were implemented as static methods. Why not shape1.intersect(shape2)? I assume the new method should follow these, but on a clean slate I think I would have used the non-static approach.
>
> Another thing I would think about is whether it makes sense to just one method or is it a part of a more comprehensive shape geometry bundle. Is "intersects?" the only question we would like to ask?
>
> - Nir
>
> On Mon, Jan 18, 2021 at 12:12 PM Dirk Lemmermann
> <dlemmermann at gmail.com>
> wrote:
>
>> I just noticed that there is no „intuitive“ API to check whether two
>> shapes intersect with each other. The only way (I think) to do it is
>> as
>> follows:
>>
>> Shape.intersect((Shape) child, circle).getBoundsInLocal().getWidth()
>> != -1
>>
>> If this is indeed the case I would like to propose that a method
>> shall be added called „boolean Shape.intersects(Shape,Shape").
>>
>> See also:
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.co
>> m
>> _questions_15013913_checking-2Dcollision-2Dof-2Dshapes-2Dwith-2Djavaf
>> x
>> &d=DwIFaQ&c=ukT25UmkSFgENae3bmQPWw&r=4CcGGNkvpQC43k2S_CRiSDUcCYYGpfGF
>> 1
>> AetrfAv2Mw&m=p3Mxo9ouTmwb0rTqUVuKSgB0UwSHVVoF-Q9F0D_Kr_Y&s=DRGfselPcM
>> M
>> lUyRnLx7wTx4S243tMuSxGIBFhqNKKy8&e=
>> <
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.co
>> m
>> _questions_15013913_checking-2Dcollision-2Dof-2Dshapes-2Dwith-2Djavaf
>> x
>> &d=DwIFaQ&c=ukT25UmkSFgENae3bmQPWw&r=4CcGGNkvpQC43k2S_CRiSDUcCYYGpfGF
>> 1
>> AetrfAv2Mw&m=p3Mxo9ouTmwb0rTqUVuKSgB0UwSHVVoF-Q9F0D_Kr_Y&s=DRGfselPcM
>> M
>> lUyRnLx7wTx4S243tMuSxGIBFhqNKKy8&e=
>> Dirk
>>
>>
>>
More information about the openjfx-dev
mailing list