Search code examples
javamysqlsqlitejungjung2

Customizing edge colour in JUNG


I am trying to customize the edge based on the condition which is related to one database. But i couldn't get the proper output. Ive tried the bellow code.

Transformer<String, Paint> edgePaint = new Transformer<String, Paint>() {
        public Paint transform(String s) {
            connection = connection1.dbConnector(); // graph
            try {
                String qr = "select Inter from gene1 where Disease='Breast Neoplasms'";
                PreparedStatement pest = connection.prepareStatement(qr);
                ResultSet rs = pest.executeQuery();
                while (rs.next()) {
                    // for (j = 0; j <= 1; j++) {
                    name2[j] = rs.getString("Inter");}
                    for (j = 0; j <= 30; j++) {
                        if (name2[j] == "direct")

                            return Color.CYAN;
                        else
                            return Color.BLUE;

                }
                rs.close();
                pest.close();
            } catch (Exception e1) {
                // JOptionPane.showMessageDialog(null, e1);

            }
            return null;
        }
    };

Can anyone help me with this


Solution

  • Ive tried the following code and i got the required output(different edge colours).

    Transformer<Edge, Paint> edgePaint = new Transformer<Edge, Paint>() {
            public Paint transform(Edge s) {
                if (s.toString().equals("Inter"))
                    return Color.RED;
                else
                    return null;
            }
        };