GUI Library under development

Hi, im making a GUI library(It’s in the veeeery early stages) for general purposes(My own 3D game in JME3 and the games i do on my job(JApplets browser games)) and i want it to be able to comunicate to JME3.



As i can guess, all i need to do is to make a node draw a image under “ortogonalNode”(actualy i don’t remember the correct name, it was something like that, it’s a field from SimpleApplication), so i can make a GUI.



If that is correct then i still need help with two issues:



First:

Connecting my GUI library to JME3. My library will have a class named Connection that will manage some things, right now only two of them have been made, a class that get BufferedImages to be able to draw the components from the library, and a GraphicsConnection that will make the communication betwen JME3 and the GUI library. Seens that i can’t post anexes so i will post the whole class later on this thread.



The communication idea:

GraphicsConnection have two fields:

  • Graphics2D dbg: Every component is drawn here, you need to be able to render it, either by creating it from a image and drawning the image afterwards, or with something else.
  • Container scene: The current scene to be drawn, you add a couple of components(or other containers) inside this container and the GraphicsConnection will draw them during the draw method.



    It also contains 3 important methods:
  • void Update(long diftime): Update the state of all components inside the current scene with the given time diference betwen this call and the last call of this method(you suply the value, in case you need it to go fast foward for some reason), things like buttons will need this method to be able to animate the “you clicked on me” annimation.
  • Graphics2D draw(Graphics2D): This method will either draw on it’s own Graphics2D or the one you just supplied, it will always return the Graphics2D it drew on. This method needs to be called often like Update.
  • void setScene(Container): Replaces the current scene with a new one, like a transaction betwen item list scene and main menu scene or multiplayer scene or whatever.



    With those methods it should be easy to communicate and work with JME3 i supose, im posting them because im not sure and im not very experienced with JME3.





    But the biggest problem of all is the ResourceConnection. This one should be able to communicate betwen AssetManager from JME3 and generate a method with given syntax:



    public BufferedImage(imagename): This method is called by a lot of components that require a image, like a Pane that will have a cool boarder or something.



    Is this ResourceConnection possible to do? how to? Is there a huge problem to the idea that make it not viable? what could be changed to make it possible? (Btw it migth not be worth to make to work with JME3, but it is to work on my job, so i want to be able to use this library for both projects).

    Im quite sure it got quite complicated and confused so ask if you need more information to help me…



    Thx for the help in advance ;D

For the ResourceConnection, can’t you just use ImageIO to load the image from a URL?

Looks like a serious endeavor; wish you the best of luck!



That said, could you please consider explaining why you chose to make a new GUI library from scratch, instead of using one of the existing options? Nifty-GUI being the main solution in question of course (and I’m sure Jens “void” would greatly appreciate your feedback), but with a little bit of work much like what you’re doing here, libraries such as GBUI, TWL and even Feng-GUI would be viable options.



We want jME3 to cater to as many development models as possible right out of the box, so this type of use-case feedback can be really useful, both to us and closely related projects (e.g. Nifty-GUI).

Momoko Fan: Won’t all things used on the JME3 project suposed to be loaded using the AssetManager thingy? I was worried about it…



Erlend Sogge: well, mainly because i need to make those graphics library anyways for my job(Java applet games), so if i can use them for my game(a JME3 game) the better, so im making it in a way that can be highly configurable and at the same time be able to use it on both projects. Basicaly i don’t want the library used on my job to be wasted(as this one im completaly sure it will have everything i will ever need in a GUI, since im making it and therefore know exactly how it works).

Guedez said:
Momoko Fan: Won't all things used on the JME3 project suposed to be loaded using the AssetManager thingy? I was worried about it...

I don't think it matters in this case since you're using it for drawing on a Graphics2D, which is completely unrelated to jME3.
If you load it using the AssetManager, you'll get it in jME3's preferred image format which is not a BufferedImage.

this get things a lot easier :open_mouth:

thx for the help!