How do you edit a CubicCurve in JavaFX Scene Builder? - java

I'm experimenting with JavaFX Scene Builder 1.1.
I've just placed a CubicCurve onto the canvas, resulting in this:
I'm able to drag the nodes and handles around, but I'm unable to find any documentation on how to add/remove nodes, create additional handles, etc. I've experimented with right-clicking and clicking on various parts of the shape while holding down Shift, Ctrl, or Alt, but this seems to have no effect.
Is it possible to visually manipulate CubicCurves in Scene Builder, and if so, how?
Also, is there any documentation for Scene Builder? I can seem to find only a few miscellaneous videos and guides, but nothing comprehensive.

Update
The final release of SceneBuilder 2.0 dropped the cubic curve manipulation capabilities which were available (but somewhat broken) in the SceneBuilder 2.0 preview and discussed in this answer.
The related issue tracker request for this facility is:
DTL-6598 Content panel should provide editing gestures for CubicCurve, QuadCurve, Polygon...
I'm unable to find any documentation on how to add/remove nodes, create additional handles
I think what you are actually trying to do is create a Path with multiple cubic curves between points on the path. To do that you would add CubicCurveTo path elements to a path. You could create such fxml by hand and SceneBuilder would display it, but SceneBuilder 1.1 does not have the ability to visually create paths. I just tried SceneBuilder 2.0 early release and it did allow you to visually create paths, but it didn't seem to work quite right, so I think that particular functionality is still a work in progress.
The rest of this answer relates to plain CubicCurves in SceneBuilder 1.1 (as opposed to CubicCurveTos).
Is it possible to visually manipulate CubicCurves in Scene Builder? I'm able to drag the nodes and handles around.
That's how you edit the curve. You click on the little square handles and drag them around to modify the curve start/end and control points. You click on the curve itself and drag it around to move the whole curve. The Layout section of the inspector panel also has StartX, StartY, ControlX1, ControlY1, etc. text fields that you can manually edit data in.
If you want to add more control points, you add a new curve (by dragging it from the shape library into the scene), then (here is the yucky bit) manually line up the curve endpoints and control points to smoothly join the two curve end points.
Here is a sample with the control points of two different curves highlighted.
Advice on Using SceneBuilder
SceneBuilder isn't really a drawing tool, its more a component assembly and layout tool. It is a tool that is designed to work with other tools rather than a comprehensive design and development tool in it's own right. It doesn't try to be an IDE to write code in, as there are many good Java IDEs for that. Nor does it try to be a vector drawing tool as there are many good tools for that.
If you have a lot of drawing to do, IMO, you are best off using a specialized tool such as Inkscape to create the raw vector graphic data and then use another tool to convert that to FXML (which you can load directly into either SceneBuilder or a JavaFX application).
JavaFX 1.x used to provided with a tool where you could directly export SVG data from Inkscape and it would output a JavaFX 1.x FXD based scene definition. But JavaFX 2.x unfortunately doesn't yet have such tools.
A similar drawing conversion tool for JavaFX would be an FXG to FXML converter which takes an Adobe Illustrator file and produces an FXML file usable in SceneBuilder.
If your input data is 3D models, then InteractiveMesh supplies 3D model to FXML converters you can use to import your models into FXML (which can then be utilized in SceneBuilder 2.0).
is there any documentation for Scene Builder?
There is a User Guide.
There is some more information on Scene Builder in the Oracle JavaFX Tutorials.
And some videos on Scene Builder at javafx.com.
The Scene Builder team occasionally blog about SceneBuilder.
If you find any more feedback on SceneBuilder documentation, email the JavaFX documentation team at:
jfx-docs-feedback_ww#oracle.com

Related

Java FX Multiple Windows App

How are big applications (with lots of windows, lets say users administration, roles, payments, etc) designed. I'm a web developer and I'm used to develop different screens in different html files. I wanna know how to split windows generations in different files instead of having only one huge Application class.
Thanks in advance..
The question is a bit too broad to thoroughly answer, but I still think providing a partial answer here might be useful.
For an implementation of Banislav's strategy of hyperlinks controlling a swappable pane (which does not use FXML), see the related question: How to have menus in java desktop application.
For a small FXML based framework for switching panes see: Loading new fxml in the same scene with associated sample code. Note that sample is for small apps, for large apps a more rigorous framework would be preferred.
The next step up from the small framework listed above would be something like afterburner.fx, which is "a minimalistic (3 classes) JavaFX MVP framework". Even though small, afterburner.fx would probably suffice to be used as the core for a medium sized application. You can find a small sample application built using afterburner.fx named airhacks-control.
For something a bit more involved you can study the source of SceneBuilder and SceneBuilderKit. SceneBuilder is an open source design tool written in JavaFX. Understanding and adapting that code may be challenging for somebody coming from a web background as its implementation differs significantly from a traditional web application.
For very large applications, basing the application on a fully featured platform such as NetBeans RCP would probably be a preferred approach, though, as of this time, that is probably a large and difficult task to do well and likely requires mixing multiple frameworks rather than writing everything purely in JavaFX.
In JavaFX, you can use similar approach as in web development.
Use BorderPane as root pane.
Create main menu
You can use MenuBar with Menus and MenuItems. You can also use TreeView or ListView on like left side of screen. To position TreeView/ListView on left side you could use BorderPane and set it to left with setLeft.
Approach I prefer would be to use HyperLink control. Add multiple HyperLink's to VBox and again, set them on left side of BorderPane. Upon click, they will handle event which set's desired form on center of BorderPane.
I.e.

Adding Text to Screen with OpenGL

Currently, I am working on a OpenGL project and here is the screenshoot what I did
The question is, I want to add texts(degrees) to compass and want to do that with pure OpenGl methods. I found TextRenderer class however, couldn't manage to download it and use it. How to use TextRenderer class in my Java project? If there is any other way of adding text besides TextRenderer, would love to hear it.
My second and most important question is about merging swing/awt methods with OpenGL and using multiple objects. I wrote the program with only using one GL2 object and worked perfectly, is it sensible to use multiple openGL objects on the same frame? Furthermore, using swing methods and openGL methods together is a good idea?
I want to add texts(degrees) to compass and want to do that with pure OpenGl methods.
Unless you can live with not very pleasantly looking center stroke fonts, you have no choice but to use help from some other library or API.
Theoretically OpenGL can collaborate with OpenVG, but so far overall support for OpenVG is very poor, and OpenGL interoperability even worse. But say you had a proper working OpenVG – OpenGL interoperability working, then OpenVG was the way to go.
Practically you have to something different. A very fruitful approach is to use a font renderer library (like FreeType) together with some layout engine (like Pango) to produce an outline stroke list of the text to be rendered, which in turn can be either rendered directly using some extension by NVidia (http://www.opengl.org/registry/specs/NV/path_rendering.txt available only on the most recent NVidia GPUs) or manually tesselated into triangles, either on the CPU or by a combination of GPU Geometry and Tesselation Shaders. A huge drawback of drawing glyphs as tesselated filled outlines with OpenGL primitives is, that they will look very dirty (due to aliasing) if the used framebuffer doesn't have a multisample format (full screen antialiasing)
The next best thing is rendering the text to an image and copying that to the GPU and overlay that over the scene by rendering a textured quad. You should apply all text transformations already when rendering the quad, so that the font hinting system can make the proper adjustments on the transformed glyphs before rasterizing them.
Another approach is using texture mapped fonts. I implemented two TMF engines myself so far, but personally I advise against using this approach these days, as TMFs are resource hogs. A 200kiB TTF font can blow up to several megabytes of texture data. Maybe one day I or somebody else implements a TrueType or OpenType rendering engine with OpenCL, CUDA or Compute Shader, but until then rendering text with OpenGL is dirty business.
It boils down to
Crisp Look
Memory Efficient
Computationally Efficient
→ choose 2
After doing little research, I ve figured out how to install it and use it correctly.
Firstly, go to that web site and download suitable version of jogl for your os in case you dont have any library:
http://jogamp.org/deployment/autobuilds/master/jogl-b1011-2013-06-19_05-41-38/
Then, download that jar file and add it to your user library.
http://www.java2s.com/Code/Jar/j/Downloadjogl20jar.htm
That file contains the TextRenderer class.
If you dont know how to make one, use that link:
http://riccardotramma.com/2011/04/setup-eclipse-to-develop-opengl-glut-apps-in-java-cc-on-windows-mac/
Then, follow the instructions: http://download.java.net/media/jogl/jogl-2.x-docs/com/sun/opengl/util/awt/TextRenderer.html
It's very easy to use, I perfectly added numbers to my compass. However, not efficient as far as I can tell.

Is there a 3D scene graph implementation for libgdx?

I am using libgdx for some time now, and I have been asking myself for weeks now, if there is any suitable scenegraph implementation for libgdx. I do not mean the scene2d classes. I mean some graph function for 3d games. I searched a bit and did not find any...
Do you know any?
Currently there is no 3D scene. It might be added in the near future. However the new 3D api provides everything to load a 3D scene (see my loading a scene with libgdx tutorial). It is also possible to load scene physics if your like (see the bullet ImportTest). So practically for the actual rendering a Scene3D would only have to take care about frustum culling and multiple render passes (like shadow mapping). This can be as simple as an array of model instances or an entity system if you like.
Probably not, but it depends on what exactly you're looking for. See https://code.google.com/p/libgdx-users/wiki/scene3d
If you just want to optimize loading and share model resources when rendering, it looks like the new Libgdx 3D API (will be part of the 0.9.9 release, part of the current nightly builds) has some support for that: http://blog.xoppa.com/loading-a-scene-with-libgdx/#more-71
If you're just looking for something to organize your objects, there may be a generic Java scene graph library that you can adapt to Libgdx. Try 3D scene-graph library for Java?

drawing framework in java

I'm looking for a java 2d drawing framework. I'm building an application in which you load an image, and you should be able to draw on top of the image. But everything which is drawn should be selectable, modifiable, have properties etc. Actually Eclipse GEF (or Graphiti) looked really good, but that seems to be focused on drawing diagrams only. I would also need support for freehand drawing, bezier curves, lines etc.
Anybody know something like Eclipse GEF but which also supports freehand drawing and bezier curves? Or maybe it does and I didn't look quite good enough?
You can quickly write a simple editors yourself using JPanel and a custom paintComponent() method. But creating a useful editor with undo, etc. is a lot of work.
Try jfig which is shareware (free for 30 days, then $30). It has a framework with editor components plus a default editor which you can tweak.

Drawing a dynamic graph

I have a web application written with JavaServer Faces technology.
The application takes n inputs and provides an output.
I want the following functionality in my application.
I want to have sliders for each of my inputs.
I want the output to be depicted by a graph.
So whenever I change the input values via a slider I want the changed output value also displayed in the graph
So what will be the best way to do this?
You need two components. One is the slider component which comes with pretty much every component library.
Second one is the chart component I believe comes
with the PrimeFaces component library. All JavaServer Faces component libraries support Ajax so you could give it a shot.
May be you could use the Google Chart API.
In one of my projects we had a similar request.
As we where using richfaces we used those components but for the graph drawing we used jGraph, a small 'open source' library.
We chose jGraph as it was the only (not too expensive) library we found that allowed us to layout automatically a graph. (automatic layout is part of a licensed version, not free)
We used the richfaces mediaoutput component to call our backingbean which used jGraph to render a jpg of our graph.

Categories

Resources