Hi,
My graph is created without coordinates at all, but before using it for making the video I set the coordinates of the nodes (I will explain it better later).
After creating the graph, it is displayed on the screen, basically on the following way:
//I get the instance of the created graph, that is a class on the Singleton pattern that extends the MultiGraph class
GraphSingleton graph = GraphSingleton.getInstance();
Viewer viewer = new Viewer(graph,Viewer.
ThreadingModel.GRAPH_IN_ ANOTHER_THREAD);
SpringBox layout = new SpringBox(false, new Random(newDate().getTime()));
viewer.enableAutoLayout(
layout); DefaultView view = (DefaultView) viewer.addDefaultView(false);
view.getCamera().
setViewPercent(1);
final ViewerPipe pipe = viewer.newViewerPipe();
pipe.addAttributeSink(graph);
…
After that, I get the GraphicGraph of my graph and after I get the positions of all nodes of GraphicGraph, saving it into a Array List. I also created an Array List with all nodes’ positions that have to be in the way to go. Thus, I can set the nodes’ coordinates of my original graph. The coordinates are on graph units.
GraphicGraph copyGraphInstance = viewer.getGraphicGraph();
Iterable<? extends Node> eachNode = copyGraphInstance.getEachNode(
); List<Position> positionsAllNodes = new ArrayList<Position>();
for(Node node: eachNode){
double[] xyz = GraphPosLengthUtils.
nodePosition(node); //Postion is a class that has three attributes x,y and z
Position position = new Position(xyz[0], xyz[1], xyz[2]);
//Setting the nodes’ positions on the original graph
String id = node.getId();
Node node2 = myInstance.getNode(id);
node2.setAttribute("xyz", xyz[0], xyz[1], xyz[2]);
}
….
Thus, now that my graph has coordinates, I use the LeHavreClass, using the FileSinkImages on the following way:
String prefix = "tracking/images/prefix_";
OutputType type = OutputType.PNG;
Resolution resolution = Resolutions.HD720;
OutputPolicy outputPolicy = OutputPolicy.NONE;
FileSinkImages images = new FileSinkImages(prefix, type, resolution, outputPolicy);
images.setStyleSheet(
styleSheet); images.setQuality(Quality.
HIGH); images.setRenderer(
RendererType.SCALA); SpriteManager manager = new SpriteManager(GraphSingleton.
getInstance()); RandomWalk rwalk = new LHRandomWalk(manager);
addSink(images);
try {
images.begin(prefix);
} catch (IOException e1) {
e1.printStackTrace();
}
double step = 0;
…
The rest of the code is on the same way of your LeHavreClass.
A important diference is that on your dgs file, each edge has some attributes: name, speedMax, time, lanes, length e maxCap, while the edges of my graph have only an id.
In that way, on the “step” function of “VehicleEntity” class, that you use the speedMax and Lenght attributes, for example, I needed to do an adaptation and I entered some random numbers, so I don’t know if it could be the problem.
public void step() {
if (position >= 1 || crossing == null)
super.step();
if (crossing != null) {
//double speed = crossing.getNumber("speedMax") / 90.0;
double speed = 100 / 90.0;
double trafic = 1 - 0.3 * Math.min(50, crossing.getNumber(context.
getPassesAttribute())) / 50.0; crossedLength += speed * trafic * 25;
//crossedLength = Math.min(crossedLength, crossing.getNumber("length"));
crossedLength = Math.min(crossedLength, 400);
position = crossedLength / 400;
addPass(crossing, current);
sprite.setPosition(
getSpriteLocation()); } else
System.out.printf("%s nowhere\n", sprite.getId());
}
}
Would you have any idea about what could be happening to my images? They are being created empty.
Regards,
Carina2016-07-19 23:21 GMT-03:00 guilhelm savin <guilhelm.savin AT gmail.com>:GuilhelmCheers.Hope it helps.About magic numbers : it represents the count of produced images. The video has been generated at 25 fps. Since the output policy of the FileSinkImages is set to STEP_POLICY, images are produced at each call to graph.stepBegins(...). When passing such number to DynamicAttribute, we are telling it how many steps there will be for the animation. It is a bit too far to remember but I guess that 925 (ie. 37 seconds) is the length of the sequence.I can not say why you images are empty. It could be a lack of coordinates. But I need more informations about how you are using the FileSinkImages.Hi Carina,Please note that this code is a quick & dirty made creature which has only been used to generate the video. We made sources available "just in case" someone could find something interesting in it.--2016-07-19 15:47 GMT+02:00 Carina Oliveira <carinacapelao AT gmail.com>:Hi all,
First of all, congratulations for your API ! This is great and it helps so much !
My name is Carina, I'm studying Information Systems on Federal University of Minas Gerais (UFMG) in Brazil and I’m a Research Assistant on Compilers Laboratory, UFMG. I'm currently in a project that involves the design and implementation of an information flow system, which involves the creation of graphs and involves some interactions on this graphs. I'm using your API.
At this moment, what I need to do is: given a graph, and a set of connected nodes, that are considered tainted and that form a path, I need to do how you did in the "tracking example" ((https://www.youtube.com/
watch?v=XX5rRF6uxow#t=115 )). I want to zoom the first tainted node and walk through the graph, showing the tainted nodes that are on this path, and, in the end, create a video with this animation.I saw the LeHavre class, that you provided, and I adapted my code to use this class. Nevertheless, my graph doesn’t work. The generated images are empty. So, I thought that maybe you could help me. I didn't understand very well some particularities of the LeHavre class.
->For example, at this part of the code:
MoveCenterView move = new MoveCenterView(images, g.getNode("LH.9921_0"), 75, true);
DynamicCenterViewZoom zoom = new DynamicCenterViewZoom(images, 0.1, 75, true);
I didn't understand the meaning, the role, of the value 75.
->At this slices:
for (int i = 0; i < 20; i++)
rwalk.compute();
and
for (int i = 0; i < 75; i++) {
rwalk.compute();
updateGraph(g, rwalk);
g.stepBegins(step++);
}
I didn't understand the meaning, the role, of the values 20 and 75, as well as the other bounds of the 'for' (20, 75, 100).
->At this part:
double byStepLength = fullLength / 925.0;
I didn't understand what the value 925 represents.
I would like to understand what the values means so that I can adapt this functionalities to create a video on my graph, which is a MultiGraph, that isn't in a DGS file.
Thanks in advance and I await your reply.
Regards,CarinaGuilhelm Savin
PhD of Computer ScienceLITIS, University of Le Havre
\/\/\/\/\/\/
Archives gérées par MHonArc 2.6.16.