Contributing to ENIGMA => Proposals => Topic started by: Mangolion on October 19, 2014, 03:09:58 PM

Title: Force directed graph in LGM
Post by: Mangolion on October 19, 2014, 03:09:58 PM
After a few hours studying LGM's wild source code (I really wish there are more comments and javaDocs   :-\ ) I decided to make a small feature to see how I understood LGM's basic components. I've added 2 force directed graphs, one to show an object 's events and actions, the other to show all resources in a project (objects, backgrounds, ...) and also objects and their events.
I added a "View" menu in the menubar for project visuallization, and a "Visualize" button in the obj frame.
Drag right mouse to zoom.
Download it here : https://www.dropbox.com/s/3hp184w14at89uf/Crazy%20LGM.jar?dl=0 (https://www.dropbox.com/s/3hp184w14at89uf/Crazy%20LGM.jar?dl=0)
I have used the substance library for the cool-looking GUI : https://github.com/Insubstantial/insubstantial/releases/tag/insubstantial_7.3 (https://github.com/Insubstantial/insubstantial/releases/tag/insubstantial_7.3)
and the visualization toolkit called prefuse: http://sourceforge.net/projects/prefuse/ (http://sourceforge.net/projects/prefuse/)
Please know that I don't really understand most of LGM's code because my experiences with java isn't enough. However, I am quite proficient with writing Android apps and am planning to port LGM to Android, perhaps you guys can help!  :)

Title: Re: Force directed graph in LGM
Post by: TheExDeus on October 20, 2014, 11:46:03 AM
This is actually an extremely cool feature. It helps the user to grasp the project and the relationships. More view options would be cool, like showing sprites as actual sprites; allowing people to edit the resource by clicking on it; and showing the scripts used in an event (even code events).

Then later things like relations between instances would cool, like showing Create event -> Code Event -> scr_delete_bullet then links to obj_bullet, because spr_delete_bullet has "with (obj_bullet){ instance_destroy(); }" in it. But that would involve parsing the code, to see which resources are referenced.
Title: Re: Force directed graph in LGM
Post by: TheExDeus on October 24, 2014, 06:26:57 PM
Did anyone else check this out? I would really like a feature like this in main LGM at some point. I guess having a 3rd party visualization library can be large to include (or is the skin the one thing that made this LGM 6mb?) and I don't think we need something as fancy looking as this (via all the animations and stuff). But I really do like the feature.
Title: Re: Force directed graph in LGM
Post by: Goombert on October 25, 2014, 05:45:35 AM
Sorry I forgot to respond to this topic. It certainly is a nice feature, I can tell you that Josh would definitely like it he did very similar with JDI which can spit out SVG's. My recommendation is to wait until we design a better plugin system with LateralGM. The intention was to utilize Project Nashorn so that JavaScript extensions could also be added, much like Unity3D so that users can expand editors and such. Currently I have no actual solid plans for this and it requires more discussion with IsmAvatar, but I haven't even really approached her about the topic yet. In other words, I am just saying that I think LGM should have a better extension system that supports JavaScript, but I really have no idea how to go about implementing it, it's not that I don't understand the technology involved. For instance, Unity3D lets you place a script as a resource in your project and you can even write your own editor with JavaScript or C# and you can distribute these scripts on their market place. If we went that route for LGM we would have to add a new resource folder to the tree among other things, but again, I have no idea if we should go this route or what route anyone else wants to go for the extension system revamp.

However one thing that everyone could do to speed this along is to go and upgrade to Java 8, which is one of the most quickly adopted Java versions in history because of all the new features. I strongly encourage you all to upgrade.
Title: Re: Force directed graph in LGM
Post by: Josh @ Dreamland on October 25, 2014, 11:56:44 AM
Actually, I don't really understand this one—in general, I'm a fan of GraphViz (Prefuse?), but in this case, the interface seems not to offer any new information; it seems to just be an unscalable rehash of the current system. What happens when you try to display an actual game? I've never seen a finished game with less than 20 objects, and I've never seen an event which had about three non-code DND tiles. This presentation just won't work for real games.

That said, the interface could be effectively used to display inter-resource dependencies. For instance, if it showed "Objects" -> (Group name)* -> (Object name) -> (Script name)*, that would be mostly tractable (as long as you had to click a group to make it the root and display its objects). It would also be useful for people when they wanted to change the behavior of a script—especially if you could filter by script name.

The same can be said for most combinations of resources. It'd be easier to bundle resources into loadable/unloadable packages if you could quickly see what all references them.

Showing actual code, though, just won't scale.

JDI exports expressions as trees, not whole pieces of code. A complicated expression looks like this (https://dl.dropboxusercontent.com/u/1052740/notable_asts/ast_00000941.svg) or this (https://dl.dropboxusercontent.com/u/1052740/notable_asts/ast_00000935.svg):
(https://dl.dropboxusercontent.com/u/1052740/notable_asts/ast_00000935.svg) (https://dl.dropboxusercontent.com/u/1052740/notable_asts/ast_00000935.svg)

An entire script would not be fun or easy to navigate in this form. I'll be adding that capability for my own debugging purposes, but it's not something we really want to hand users.
Title: Re: Force directed graph in LGM
Post by: TheExDeus on October 25, 2014, 03:31:17 PM
As I said there are many ways to improve what is shown. I was advocating the idea in general though. Right now this is like Gource. It shows the project as "gmk", then each resource type as a child of that, and then each resource as a child to each type node. Then things like objects also have events and code. It might be clearer and easier to use if it was more in a tree form, but this is also cool. We could make it more practical, but I also liked only the visualization in general, as it shows scope of a project.