javajungjung2

setToolTip in JUNG for several vertices


I have nearly 36 vertiecs in one graph.I would like to insert tooltip box for each and every vertices. I have to show further information about the vertices with the help of tooltip box.

 vv.setToolTipText("<html><center>Breast Neoplasms<p>"+ "Gene interactions</p> </center></html>");

The above code is for displaying general information. But i need tooltip for every vertices in my graph. Can anyone help me with this?


Solution

  • I got the required output uisng the following code.

      vv.setVertexToolTipTransformer(new Transformer<String, String>() {
            public String transform(String v) {
    
            //  i=0;
                try {
    
                     String bb = "SELECT * FROM interr";
                    Statement pest = connection.createStatement();
                    ResultSet v1 = pest.executeQuery(bb);   
                    while(v1.next())
                        if(v.toString().equals(v1.getString("Mole1")))
                     na[i] = v1.getString("Pubchem_ID");
                    System.out.println(na[i]);
                    v=na[i].toString();
                    return "PUBMED:"+v.toString();
                }
            catch (Exception e1) {
                JOptionPane.showMessageDialog(null, e1);
    
            }
                return null;
    
            }
        });