jung how to create a new vertex at new position - jung

I am using circle layout in jung. On the click of button i am able to create a new node but it overlaps with the earlier one. Ever new node is getting generated at the same position. Please help me in dynamically allotting a location to newly created node

CircleLayout is a static layout: if you add new vertices to the graph, you need to create a new CircleLayout instance.
Aside from that, I have no idea how you're assigning locations to vertices when you create them, but that's your code, not ours. :)

Related

How bind some nodes in spritekit and move them in a bunch along one trajectory?

I create game with spriteKit in Xcode. I need to create carousel and move 4 nodes around one pillar.
carousel
How can I move some bind nodes? It`s necessary to change zPosition when node approaches the pillar and when node comes out from behind the pillar. How it can be implemented?
To group your nodes together, just create a new SKNode, add it to the scene, and anything that needs to be grouped to this, just call move(toParent:) on the nodes that need to be moved.
let groupedNode = SKNode()
self.addChild(groupedNode)
node1.move(toParent:groupedNode)
As for zPosition, it is relative to the parent, so if your pillar is at 2, and your group is at 1, to make your individual nodes above the pillar, you need to make the node 2. This will make the node zPosition really 3 (node + group) placing it above the pillar.

iOS - Converting Point From One Coordinate System to Another

I have icons that are children of node "shelf", which is a child of "self"(the scene). I also have decorations that are children of node "vehicle", which is also a child of "self".
When an icon is dragged off of the shelf and onto the vehicle, the icon node is removed and a decoration node is spawned in its place, which is made a child of "vehicle" instead of "shelf". This is a problem: when the decoration node is spawned, it jumps far away in the scene because the coordinate systems of "shelf" and "vehicle" are incongruous.
How can I convert the new decoration node from its position in the "shelf" node to its new position in "vehicle" so that it doesn't jump?
(I can post code if you need it, but it will be very long and messy.)
Assuming you're using Sprite Kit, you can use the SKNode method convertPoint:toNode: to convert points between coordinate systems.
So for instance, as soon as dragging ends on top of the vehicleNode:
CGPoint iconPos = iconNode.position; // this is position on shelf node
iconPos = [shelfNode convertPoint:iconPos toNode:vehicleNode];
// ... remove iconNode from shelfNode
// ... make new decorationNode
decorationNode.position = iconPos; // this is now position on vehicle node
// ... add decorationNode to vehicleNode

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.

Highcharts - Updating a chart's option after initial render

Is it possible to update a chart's option (marginRight for example) and call redraw() to have that new value reflected in the chart? Or does a new instance of the chart need to be created for these types of changes?
I think it may be the latter because it sounds like only data or axis values can be altered after the chart is created. I see the documentation for redraw states:
Redraw the chart after changes have been done to the data or axis extremes
And the new dynamic feature in 3.0 states:
Through a full API you can add, remove and modify series and points or modify axes at any time after chart creation.
Thank you in advance.
Update
My reason for wanting to do this was I had a vertical layout and right-aligned legend that was overlapping my chart. I just realized Highcharts automatically sets the correct marginRight to accommodate for this if one isn't explicitly specified.
Unfortunately you cannot modify margin parameter dynamically, so you need to destroy old chart and create new instance.
This feature is one of our target in the nearest future.
Say you got a chart initialized like this:
chart = new Highcharts.Chart({
...
You can change trivial attributes, like its title, like this:
chart.setTitle({text: "New title"});
And you can refresh the dataset it's using with a new one, like this:
chart.series[0].setData(newChartData, true);
Where newChartData will contain the array with new data you wish to display

HighChart - Custom Paths Not Linked to Chart

I have a HighStock chart that is pulling in some OHLC data and creating a chart with 3 series - 1 candlestick, 1 volume, and 1 set of flags. This all works fine.
I want to add some custom trend lines to the chart. I will determine the points and do the paths based on custom logic.
The problem is that when I use the Renderer from the Chart to draw my path, the path is not connected to the underlying chart. As the chart date range is modified and/or new points are added to the primary series, the placement and size of my custom path remains unchanged. It is constant.
I need the location/endpoints of the custom path to be tied to the datapoints of the chart, not the coordinates of the svg drawing. Is there a way to accomplish this?
Here is the portion of the code that is adding a simple path from pointa to pointb. The path renders as expected but is then static:
buildPath: function(pointa, pointb){
this.myChart.renderer.path(this.buildPathArray(pointa,pointb))
.attr({
'stroke-width': 2,
stroke: 'red'
}).add();
},
buildPathArray: function(pointa, pointb){
var pathArray = [];
pathArray.push('M');
pathArray.push(pointa.plotX);
pathArray.push(pointa.plotClose);
pathArray.push('L');
pathArray.push(pointb.plotX);
pathArray.push(pointb.plotClose);
pathArray.push('Z');
return pathArray;
}
Per request, I created a JS Fiddle that demonstrates the general issue.
Any help is much appreciated.
SOLVED
This doesn't seem to come for free with Highcharts. Or if it does I did not find out the technique.
I had to use both the load and redraw events of the chart object contained in my StockChart.
On load, I draw the initial paths, aligned with the Point objects involved in my trending lines. As I build these path objects (SVGElement objects containing the genuine SVG path elements) I keep track of them in an array.
On redraw, I have to both destroy the old trend lines and create new ones. So I loop over my array of old elements and remove each from their own parentNode. Then I draw a fresh version of my trend lines based on the newly plotted location of each of my relevant Point objects.
The end result is that on each redraw event, the lines appear to move with the chart, when they're really being destroyed and recreated.

Resources