use of javafx.scene.chart.PieChart.Data in project VocabHunter by VocabHunter.
the class ProgressController method slice.
private Data slice(final String name, final ObservableNumberValue property) {
double value = property.getValue().intValue();
Data slice = new Data(name, value);
slice.pieValueProperty().bind(property);
return slice;
}
use of javafx.scene.chart.PieChart.Data in project TeachingInSimulation by ScOrPiOzzy.
the class TeacherQuestionPaper method loadChart.
private void loadChart(int qid) {
Map<AnswerState, Integer> statistics = SpringUtil.getBean(LibraryAnswerAction.class).statisticsByQuestionId(pid, qid);
Integer undo = statistics.get(AnswerState.ANSWER_STATE_UNDO);
Integer wrong = statistics.get(AnswerState.ANSWER_STATE_WRONG);
Integer corrected = statistics.get(AnswerState.ANSWER_STATE_CORRECTED);
Integer right = statistics.get(AnswerState.ANSWER_STATE_RIGHT);
int total = undo + wrong + corrected + right;
ObservableList<Data> datas = //
FXCollections.observableArrayList(//
new PieChart.Data(MsgUtil.getMessage("answer.undo"), undo), //
new PieChart.Data(MsgUtil.getMessage("answer.wrong"), wrong + corrected), //
new PieChart.Data(MsgUtil.getMessage("answer.right"), right));
chart.setData(datas);
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);
});
}
if (total == 0) {
rate.setText(MsgUtil.getMessage("answer.rate", 0));
} else {
rate.setText(MsgUtil.getMessage("answer.rate", MathUtil.round(2, right * 100f / total)));
}
}
use of javafx.scene.chart.PieChart.Data in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionPaper method loadQuestions.
private void loadQuestions() {
this.paper.getChildren().clear();
List<Question> choices = loadQuestionsByType(QuestionType.CHOICE);
List<Question> judgments = loadQuestionsByType(QuestionType.JUDGMENT);
List<Question> blanks = loadQuestionsByType(QuestionType.BLANK);
List<Question> subjectives = loadQuestionsByType(QuestionType.SUBJECTIVE);
List<Question> questions = new ArrayList<>();
questions.addAll(choices);
questions.addAll(judgments);
questions.addAll(blanks);
questions.addAll(subjectives);
for (int i = 0; i < questions.size(); i++) {
int index = i + 1;
Question question = questions.get(i);
PreviewQuestionItem item = new PreviewQuestionItem(index, QuestionType.getQuestionType(question.getType()), question, showReference);
paper.getChildren().add(item);
}
ObservableList<Data> datas = //
FXCollections.observableArrayList(//
new PieChart.Data(MsgUtil.getMessage("question.choice"), choices.size()), //
new PieChart.Data(MsgUtil.getMessage("question.judgment"), judgments.size()), //
new PieChart.Data(MsgUtil.getMessage("question.blank"), blanks.size()), //
new PieChart.Data(MsgUtil.getMessage("question.subjective"), subjectives.size()));
chart.setData(datas);
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);
});
}
}
use of javafx.scene.chart.PieChart.Data in project Gargoyle by callakrsos.
the class SvnChagnedCodeComposite method initialize.
@FXML
public void initialize() {
createContextMenu();
Collection<SVNLogEntry> allLogs = supplier.getAllLogs();
LOGGER.debug("Log Count : {}", allLogs.size());
String dateString = supplier.getStart().toDateString();
String dateString2 = supplier.getEnd().toDateString();
piChartChagendCode.setTitle(String.format("Chaned Code Count ( Rank %d )\n%s ~ %s", supplier.getRankSize(), dateString, dateString2));
// collectedTable = supplier.createStream(allLogs).collect(Collectors.groupingBy(v -> v.getPath()));
Map<String, Long> collect = supplier.createStream(allLogs).collect(Collectors.groupingBy(v -> v.getPath(), LinkedHashMap::new, Collectors.counting()));
dataList = collect.entrySet().stream().sorted((o1, o2) -> {
return -Long.compare(o1.getValue(), o2.getValue());
}).map(v -> new Data(v.getKey(), v.getValue())).limit(supplier.getRankSize()).collect(Collectors.toList());
piChartChagendCode.getData().addAll(dataList);
Set<Node> lookupAll = piChartChagendCode.lookupAll(".chart-pie-label");
for (Data d : piChartChagendCode.getData()) {
Node node = d.getNode();
Tooltip.install(node, new Tooltip(String.format("Source Code : %s\nModify Count:%d", d.getName(), (int) d.getPieValue())));
node.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> {
dataOnMouseClick(e, d);
e.consume();
});
/*animation effect. */
node.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, ev -> {
Platform.runLater(() -> node.setStyle("-fx-background-color:derive(-fx-color,-5%);"));
});
/*animation effect. */
node.addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, ev -> {
Platform.runLater(() -> node.setStyle(null));
});
}
lookupAll.stream().map(v -> (Text) v).forEach(v -> {
String text = v.getText();
String displayText = text;
int count = supplier.getCollectedTable().get(displayText).size();
int textLength = displayText.length();
if (textLength > 15) {
displayText = "... " + displayText.substring(textLength - 15);
Tooltip.install(v, new Tooltip(text));
}
displayText = displayText.concat(" [").concat(String.valueOf(count)).concat("]");
v.setText(displayText);
});
// Platform.runLater(() -> {
// this.getScene().addEventFilter(KeyEvent.KEY_PRESSED, this::sceneOnKeyPressed);
// });
}
use of javafx.scene.chart.PieChart.Data in project Gargoyle by callakrsos.
the class SvnChagnedCodeComposite method createContextMenu.
/**
* 차트 위치를 복구하는 기능을 처리.
*
* @작성자 : KYJ
* @작성일 : 2016. 7. 20.
* @param e
*/
// public void sceneOnKeyPressed(KeyEvent e) {
// if (e.getCode() == KeyCode.ESCAPE) {
//
// setRight(null);
// e.consume();
// }
// }
/**
* @작성자 : KYJ
* @작성일 : 2016. 7. 20.
*/
private void createContextMenu() {
MenuItem miViewHistory = new MenuItem("View History");
miViewHistory.setOnAction(ev -> {
Node ownerNode = contextMenu.getOwnerNode();
System.out.println(ownerNode);
Node center = getCenter();
if ((ownerNode != null && ownerNode instanceof Region) && (center != null && center == piChartChagendCode)) {
Data userData = (Data) contextMenu.getUserData();
if (userData != null) {
String relativePath = userData.getName();
ListView<GargoyleSVNLogEntryPath> createHistoryListView = supplier.createHistoryListView(relativePath);
FxUtil.showPopOver(ownerNode, createHistoryListView);
}
}
});
contextMenu = new ContextMenu(miViewHistory);
}
Aggregations