use of javafx.scene.chart.PieChart.Data in project Gargoyle by callakrsos.
the class PMDViolationbyPieChartComposite method build.
/* (non-Javadoc)
* @see com.kyj.fx.voeditor.visual.component.pmd.chart.PMDViolationChartVisualable#build()
*/
@Override
public void build() {
Optional<Integer> reduce = observableHashMap.values().stream().reduce((a, b) -> a + b);
reduce.ifPresent(size -> {
total.set(size);
observableHashMap.entrySet().forEach(v -> {
String name = v.getKey().toString();
Integer value = v.getValue();
dataList.add(new Data(name, value));
});
});
// Integer size = reduce.get();
}
use of javafx.scene.chart.PieChart.Data in project VocabHunter by VocabHunter.
the class ProgressController method slice.
private Data slice(final I18nKey key, final ObservableNumberValue property) {
double value = property.getValue().intValue();
Data slice = new Data(i18nManager.text(key), value);
slice.pieValueProperty().bind(property);
return slice;
}
use of javafx.scene.chart.PieChart.Data in project Gargoyle by callakrsos.
the class PMDViolationbyPieChartComposite method createNode.
/* (non-Javadoc)
* @see com.kyj.fx.voeditor.visual.component.pmd.chart.PMDViolationChartVisualable#createNode()
*/
@Override
public Node createNode() {
picChart = new AttachedTextValuePieChart();
picChart.setLabelConverter(new StringConverter<PieChart.Data>() {
@Override
public String toString(PieChart.Data object) {
int value = (int) object.getPieValue();
double percent = (value * 100) / total.get();
return String.format("%s\ncount : %d\n%.2f%%", object.getName(), value, percent);
}
@Override
public PieChart.Data fromString(String string) {
// TODO Auto-generated method stub
return null;
}
});
picChart.setChartGraphicsCustomAction((data, node) -> {
chartGraphicsCustomAction(data, node);
});
dataList = picChart.getData();
return picChart;
}
use of javafx.scene.chart.PieChart.Data in project TeachingInSimulation by ScOrPiOzzy.
the class ResourceList method loadPieChart.
/**
* 加载饼图数据
*/
private void loadPieChart() {
String keyword = search.getText();
int picNum = picCheck.isSelected() ? action.countResourceByType(type, ResourceType.IMAGE.getType(), keyword, creator) : 0;
int swfNum = swfCheck.isSelected() ? action.countResourceByType(type, ResourceType.SWF.getType(), keyword, creator) : 0;
int videoNum = videoCheck.isSelected() ? action.countResourceByType(type, ResourceType.VIDEO.getType(), keyword, creator) : 0;
int txtNum = txtCheck.isSelected() ? action.countResourceByType(type, ResourceType.TXT.getType(), keyword, creator) : 0;
int wordNum = wordCheck.isSelected() ? action.countResourceByType(type, ResourceType.WORD.getType(), keyword, creator) : 0;
int pptNum = pptCheck.isSelected() ? action.countResourceByType(type, ResourceType.PPT.getType(), keyword, creator) : 0;
int excelNum = excelCheck.isSelected() ? action.countResourceByType(type, ResourceType.EXCEL.getType(), keyword, creator) : 0;
int pdfNum = pdfCheck.isSelected() ? action.countResourceByType(type, ResourceType.PDF.getType(), keyword, creator) : 0;
ObservableList<Data> datas = //
FXCollections.observableArrayList(//
new PieChart.Data(MsgUtil.getMessage("resource.pdf"), pdfNum), //
new PieChart.Data(MsgUtil.getMessage("resource.ppt"), pptNum), //
new PieChart.Data(MsgUtil.getMessage("resource.txt"), txtNum), //
new PieChart.Data(MsgUtil.getMessage("resource.excel"), excelNum), //
new PieChart.Data(MsgUtil.getMessage("resource.pic"), picNum), //
new PieChart.Data(MsgUtil.getMessage("resource.video"), videoNum), //
new PieChart.Data(MsgUtil.getMessage("resource.word"), wordNum), //
new PieChart.Data(MsgUtil.getMessage("resource.swf"), swfNum));
chart.setData(datas);
chart.setOnMouseMoved(e -> {
tip.setTranslateX(e.getX());
tip.setTranslateY(e.getY());
});
for (final PieChart.Data data : chart.getData()) {
Node node = data.getNode();
node.setOnMouseEntered(e -> {
tip.setText(data.getName() + ":" + (int) data.getPieValue());
tip.setVisible(true);
});
node.setOnMouseExited(e -> {
tip.setVisible(false);
});
}
pic.setText(MsgUtil.getMessage("resource.pic") + ":" + picNum);
swf.setText(MsgUtil.getMessage("resource.swf") + ":" + swfNum);
video.setText(MsgUtil.getMessage("resource.video") + ":" + videoNum);
txt.setText(MsgUtil.getMessage("resource.txt") + ":" + txtNum);
word.setText(MsgUtil.getMessage("resource.word") + ":" + wordNum);
ppt.setText(MsgUtil.getMessage("resource.ppt") + ":" + pptNum);
excel.setText(MsgUtil.getMessage("resource.excel") + ":" + excelNum);
pdf.setText(MsgUtil.getMessage("resource.pdf") + ":" + pdfNum);
}
use of javafx.scene.chart.PieChart.Data in project VocabHunter by VocabHunter.
the class ProgressController method buildChartResults.
private void buildChartResults(final ProgressModel model) {
Data known = slice(PROGRESS_SLICE_KNOWN, model.knownProperty());
Data unknown = slice(PROGRESS_SLICE_UNKNOWN, model.unknownProperty());
Data unmarked = slice(PROGRESS_SLICE_UNMARKED, model.unseenUnfilteredProperty());
Data filtered = slice(PROGRESS_SLICE_FILTERED, model.unseenFilteredProperty());
chartResults.setData(FXCollections.observableArrayList(known, unknown, unmarked, filtered));
bindValueLabel(labelValueKnown, model.knownProperty());
bindPercentLabel(labelPercentKnown, model.knownPercentProperty());
bindValueLabel(labelValueUnknown, model.unknownProperty());
bindPercentLabel(labelPercentUnknown, model.unknownPercentProperty());
bindValueLabel(labelValueUnseenUnfiltered, model.unseenUnfilteredProperty());
bindPercentLabel(labelPercentUnseenUnfiltered, model.unseenUnfilteredPercentProperty());
bindValueLabel(labelValueFiltered, model.unseenFilteredProperty());
bindPercentLabel(labelPercentFiltered, model.unseenFilteredPercentProperty());
}
Aggregations