Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing graphs on java [closed]

Tags:

People also ask

How do you draw a graph in Java?

In order to draw lines representing the x-axis and y-axis, we need four coordinates, i.e., x1, y1, x2, and y2. In our code, we use g1. draw() method to draw lines. We use the setpaint() method for setting the color of the points which we plot on the graph.

Does Java have a built in graph?

Usually, we implement graphs in Java using HashMap collection. HashMap elements are in the form of key-value pairs. We can represent the graph adjacency list in a HashMap. A most common way to create a graph is by using one of the representations of graphs like adjacency matrix or adjacency list.

Can you draw graphs on LaTeX?

We can now discuss the packages that we can use to draw graphs in LaTeX. The most common LaTeX package used for drawing, in general, is TikZ, which is a layer over PGF that simplifies its syntax.


I want to draw graphs (nodes and edges) in Java. However, since I don't know how to go about it, I would like to have some advice before starting.

How should I do this?

use Graphics2D package, right?

How about the labels for the nodes? should I use something like drawString and handle all the "centering" manually or create a JLabel for that? Can I put a JLabel on a Graphics2D environment?

I have searched but haven't found any simple implementation of this. If you know of one, please provide the link in your answer.

edit: The solution I am looking for should be able to remove nodes, drag nodes, edit labels, create nodes, all with mouse events.

Thanks.