Search code examples
javaswingopenglcanvaslwjgl

LWJGL 3 as a method of drawing charts


A friend asked me to develop a chart setup for a machine he is building. He has some very specific requirements about how the charts need to be displayed, and no existing api will satisfy those requirements. So I need to make a custom chart renderer, one option was to just take any java 2D canvas or to use OpenGL, which would be LWJGL. I used LWJGL 2 in the past, and i know it can be a canvas element, while LWJGL 3 can't. So the only solution I can have here is either have it broken up in frames like Gimp is, or have the gui as part of the LWJGL 3 frame. Those solutions are not appreciated for what needs to be done. Is there a way I could wrap the LWJGL 3 frame as a internal frame, or anything to make it stick to a java swing or java fx gui?

I use Java because I know it best, I don't have so much experiences in other languages.


Solution

  • Look here is an interval chart:

    enter image description here

    I cant fit all the code on here unforunately, I will post it on github. But anything you can imagine can be done, I am not going to go through every way jfreechart can be customized but with some digging you can find the answers.

    You can find the code on https://github.com/derrick3192/sliderchartdemo.git

    If you want to add zoom buttons and what not I suggest you look at the:

    plot.getDomainAxis().setRange

    Or

    plot.getRangeAxis().setRange

    But I don't mean this offensivily but you can't come on stackoverflow with low rep (even though I don't have much rep) and claim all the charting libraries are not good enough, and you have to make your own, you will get downvoted for that so tread lightly.