Je travaille sur GraphStream en affichant des données de la base de données. Mais il crée des nœuds et des bords très lents. J'utilise this exemple très basique.Noeud de rendu GraphStream et bords lents
Voici mon code:
public class GraphExplore {
static Connection conn2;
static String result, result2;
static JFrame frame;
static JPanel panel;
static int totalRows, i;
public static void main(String args[]) throws SQLException {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
showData();
} catch (SQLException e) {
e.printStackTrace();
}
}
});
}
private static void showData() throws SQLException {
frame = new JFrame("GRAPH TESTING");
Graph graph = new SingleGraph("tutorial 1");
graph.setAutoCreate(true);
graph.setStrict(false);
graph.display();
try {
Class.forName("org.h2.Driver");
conn2 = DriverManager.getConnection("jdbc:h2:file:G:/hs_data/h2_db/test", "sa", "sa");
} catch (Exception e) {
e.printStackTrace();
}
Statement stmt2 = conn2.createStatement();
ResultSet rs = stmt2.executeQuery("SELECT count(*) FROM cdr");
while (rs.next()) {
totalRows = rs.getInt(1);
}
ResultSet rs2 = stmt2.executeQuery("SELECT ANUMBER,BNUMBER FROM CDR LIMIT 20");
while (rs2.next()) {
result = rs2.getString("ANUMBER");
result2 = rs2.getString("BNUMBER");
graph.addNode(result);
graph.addNode(result2);
for (i = 0; i < totalRows; i++)
graph.addEdge("string" + i, result, result2);
}
for (Node node : graph) {
node.addAttribute("ui.label", node.getId());
}
// graph.addAttribute("ui.stylesheet", "graph { fill-color: red; }");text-mode:
// hidden;
graph.addAttribute("ui.stylesheet", "node {size: 12px;fill-color: #ff0000;z-index: 0;}");
graph.addAttribute("ui.stylesheet", "edge { shape:line ; fill-color: #222;}");
conn2.close();
}
}
Pour l'instant, je suis juste en utilisant 20 lignes et il prend 3-4 secondes. Mais j'ai besoin de montrer plus de disques (peut-être plus de 1 million) à la fois. Quelqu'un peut-il me dire comment puis-je augmenter la vitesse de rendu?