0
我创建了一个ListView,它根据对象字段动态绘制一个特定颜色的圆。单元格可以有三个状态,导出,具有必填信息,也没有。前两个他们有自己的圆圈颜色,我想“没有任何一个”来实现他们的图形两个圆圈。问题是你只能为单元格设置一个图形。如何创建一个带有两个圆圈的形状?
我试图找到一种解决方法,通过改变圆的的centerX和他们两个用Shape.union,但只显示circEx。有什么办法可以实现这个吗?
listView.setCellFactory(new Callback<ListView<BusinessCard>, ListCell<BusinessCard>>(){
@Override
public ListCell<BusinessCard> call(ListView<BusinessCard> list){
return new ColorCell();
}
});
//Colors circled that indicates status of card on listView
static class ColorCell extends ListCell<BusinessCard> {
@Override
public void updateItem(BusinessCard item, boolean empty) {
super.updateItem(item, empty);
//Probably should have one circle and setFil in if statements
Circle circMan = new Circle(0,0,3,Color.web("#ff9999"));
Circle circEx = new Circle(10,0,3,Color.web("#808080")); // old #e1eaea
Circle circDone = new Circle(0,0,3,Color.web("#99ff99")); //old #99ff99
if(item != null){
setTextFill(Color.BLACK);
setText(item.toString());
if(item.wasExported() && !item.hasMand()){
setGraphic(Shape.union(circMan, circEx)); //TODO
}
else if(item.wasExported()){
setGraphic(circEx);
}
else if(!item.hasMand()){
setGraphic(circMan);
}
else{
setGraphic(circDone);
}
}
}
}
你能制作一个半圈的颜色吗? – trashgod
嗯,我,看看我是否能有两个圆弧,并创建两个联盟之间的形状虽然我想这两个圆我想这将不得不这样做。 – Javant