JUNG - adding an edge or a node dynamically in a graph - jung

I use Java and Jung for an application with graphs. I want to add dynamically an edge to a graph while it is visible. In particular, I choose a node from a list (JComboBox) and when I press a button an edge shall be created between that node and a given node. However, when I do that I get a
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
message.
I would appreciate any help.

Related

How to get all nodes within an area surrounded by a node type by using Cypher (Neo4j)

I am trying to do the following:
Let's say this is the initial graph: Initial Graph
I want to get all the blue nodes between red nodes and connect them to a new yellow node. I want to do this for every blue node area seperated by red nodes.
What I am trying to tell: The Result I Want
I want to do this without creating redundant yellow nodes and unnecessary traversals. Also, I want to do this in a single query, if it is possible.
Initially I achieved creating yellow nodes and connecting them by getting paths which start with a red node and end with another red node. However, this solution led to creating redundant yellow nodes since there are some areas seperated by 3 or more red nodes. For instance if a blue node area is seperated by 3 red nodes, this solution finds 3 different paths in that area, therefore creates 3 different yellow nodes. So I had to delete redundant yellow nodes in another query which was terrible in terms of efficiency.
After that, I tried using apoc expand functions, however they require minLevel and maxLevel parameters which again leads to finding more than one path in a blue node area.
In short, the real question is how can I achieve getting each blue node area as a single path without compromising efficiency?
Edit: I also tried creating a yellow node for each blue node directly connected to the red node near it and then connected the other blue nodes to the yellow node if they are reachable through blue nodes, however this query also takes too much time.
As far as I am concerned matching paths like the following query affects time efficiency too negatively:
MATCH path = (:YELLOW)-[link*]-(:BLUE)-[:CONNECTION]-(:RED)
WHERE single(x IN nodes(path) WHERE x:RED)
//Then connect nodes in path to the yellow node if there is no connection
Any suggestions?

How to always show Sirius Label in foreground

For the context, I'm working with Capella, an Eclipse RCP application based on Sirius (hence, EMF, GMF and draw2d). This application is used for MBSE, that basically means diagram representations for industrial systems.
I'm developping an add-on (viewpoint) to display custom labels next to diagram elements. These diagram elements are, to put it simply, boxes inside boxes. My problem is that usually the label text is larger than the space between a box and its container, so the label gets hidden. What I need is these labels to always be in foreground. As I'm more used to web development, what I'm looking for would be the equivalent of the z-index CSS property.
Currently I have no idea of how to achieve this, I'm using a custom .odesign that allows me to control some rendering options, like labels text, the color of some elements or to add decoration, but I dont think its the way to go for my problem. Maybe I should use a custom EditPart or a custom StyleConfiguration (I already used these components for other projects) but I have no clue where to start for this issue.
Any leads will be greatly appreciated.
We recently did this kind of changes to keep some labels in Sirius Sequence diagrams always on top: the combined fragments are placed behind the lifelines (z order) but we wanted to keep the labels of the CombinedFragments visible event their bounds intersects Lifelines, Executions or States).
This has been handled in Bug 564239 for Sirius 6.3.2 (used in Capella 1.4.1).
You could find some hints the bugzilla (Gerrits and commits can be retrieved from the See also section).
In Sirius Sequence diagram , we use org.eclipse.sirius.diagram.sequence.ui.tool.internal.layout.SequenceZOrderingRefresher to control the z-order of CombinedFragments : all the figures that composes them comes from some expressions in the odesign, and synchronization with the Capella model for exemple.
But in your case you want to control only the label, so it must not be dealt on the edit par level, but on the figure one. The "overlay" layer and figure lead might be a good one.
Do not forget another thing: in GMF/GEF, the labels of an element is displayed/shown/rendered/visible if it fits to the visible area of the parent container: in the case of a node in a container with scrollbar, the visible are will impact the visibility of the sub nodes (extended to their border nodes, edges, labels, ...)
Regards
Maxime

How to Simulate TListView(vsIcon mode) with Virtual TreeView

I am using Delphi XE3. Now I try to simulate TListView(vsIcon mode) with Virtual TreeView. Is that possible? Basically this is:
(1) A tree with only root nodes. That is easy to implement. Just use the following codeline is OK:
VirtualTreeView1.RootNodeCount := 5;
(2) Hide the tree lines. That is also easy to do, just set toShowRoot option to False can hide all the tree lines for the root nodes.
(3) Each root nodes is displayed with only icon instead of text. That can be implemented with OnGetImageIndex vent together with an image list assigned to the tree view.
(4) There is only one column. That is also easy. By default there is only one column.
(5) The nodes should be tiled from left to right, horizontally, instead of vertically.
The (5) point is the one that I cannot figure out how to implement. I try to do the following researches:
I try to check the TreeOptions and other properties, but cannot find one that support that feature.
I try to search online, and find the following articles:
How to display an icon or image in a column of TVirtualStringTree? (This use multi-column)
Icon position in Virtual Treeview (This does not discuss tiling of nodes horizontally.
Delphi - ListView or similar with owner draw button ( THis also tile the nodes vertically)
I then try to search keyword horizontally in the help document of Virtual TreeView, but what I get are all about how to scroll horizontally, not tile node horizontally.
I think I have tried my best to find a solution but failed. That is the reason why I ask on stackoverflow.
I don't think this is possible, at least Virtual TreeView was never designed to do this. It is a tree control that supports columns.

JUNG layout for left-to-right placement of nodes

Is there an optimal layout in JUNG for left-to-right placement of nodes in the graph? I'm looking for something that would model a data lineage and need to represent this somewhat linearly (left to right).
If your graph is a tree, then you can use the TreeLayout and do some post-processing to rotate it to have the root on the left instead of the top (see the L2RTreeLayoutDemo for an example of how to do this).
If your graph is only sort of tree-shaped, then you may want to extract a tree from your graph first (see MinimumSpanningTreeDemo for one way to do this automatically) and then follow the procedure above.
If neither of those works for you (for example, this won't work if your graph has multiple "roots"), then you will probably need to create your own layout, perhaps based on TreeLayout.

Neoclipse editing and constant graph layout

Each time I add a new node and a relationship, Neoclipse change the layout of the graph and eclipses nodes according to the traversal path, which become annoying as the graph is growing very fast (hundreds of nodes).
Each time, I have to find the newly created node to add properties.
My question: Is there any option that allows to disable remapping the graph each time it is edited
The button "Show reference node" alleviates the issue by keeping focus a given node, but I am looking for a way to disable the graph redrawing.
Thanks in advance.

Resources