brunomnsilva / javafxsmartgraph Goto Github PK
View Code? Open in Web Editor NEWGeneric (Java FX) Graph Visualization Library
License: Other
Generic (Java FX) Graph Visualization Library
License: Other
We're working with complex objects and it would be nice if we could set the label during vertex/edge creation. If I'm not mistaken, we would now have to first update the graph, then call update(), then use .attachLabel() on SmartGraphVertexNode (or something like that) and then call update() again.
Currently we're just overriding toString() of the generic vertex value, but for others there might be multiple string representations one would like to see. The method toString() will probably be a technical representation for debugging purposes in most cases. Another solution could be wrapping the object into another class on which the toString() is set for the visualisation, but that's sub-optimal.
Steps:
I cant run the application - the error is: java.lang.module.FindException: Module smartgraph not found
Please help.
Since the response has been great on a couple bigger issues, I decided to post a couple small ones too.
You can basically resize anything, the edges, the vertices, except for the arrow head. Yes you can change stroke width, but then it turns into a blob instead of a bigger arrow. After diving into the source code it turns out the arrow is a Path element with static coordinates.
Perhaps you could define the path based on stroke width? Or add a property I guess.
While we're on topic of arrow styling, maybe the style classes set on the edge should also appear on the arrow head.
Expected behavior:
Two edges should be able to exist with the same name. And by name, I really mean label.
Actual behavior:
If I try to make the graph displayed above, then an error is thrown claiming that the edge a
already exists.
com.brunomnsilva.smartgraph.graph.InvalidEdgeException: There's already an edge with this element.
at com.brunomnsilva.smartgraph.graph.DigraphEdgeList.insertEdge(DigraphEdgeList.java:99)
Perhaps there should be an additional label
parameter available to edge objects, and that label
is what should be displayed instead of the edge key?
e.g.
g.insertVertex("start", "state a", "a", "a")
g.insertVertex("state b", "state a", "a2", "a")
You could also just auto-generate a unique-enough edge key by combining the inbound-vertex, outbound-vertex, and label.
e.g.
// behind the scenes the key would be something like "start, state a, a" <- could hash this
g.insertVertex("start", "state a", "a")
// "state b, state a, a"
g.insertVertex("state b", "state a", "a")
// the visual label would be a for both
I know this not really an issue but i've no idea how to setup the properties file on my project ! i managed to understand every point except for this one.
thanks in advance
From #10:
Umm, are you certain it doesn't clear the default classes now? (.vertex, .edge, .arrow)
Yeah I (Bertie2011, but now on a school account) finally got around to trying the new version (which you should probably increase the version number of instead of calling it 0.9 again) aaaaand it does seem to have the default classes missing after setting a custom class in the latest version. ๐
Hello!
I have an issue installing tooltips as in javafx.scene.control.Tooltip
. I assume it can only be installed on
com.brunomnsilva.smartgraph.graphview.SmartGraphVertexNode
but thats an internal class.
How do I install tooltips?
Thanks, J.
I managed to set a custom properties file path using the Graph constructor (I think), which removed the missing properties file warning. The css file check is hardcoded, a style sheet parameter in SmartGraphPanel would prevent the missing default css file warning from being printed to console.
Using this project as a gradle sub-module would be a very useful feature. To add support for that a build.gradle file needs to be added, and the resources need to be moved into a directory.
I have two problems that may be related.
I draw edges in different colours if their "weight" is positive or negative. However, the edge arrows always appear in one colour. How can I fix this?
In the CSS, file there is a way to specify a hover behaviour for the vertices. I would like to do the same with the edges. How can I do this?
On a related note, it would be really nice to have a detailed manual of sorts.
Thanks,
Ozan
Hi,
Are you planning to implement a way to create new shapes in the graph like boxes or ellipses ?
Bruno, nice work. Any thought to including input/output port(s) on the vertex so that data could be associated with that graphic? It would be a great enhancement for my application.
I'm trying to use JavaFXSmartGraph to show relationships between people.
It works well but a lot of manual repositioning is required each time the graph is shown to get the layout right. This happens whichever layout strategy is used.
E.g. The circular layout strategy produces this:
But after manual changes it's clearer:
Is there some way for the graph to remember previous node positions and to use these if they have been set before?
Hello and thank you for your hard work on this library. This is more of a question than an issue. I was wondering if I could change a vertex's label in my custom Strategy class or even outside it.
I was looking at the javadoc and eventually I found out that I can load my custom CSS class by using the setStyleClass method on a SmartLabel object. This SmartLabel is attached to a SmartGraphVertextNode in the addVertex method in SmartGraphPanel.
I can't find a way to get this SmartLabel and load the CSS class into it.
Any help is deeply appreciated, thank you.
Hi
Thank you for this beautiful graph library. However its is continuously throwing exception mention in above title. I am trying to show connected graphs. The vertex may be more than one in complex. Also I am adding the vertex dynamically. But After the loop run only onces the library throws this exception. Please have a look on this error.
The error details looks like this:
com.brunomnsilva.smartgraph.graph.InvalidVertexException: There's already a vertex with this element.
at com.brunomnsilva.smartgraph.graph.GraphEdgeList.insertVertex(GraphEdgeList.java:139)
at application.MainApp_Layout.retrieveRelationships(MainApp_Layout.java:612)
I am adding the vertices in this way
for (int i = 0; i < Influence_relation.getLength(); i++) {
Node inner_node = Influence_relation.item(i).getFirstChild();
FTGgraph.insertVertex(inner_node.getNodeValues());
}
Hi! Could you please tell me how I can draw a graph on canvas which is part of JavaFX?
Hi,
I used your method from your project at Main.java :
graphView.setVertexDoubleClickAction(graphVertex -> { System.out.println("Vertex contains element: " + graphVertex.getUnderlyingVertex().element()); g.replace(graphVertex.getUnderlyingVertex(),"NewEntity"); System.out.println("Vertex contains element: " + graphVertex.getUnderlyingVertex().element()); graphView.update(); });
I added the instruction g.replace(graphVertex.getUnderlyingVertex(),"NewEntity");
When I ask the name of this current vertex, the method changed its name but even after the instruction of updating the graphView, it doesn't show the new name.
How can I create a vertex by mouse click, that is, through the event processor? I cannot achieve this by overriding the strategy because the place method only uses the scene value.
Hi,
Once again I thank you for this nice graph library. I run your own example but when I run it, the arrow itself changes the direction .If I set the arrow like this
A->B and B->A
then the arrow always headed to B like A->B in both cases.
The other problem
When I run this example
g.insertVertex("A");
g.insertVertex("B");
g.insertVertex("C");
g.insertVertex("D");
g.insertVertex("E");
g.insertVertex("F");
g.insertVertex("G");
g.insertEdge("A", "B", "1");
g.insertEdge("A", "C", "2");
g.insertEdge("A", "D", "3");
g.insertEdge("A", "E", "4");
g.insertEdge("A", "F", "5");
g.insertEdge("A", "G", "6");
the arrow head is not heading toward source and target. For example the edge arrow of vertices connected to A is not correct only A->F is connected in correct way. Also the vertices connected to H are not connected correct way lets say the arrow should to toward I in H->I and H->J.
Also It changes every time when I run the application.
Please give some solution. I am working some research work and I want to use this library to show my data.
Thank you
Hello!
Can I set an icon to the Vertex?
I tried using "-fx-background-image: url("./town.png)"
But it was not successful.
What are some options to achieve my goal?
In an application where styles are constantly changed, the setStyleClass does not remove the previously "set" style, resulting in visuals not updating.
when I use this repository, I got this error, can you help me with that?
the error: "Exception in thread "main" java.lang.ExceptionInInitializerError
at com.brunomnsilva.smartgraph.graphview.SmartGraphPanel.addEdge(SmartGraphPanel.java:506)
at com.brunomnsilva.smartgraph.graphview.SmartGraphPanel.initNodes(SmartGraphPanel.java:433)
at com.brunomnsilva.smartgraph.graphview.SmartGraphPanel.(SmartGraphPanel.java:199)
at com.brunomnsilva.smartgraph.graphview.SmartGraphPanel.(SmartGraphPanel.java:163)
at com.brunomnsilva.smartgraph.graphview.SmartGraphPanel.(SmartGraphPanel.java:148)
at MainClass.Main.main(Main.java:49)
Caused by: java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:436)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:431)
at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:724)
at com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(PlatformImpl.java:686)
at javafx.scene.control.PopupControl.(PopupControl.java:89)
... 6 more"
Note: I use JDK 17
I've never worked with CSS before, so maybe this is obvious, but is there any way to change the color of nodes in the code? I know that you can change the styles nodes used based on preconfigured CSS entries, but I'd like to be able to have nodes slowly fade from one color to another to show gradual changes in "attitude" of nodes.
To reporduce:
Add 2 vertexs A and B. Make a link between them.
In code later make a new vertex C and then add an edge to A.
In code later remove the C to A edge with g.removeEdge(name)
graphView.update();
Observe that the arrow is removed, but the attraction between C and A remains.
Hi,
In my project, when i double click on a vertex, i want to display only vertices that are adjacents to the one a clicked on, and after i want to display all the elements of my graph but does not work...
I tried to remove all vertices and edges and then insert all of them but it crash here:
var v = this.viewGraph.getStylableVertex(vertex);
v.removeStyleClass("vertex");
v is null
I tried to reinstance my graph and viewgraph but it crash when i do an update of the graph, here is the error:
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: You must call this method after the instance was added to a scene.
at com.brunomnsilva.smartgraph.graphview.SmartGraphPanel.update(SmartGraphPanel.java:317)
How can i do that ? thx
I see , that i can use css for change color, or label font. But it will be more better to use different shapes for different types of vertices. Is it possible? Thanks!
Hi,
First of all, thank you for you work - it's great.
I'm working with your project and I need to create a new method to apply a different style of Edges and Vertexes. I was thinking of creating property in the "smartgraph.css" and then create a new method of inserting an element like the "insertVertex(...)" method.
The issue is the link from a property in smartgraph.css and insertVertex() is more deep than expected.
Do you see an easy way to do it ? Or should I modify / create a method for each file in the process ?
Thank you for your time,
TL
Here is my code:
var e = this.viewGraph.getStylableEdge(edge);
var line = (SmartGraphEdgeLine) e;
var arrow = line.getAttachedArrow();
line.attachArrow(arrow);
When i attach the current arrow, the arrows are missed placed and they doesn't move correctly when i move the vertices.
I tried to do that because i reset the radius of vertices with this :
var v = this.viewGraph.getStylableVertex(vertex);
var node = ((SmartGraphVertexNode<?>) v);
node.setRadius(35);
But the arrows are hid by the vertices now...
I can't replace the arrows :/
How can i do that ?
Hi,
I have an issue with overlapping nodes.
Every time I insert an element in the graph, I update it with graphView.update().
I am currently putting on the graph around 70 nodes in row.
Do you think the issue has something to do with the "smartgraph.properties" and the Force-directed layout ? Or graphView.updateAndWait()
could do the trick ?
NB : there are currently no edge in the graph
_Figure 1 : Node overlap_ _Figure 1 : Node overlap after I drag the top node of the stack_Thank you for you help
TL
Hello, thank you very much for making this available, it is really useful.
I'm using it in a Maven project, and it would be very convenient to have it available through a Maven repository. Do you have any plans for this? If not, that's completely fine, I was just wondering.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.