Visualizing multiple layouts in jung - java

I am creating a RadialTreeLayout of a graph using JUNG. Now I want to see one more RadialTreeLayout of another graph (with same type of vertices and edges) as a part of the main layout.
The problem is not of uniting the two graphs (as explained here) but actually of visualizing a similar layout in the main window.
Few ways I thought of doing that, but not sure if they are feasible or not. e.g. to create one such node which actually is the layout (and can be seen with zooming in) or when one clicks on that node, another layout appears in a separate window.
Or are there existing ways to do that in JUNG already. Any help/suggestions would be appreciated.

Check out the demos. I don't remember offhand which one, but at least one demonstrates visualization of multiple graphs.

Related

Advices to improve performance in javafx

I'm working on an app where I need to draw a lot of data. There are different functions that can be used to work with the data. The main functions share two views, that right now I draw every time I start the functions. They differ in the middle part where the data is displayed different. Right now my main goal is to improve the performance of the app. When I switch from view A to B runs smoother than the other way around. My idea is to store all the parts (from all views) in a list so when I jump back to the view I can reuse them instead of building them again. Is this a good idea? Are there some general performance advices when building an app with javafx?
In GUI desktop development, there is a technique named "double buffering", which is useful to make fast screen flips:
It consists on having two separated and different panels that occupy the whole application viewport and that must be permanently updated, but just one of them must be visible at the same time. Changing from one to another is as fast as to hide one of them and to show the other one.

How to achieve absolute positioning in Javafx (FXML)

Ok lets just assume I wanted to have the following layout:
<GridPane>
<Button></Button>
<Button></Button>
<GridPane/>
<HBox>
<Label></Label>
<HBox/>
Now, in HTML I would simply apply position: absolute via css and one of the two containers would detache from the normal document flow allowing it to float around without pushing its siblings aside. I am trying to achieve something similar but im on it for hours already.
According to the Oracle documentation this can be achieved with either StackPane, which I dont want because I want the other container unaffected) or I could use a raw Pane node which somehow acts crazy because well, its a base class. The documentation about the pane also says:
This class may be used directly in cases where absolute positioning of children
and well of children doesnt sound good...as in my case it has to be the direct container.
So my question is: how can I achieve absolute positioning without hacking around with too much math?
Could localToScene() be what I want?
Transforms a bounds from the local coordinate space of this Node into the coordinate space of its scene.
My impression is that you are still thinking in HTML-terms and not JavaFX-Terms. For example in JavaFX there is no "normal document flow". Everything has to be put into some layout container and this container determines how things are layed out and there is nothing wrong with using a Pane directly if you have to. Although I am not sure what your actual use-case is, I think you might want to have a look at the AnchorPane.

Need help setting up GUI featuring grid and clickable items

For my Comp Sci assignment, I have to make a world that has Village objects connected via Roads in a graph data structure.Gnomes, each running their own thread traverse this world from one village to another using the shortest path. This whole thing needs to have a GUI, however.
Basically I need to have a grid with the villages on the intersections. Something like this ( without the numbers):
(source: kwiznet.com)
The villages have to be interconnected with roads. If it is not too difficult, roads should be deletable if they are not the only road connecting the village to the rest of the graph. This would be done via clicking.
There must also be an option to add villages by clicking on the graph, and select current villages, deleting them.
Basically:
Graph data structure is translated to GUI grid
Roads and Villages can be selected
Selected items can be deleted
Could you please just point me to what I need to research as I am new to GUIs? Such as the best layout manager, in what way to handle action events, how to draw a grid, etc. I just need a brief outline.
This is a HUGE question, although that's not really your fault. Here goes:
Read through the Java Swing Tutorial.
Learn a bit about MVC. Link1 Link2
Understand that Swing is not thread safe.
Then:
The best layout manager for your graph is likely the grid layout.
Probably you should add a JButton to each node so you can just click on it. JButtons can be made to look like anything so don't be put off by how they look by default.
Then MOST IMPORTANT: probably you should use a GUI Builder tool of some sort. I recommend NetBeans Matisse if you are new.
Now you should try all of that, and ask a SPECIFIC QUESTION when you get stuck. Good luck!

How to create a modular UI using MigLayout without nesting multiple panels?

MigLayout is a highly versatile layout manager for Swing, SWT and JavaFX.
As per the documentation, it should be possible to (re-)create any given layout with just a single instance of that layout manager.
However, I could never figure out how to create a modular application with decentralized control over layouting with that single instance:
I have a parent panel that controls where individual components contributed by submodules go.
Aiming for decoupled and independent submodules, those components are free to choose whether they do their layout with MigLayout or with any given layout manager. Thus, they hand out an instance of Node (or JComponent), and I end up with nested layout managers.
Are there any emergent/good/best practices for achieving both decoupled architecture and adhering to MigLayout's single-instance paradigm?
I understand what you want to do and have tried similar approaches. I found no generic solution; either you nest the layouts or you come to some kind of agreement between modules on usages of ranges of cells (this is what I usually end up with when for example generating search screens).
I ended up with one conclusion; having totally independent modules putting stuff on a screen works fine technically, and if you can make a high degree of separation part of the layout style, it might also work for the user. But I found that the resulting screens usually are not very user friendly, especially if there are multiple layers of construction. So I stopped trying to dynamically construct screens and just build a screen to match the task at hand; there is the end user screen, some custom controls, and maybe the occasional task specific panel (/ pane).

Horizontally flipping a JTree

I want to visualize a set of linked objects by focusing on one element and showing all referenced objects and descendants in a tree to the right. That's business as usual.
But if i want to show the referencing objects (i.e. the objects pointing at my selected element) to the left of my selection i'd like to add a little twist. I want it to be a "reverse tree" - a tree with the structure nodes and lines on the right side.
That way the selected element (as root node) would be in the middle of the two trees and at least in theory it would be less confusing to the user.
Is there a way to flip the tree structure (not the text of course) horizontally in a JTree?
I'm pretty confident that there isn't an easy solution.
Probably the best you can do is, dig into the paint/repaint method of the tree until you find the place where the actual drawing is happening. Then create a tree with your own implementation of that.
Beware that you have to do the same thing for any kind of event handling, in order to find the correct node that was clicked on.
maybe you have look at JTreeTable,
It seems like you have to implement the TreeCellRenderer interface and make your own realization of getTreeCellRendererComponent and paint methods.
Excuse me for short answer and maybe wrong even. It just a small hint.

Categories