Drawing a dynamic graph - java

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.

Related

How to implement repsonsive design in Eclipse RAP?

The Eclipse RAP (Remote Application Platform) project provides a way to write web applications using SWT.
Due to single sourcing, the written code can also be used in desktop SWT/RCP applications.
Since it is a framework for web applications I was wondering if it supports responsive design?
If so, a simple example would be great. It does not need to be RCP compatible.
I didn't find a lot on the internet, has there been any efforts towards supporting responsive design?
Due to the fact that RAP shields you from web technology, native CSS and other web-techniques won't work.
To summarize the comments, you will likely have to implement one or more custom layouts that adapt to the available space and show/hide/resize the managed controls accordingly.
You may also want to use custom controls or manipulate existing controls to adapt to the available space. in some places. For example, hide texts on toolbar buttons when space becomes rare.
RAP theming can also be leveraged to a certain extent in order to change the appearance and space of certain controls.
Further reading:
EclipseCon 2014 talk: https://www.eclipsecon.org/na2014/sites/default/files/slides/Responsive%20Applications%20Tutorial%20-%20EclipseCon%202014.pdf
A blog post with code examples about responsive UIs with SWT: http://www.codeaffine.com/2014/02/24/responsive-uis-with-eclipse-and-swt/
RAP Theming: https://eclipse.org/rap/developers-guide/devguide.php?topic=theming.html
Understanding SWT Layouts: https://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html (ignore the deprecation warning, the core concepts haven't changed since)
You can make it responsive with the use of Passe-Partout created by Tabris. This works in RAP and should be compatible with RCP.
They have made a custom layout : FluidGridLayout.
It's best you use it through the factory class com.eclipsesource.tabris.passepartout.PassePartout.
Source can be found on github:
https://github.com/eclipsesource/tabris/tree/master/com.eclipsesource.tabris.passepartout
Add this plugin to your dependency or just copy the source in your project.
See the blogpost at eclipsesource for basic info:
https://eclipsesource.com/products/tabris/eclipse-rap-documentation/responsive-design/
The great thing about it, is that you program it all in java.
Only issue that I now experience is with scrolling.
In my case I have a workbench and my editorpart needs a scrolledcomposite, only set to V_SCROLL. I've added two resize listeners to set the new minsize of the scrolledcomposite.
One resize listener on the display when the entire browser resizes.
A second resize listener for the parent when only the editorpart resizes. (fe when a view is resized or the editorpart is maximized)

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.

How do you edit a CubicCurve in JavaFX Scene Builder?

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

JFreeChart on Web

First, I am a final year student. We are creating a KPI and we saw JFree chart can be used to display charts. Now we have a problem about deciding whether the software is web based or not (Major votes came for a Desktop application. Only 1 is there for web based solution. ).
However, this what we have to do;
Display data using Charts
Colors of the areas of the chart MUST change during run time (eg: if < 90% attendance 'RED', if > 90% attendance 'GREEN')
When the user clicks on the particular area of the chart, display all the relevant data as a 'Tool Tip Text Box' or something. When mouse over, display some summary.
There will be 6 KPI's in the dashboard.
KPI's are belong to 2 categories, HR and PROJECTS.
Now my question is, what is the easy way of doing it? Web Based or Desktop? Will JFreeChart support these functions when it is in web? Please help!
First the long answer, then the short one. If you are using JFreeChart on the web, you have two options:
Display the charts in an applet, which will allow you to do basically all the stuff that JFreeChart supports, including the ones you mentioned above.
Use JFreeChart on the server side to generate images that will be served by the server. In this case, #2 will be difficult because you will have to refresh pages, #3 will be very hard or even almost impossible
Given the above, the short answer is: I suggest you build a desktop application, it will be easier to deal with charting.
From my experience is better use a Javascript Library to generate a gantt chart and later integrate with any framework Java Web. You could use some libraries for example:
Twproject Gantt
JQuery Gantt
JSGantt Improved
JQuery.Gantt
Finally There is an option with cost: Daylot Gantt
If you want to use JFreechart It can be used to render an image and post it on the page, you also could use some form of jquery based chart ploting. Either way you would have to take control of refreshing the data. In standalone app it might be somewhat easier.
you can use these JFreeCharts the requirements you have specified.
JFree charts will display the charts as images. But there are some methods which will display the tooltips and the summary, You have to implement those methods based on your requirements.

Tkzinc like library in java

I need to develop some canvas window with graphical entities.
I want to know is there library similar to Tkzinc in java?
http://www.tkzinc.org/tkzinc/index.php
I've used Eclipse GEF before, but that is built on top of an SWT canvas, not Swing. I'm not sure if that's compatible with what you need.
It allows you to build an object-oriented graphical model which responds to events and can be moved around, etc.
The underlying drawing framework is Draw2D which might be useful on its own if you don't want a full MVC framework for editing a model.

Categories

Resources