I use GraphViz to draw oriented graph - I read file with graph data according to http://graphstream-project.org/doc/Tutorials/Reading-files-using-FileSource/ tutorial.
Everything works fine when there is not two or more edges between two nodes. If so, the org.graphstream.graph.IdAlreadyInUseException: singleton exception: id "(48;63)" already in use. Cannot create an edge. is thrown.
I understand the exeption quite well. The problem is that I don't know how to get rid of it (and I don't want to write my own data parser).
Does anyone know how to solve this?
I don't know about graphviz, but the error you get and the tutorial you refer to are GraphStream related.
In GraphStream, you need to use the MultiGraph class in place of the DefaultGraph one.
Related
I'm currently working on a training plugin, where every player would get his own region, to learn bridge for example. So when a player joins, the plugin should automatically generate a new area for this player and delete it when he leaves.
I've created a SetupCommand where you have to set the start and end of the region that should be copied.
Now the only thing to do is copy the region and teleport the player to it, however, I couldn't find any good ways to do that. The only solution I found so far is to loop through all blocks and copy them one by one. But I can imagine that this is not the best solution and would cause lag, not only server-side but also client-side.
Are there better ways to clone a region than that?
I've read you should use Schematics but they weren't going into detail.
If you are experienced with java and feel comfortable about your skills you can try to get the blocks in the list as List and save it as base64 into your database or whatelse. You can parse it everytime back into a list of blocks and replace it. I would rather recommend you to make a custom block class with implements Serializeable and then add some values like Location, Material and BlockData to it.
Use FAWE or WorldEdit to copy/paste sections
If you use Block#setType, performance will be very slow, so if you don't want to use the API, you should use NMS, but using NMS is not a good practice.
Disadvantages of NMS:
Most nms methods are obfuscated. In one version the method is called f(), in the next version maybe c().
How to copy/paste with FAWE:
https://www.spigotmc.org/threads/how-to-paste-a-schematic-with-fawe.402950/
How to copy/paste with worldedit:
https://www.spigotmc.org/threads/worldedit-api-schematic-copy-save-load-and-paste.498476/
In conclusion, it is recommended to use the API
I am using Apache Pivot 2.0.2 and I am trying to build a DesktopApplication.
My problem is that I have a ListView or really - whatever object in my application, defined in bxml file. I can give it an ID or anything - no problem.
But now, how should I obtain this object in Java and affect changes I make to it?
Since my bxml are including other bxml files; after
this.window.open(display);
I have tried to obtain a certain object with:
bxmlSerializer.getNamespace().get("musicPanel");
And i can have the object with everything I put in BXML. I can even change its properties BUT
its not being reflected on the GUI! Nothing changes!
So I thought I could find my object in the
window.getContent();
but I cannot find a method to get an object with ID.
Any help appreciated!
Its hard to explain, but mainly I had to restructure my application and use my own namespace as in the example:
Stock Tracker Example
And it was useful to get the full sourcecode of these examples:
Sourcecode
I'm having a bit of trouble figuring this out so if you can help that would be great.
I have written a bit of code that gets a list of URLs from a sitemap. I then go each page, scrape all the links, and then test their status(200,404, etc).
I am using HttpClient. I have it all working OK but as I am new to Java I reckon my code is a complete hack/maze and I could most likely get far better performance if it was organised correctly. So what I have is
Main class - This builds the gui
Parse the sitemap class - This parses the sitemap and get a list of the urls.
Class called PingURl - I'm sure my above is poor but this is the bit I reckon is worst. This class opens all the urls, scrapes them for links, then tests the links for their status and returns it. I presume this class should be broken down? Most importantly I think I should be isolating the testing of the links in it's own class, so it would be easy to implement threads later on?
Basically I'm looking for advice. If someone could help me with laying out the project a bit better. Secondly I believe this is my weakest area so to improve I need to learn more about this, I don't even know what to call this(design/layout problem?). Can you also recommend resources to learn more about this?
Java is a language which IMO, embodies good OO design. Designing with OO in mind is very effective.
http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/oo.html
In terms of your problem, I think it works pretty well. You are kind of following a Model-View-Controller pattern: http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html
I can't tell you how to design your code, but I will tell you how I would do it if I were presented with the same problem:
I would get a class to represent a hyperlink. In that class there would be the hyperlink that has been scraped, and a getter and setter. As well as a boolean value and a ping function. That means that if I create a "hyperlink" object, then I can invoke ("ping") on that object because it is part of that class. That means that the ping function simply sets the boolean that represents connectivity.
That way, your parser basically gets a page, and for each link it finds, it creates a new "hyperlink" object based on your own "hyperlink" class. And puts it in an array. So once your parser executes you get an array of pointers to hyperlinks.
Then all you have to do is invoke the ping function on each one to see if it is there.
I think this design is the best because it scales from doing one hyperlink test to doing 1000 quite easily.
There is soooo much stuff out there about design, there are countless principals as well. There is never one absolute way to solve a problem. But the more experience you get, and the more you read up on design patterns and models the better you will get at it :)
In an android application, what is the best method to store primitive data variables (such as a list of 3 integers) on the device so that those integers can be seen and manipulated by the app, but remain on the device after updating the app?
also, it would be best if there was a way to tell the difference between the user updating and uninstalling and delete the file upon the latter. Any easy way to do this that i'm unaware of?
Any example code of the actual serializing of a piece of data would be very helpful.
I'm reading the documentation, but having trouble finding really clear examples.
Refer here!
dear friends, i use openCV in Java. Everything is fine but the thing is that am limited with API, i cant create C files (i'm not skilled in C/C++ that much and i did not use them for a long time) for my specific tasks, thus i must solve my problem with haar cascade xml file...
My task is to detect simple objects NOT FACEs, just simple objects like cup on the table, clock on the wall...
I think it is possible with edge detecting, but i did not find any cascades for this simple detection stuff. It is quite hard for me to google it because when i search object detection it always gives face detection stuff...
Could you please suggest me solution for this?
Your help will be appreciated.
Regards.
You can create your own haarcascades, but it's a lot of work!
You will find some interesting links in the answers to this question.
As you said, there are other ways to detect objects, like edge detection or color tracking for instance. There are plenty of resources for this on the web.
I guess i find the solution,
1) Solution one - there is very useful blob function witch does exactly what i wanted to, and even more, it detects center of the blob...
2) You can use deprecated method CV.findContours(...) and do your necessary stuff.
Please let me know if you have any suggestions or fixes to this...