We’d like to change a Swing GUI of one of our projects to a Nifty GUI.
I’ve checked the documentation and almost everything seems ok for the change.
The only problem is that we have a drawable canvas (so using mouse events and updating the drawn bufferedImage), but we haven’t found anything about making a custom drawable nifty component.
I think the mouse events can be processed correctly, but I don’t know if we can draw an image on a Nifty component to show this canvas.
Has anyone tried that yet or do you have any tip?
Thanks as always,
Pardon me in case I don’t understand your question correctly.
Can’t you just display the image into which you are painting using nifty ? (ex: using the image control)
That’s what I’m asking, as I haven’t seen any information about it
Basically I don’t know if I can:
Show a white image (bufferedImage) in a Nifty Panel
Click on it and get the pixel coords relative to the image
Change the bufferedImage
Update the rendered canvas in the Nifty Panel
I know it’s possible but I can’t tell you how as I wouldn’t use nifty for that
Maybe with that ?
Then you might be able to do something with your image element.
Someone else should be able to provide you a more precise answer
I found this discussion:
And he says “Current Nifty, 1.3.x or 1.4.x don’t support custom drawing to a screen.”
If this is always true, then we wouldn’t be able to work on this canvas and this is why I asked.
Let’s wait for anyone who can answer to this
I’m having sort-of-same problem here:
I’m wondering how I get a own drawn image, or an edited image into nifty on-the fly changed outside simpleInitApp().
My problem is, that this works only in simpleInitApp() (imageMap is my edited image):
NiftyImage nimg = new NiftyImage(nifty.getRenderEngine(), new RenderImageJme(new Texture2D(imageMap)));
Element niftyElement = nifty.getCurrentScreen().findElementByName("monmapimage");
// swap old with new image
Theoretical you can create a texture2D and exchange this new image for an old in nifty (see code in my question).
Sadly my solution only works in simpleInitApp() so far.
Let’s keep fingers pressed, some nifty-folks have a more generally working answer.