rdlester / hermes

A game engine for rapid world prototyping in Processing/Java:
https://rdlester.github.io/hermes/
MIT License
48 stars 4 forks source link

Conflict using Rectangle objects when using Java Rectangle #5

Closed jorditost closed 9 years ago

jorditost commented 10 years ago

I'm starting a project with the library Hermes. In this project, I'm using the OpenCV library for Processing by Greg Borenstein, that uses Java Rectangle objects. For example, the bounding box of a detected contour returns a rectangle object:

Rectangle r = contour.getBoundingBox();

In my program, when including the Java Rectangle:

import java.awt.Rectangle;

I get this error:

The constructor Being(Rectangle) is undefined

If commenting the import, then I get an error while using the native rectangle object:

myRectangle.x cannot be resolved or is not a field

Is there a workaround to use both Hermes and Java rectangles?

rdlester commented 10 years ago

The most straightforward solution would be to not import one of the two classes directly and instead refer to it by its full name, eg. java.awt.Rectangle instead of the Java Rectangle or hermes.hshape.Rectangle instead of the Hermes Rectangle. It's more to type, but it will compile.

Alternatively, we do already prefix some class names with H; perhaps we could prefix our shape names similarly, like HRectangle, etc.? That would break backwards compatibility, however, something I'm not particularly keen on doing.

jorditost commented 10 years ago

I think prefixing your Rectangle class as HRectangle would be the better practice in this case. On one hand, Rectangle is a native class, and on the other, if any lib uses the native Rectangle, that won't compile.

Thanks for your support!

El 12/07/2014, a las 1:34, Ryan Lester notifications@github.com escribió:

The most straightforward solution would be to not import one of the two classes directly and instead refer to it by its full name, eg. java.awt.Rectangle instead of the Java Rectangle or hermes.hshape.Rectangle instead of the Hermes Rectangle. It's more to type, but it will compile.

Alternatively, we do already prefix some class names with H; perhaps we could prefix our shape names similarly, like HRectangle, etc.? That would break backwards compatibility, however, something I'm not particularly keen on doing.

— Reply to this email directly or view it on GitHub.

rdlester commented 10 years ago

Okay, the API update has been pushed. Try out the new download and let me know if everything works out.

Excited to see people using Hermes! Send me an email with project details once it's finished and I'll link it from the Hermes page.