我正在尝试根据与一个数据库相关的条件来自定义边缘。但我无法得到正确的输出。我尝试过以下代码。
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;
}
};
关于java - 在 JUNG 中自定义边缘颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32179186/