Hi I have been coding Java for a while but new to graphics.
I am using the Prefuse Visualization library, and am successfully adding nodes to a graph.
I have laid out 4 JPanels, northWest (NW) NE, SW, SE. When I click on a node in NW, I want that node to be added (copied) into NE. Thats the bigger picture.
So 4 JPanels as mentioned. 4 graphs, called graphNW, graphNE etc etc.
I am adding data to graphNW from a CSV.
I create a common Visualization (vis).
I set up where to place the JPanels.
I then pass graphNW, graphNE to a method. this then calls:
Java Code:
northWest.add(createDisplay(graphNE , vis));
This creates a display from vis. It adds pan/draw/zoom controllers to the display, and finally a ControlListener to handle what to do when the display is clicked on. This is passed the graph graphNE and vis.
When the graph is clicked:
Java Code:
if (item instanceof NodeItem) {
addNewNode(item, graph);
system.out.println(graph.getNodeCount());
}
the console shows that the number of nodes on the graph is increasing with each click
In other words when a Node is clicked in graphNW, a new node is added to graphNE, that is equal to the current node.
however currently this isnt currently what happens. What I see is an exact replicor in graphNE of graphNW always. Then no new nodes appear when I click on one in graphNW. I think it is to do with the way the visualization is setup - it takes all of its properties from graphNW - and is then used by graphNE to create the display, however I didnt think I would need a new visualization for every graph?

rather I would want it so that when a node is clicked in a certain graph, that told its parent object, and that handled what to do with this information.
Any ideas what I might be doing wrong?
Thanks
Alex