Can JavaFX do CAD?
zonski at gmail.com
Tue Jul 23 16:21:19 PDT 2013
More specifically I would like to know the official recommended best practices for implementing a CAD style app in JFX.
- How best to represent large numbers of complex shapes efficiently, and when to add shapes to the scene (add all and let jfx clip, or manually work out what should be showing, etc)
- How best to handle font scaling and image scaling when rendered in a zoomed in/out viewport
- How best to do panning and zooming with dynamic level of detail
- How best to do the top level display in terms of panes vs regions vs canvas, vs whatever, how to manage overlays and layers (sharing same coordinate space, etc)
- How best to do picking, mouse overs, dragging across the 'display'
- How best to do infinite or dynamic bounds so you can add and move shapes and the scrolling adjusts accordingly.
A JFX diagramming app would make a very powerful demo app in my mind.
On 24/07/2013, at 1:47 AM, Chris Gay <chris.gay5000 at gmail.com> wrote:
> Hello all.
> Please could someone advise if it is even feasible for me to consider re-factoring the following Swing application, so that it becomes a JavaFX one. From trying to read about JavaFX, I get the feeling that Oracle never intended Java FX for the purpose I need.
> I have a large Java Swing desktop CAD application which makes heavy use of the Java 2D API, and concurrency. It is a Menu Bar driven application, with a Toolbar for Tools, and a few buttons, but 99% of the user activity concerns selecting and manipulating vector graphical objects in a traditional manner using one Tool at a time (think Inkscape or LibreOffice Drawing apps). The application has multiple drawings open at the same time (but only one is visible), and each Drawing contains it's own Drawing and Processing threads (in addition to sharing the Main and Event Threads), which keeps the Event Thread lively. Each Drawing contains an ArrayList, acting as a Display List of all graphical objects, and each graphical object can be a tree structure. In many cases I use simple iteration instead of Iterators, simply for speed, and to avoid garbage. The graphical objects are lightweight, in that they do not carry references to events and handlers. All they carry is their basic geometric data and properties, a bounding box which they can lend as Read Only, and a boolean flag to indicate selection, which means there can be millions of the objects, with a minimum memory footprint. To support them, there are many hundreds of methods, which the tools interact with. There can be multiple Drawing Windows active on a single drawing, where each Window is backed up by an offscreen image, which handles the zoom and sliding buffer behaviour for fast scrolling, to allow rapid bit-blt's to the actual window. Lastly, the user manipulates the Drawing (Display List), using one of many Tools, where the active Tool receives events from the event queue, and then manipulates selected and/or unselected graphical objects, by using XOR Mode graphics onto the offscreen buffer, generally using callbacks.
> The system is fast and very responsive on large data sets, but what I do not know is whether JavaFX will help me make a better implementation, or whether it will fight me all the way. With JavaFX claiming hardware acceleration, I do not understand whether it depends on transferring the very large data sets into graphics hardware to render, and what happens if the hardware cannot cope. So far, I have found little in the way of discussions that help me get a mental picture of how JavaFX is intended to work. Should I stick with Swing?
More information about the openjfx-dev