在 JUNG 中自定义边缘颜色

Customizing edge colour in JUNG

我正在尝试根据与一个数据库相关的条件自定义边缘。但我无法获得正确的输出。我试过下面的代码。

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;
        }
    };

谁能帮我解决这个问题

我试过下面的代码,我得到了所需的输出(不同的边缘颜色)。

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