use of javafx.collections.ObservableList in project trex-stateless-gui by cisco-system-traffic-generator.
the class RecordController method handleOnRecorderReceived.
private void handleOnRecorderReceived(WorkerStateEvent workerStateEvent) {
List<CaptureInfo> monitors = recorderService.getValue();
ObservableList<Recorder> currentRecorders = activeRecorders.getItems();
monitors.stream().filter(monitor -> {
final String mode = monitor.getMode();
if (mode == null)
return false;
final boolean isModeSuitable = mode.equalsIgnoreCase("fixed") || mode.equalsIgnoreCase("cyclic");
return isModeSuitable && monitor.getId() != pktCaptureService.getCurrentActiveMonitorId();
}).map(this::captureInfo2Recorder).collect(toList()).forEach(newRecorder -> {
Optional<Recorder> existed = currentRecorders.stream().filter(recorder -> recorder.getId() == newRecorder.getId()).findFirst();
if (existed.isPresent()) {
Recorder recorder = existed.get();
recorder.setBytes(newRecorder.getBytes());
recorder.setPackets(newRecorder.getPackets());
recorder.setStatus(newRecorder.getStatus());
} else {
currentRecorders.add(newRecorder);
}
});
currentRecorders.removeIf(recorder -> !monitors.stream().anyMatch(newRecorder -> newRecorder.getId() == recorder.getId()));
}
use of javafx.collections.ObservableList in project jgnash by ccavanaugh.
the class IncomeExpensePayeePieChartDialogController method updateCharts.
private void updateCharts() {
final Account account = accountComboBox.getValue();
if (account != null) {
final ObservableList<PieChart.Data>[] chartData = createPieDataSet(account);
creditPieChart.setData(chartData[CREDIT]);
debitPieChart.setData(chartData[DEBIT]);
final NumberFormat numberFormat = NumericFormats.getFullCommodityFormat(account.getCurrencyNode());
// Calculate the totals for percentage value
final double creditTotal = chartData[CREDIT].parallelStream().mapToDouble(PieChart.Data::getPieValue).sum();
final double debitTotal = chartData[DEBIT].parallelStream().mapToDouble(PieChart.Data::getPieValue).sum();
final NumberFormat percentFormat = NumberFormat.getPercentInstance();
percentFormat.setMaximumFractionDigits(1);
percentFormat.setMinimumFractionDigits(1);
// Install tooltips on the data after it has been added to the chart
creditPieChart.getData().forEach(data -> Tooltip.install(data.getNode(), new Tooltip((data.getNode().getUserData() + "\n" + numberFormat.format(data.getPieValue()) + "(" + percentFormat.format(data.getPieValue() / creditTotal)) + ")")));
// Install tooltips on the data after it has been added to the chart
debitPieChart.getData().forEach(data -> Tooltip.install(data.getNode(), new Tooltip(((data.getNode().getUserData()) + "\n" + numberFormat.format(data.getPieValue()) + "(" + percentFormat.format(data.getPieValue() / debitTotal)) + ")")));
creditPieChart.centerSubTitleProperty().set(numberFormat.format(creditTotal));
debitPieChart.centerSubTitleProperty().set(numberFormat.format(debitTotal));
} else {
creditPieChart.setData(FXCollections.emptyObservableList());
creditPieChart.setTitle("No Data");
debitPieChart.setData(FXCollections.emptyObservableList());
debitPieChart.setTitle("No Data");
}
}
use of javafx.collections.ObservableList in project POL-POM-5 by PlayOnLinux.
the class EnginesView method createEngineSubCategoryTabs.
private ObservableList<Tab> createEngineSubCategoryTabs(EngineSidebar sidebar) {
// initialize the engines sub category panels
final MappedList<List<EngineSubCategoryPanel>, EngineCategoryDTO> engineSubCategoryPanelGroups = new MappedList<>(this.engineCategories, engineCategory -> engineCategory.getSubCategories().stream().map(engineSubCategory -> {
final EngineSubCategoryPanel engineSubCategoryPanel = new EngineSubCategoryPanel();
engineSubCategoryPanel.setEngineCategory(engineCategory);
engineSubCategoryPanel.setEngineSubCategory(engineSubCategory);
engineSubCategoryPanel.setEnginesPath(this.enginesPath);
engineSubCategoryPanel.setFilter(this.filter);
engineSubCategoryPanel.setEngine(this.engines.get(engineCategory.getName().toLowerCase()));
engineSubCategoryPanel.selectedListWidgetProperty().bind(sidebar.selectedListWidgetProperty());
engineSubCategoryPanel.setOnEngineSelect(this::showEngineDetails);
return engineSubCategoryPanel;
}).collect(Collectors.toList()));
final ConcatenatedList<EngineSubCategoryPanel> engineSubCategoryPanels = ConcatenatedList.create(engineSubCategoryPanelGroups);
final FilteredList<EngineSubCategoryPanel> filteredEngineSubCategoryPanels = engineSubCategoryPanels.sorted(Comparator.comparing(engineSubCategoryPanel -> engineSubCategoryPanel.getEngineSubCategory().getName())).filtered(this.filter::filter);
filteredEngineSubCategoryPanels.predicateProperty().bind(Bindings.createObjectBinding(() -> this.filter::filter, this.filter.searchTermProperty(), this.filter.showInstalledProperty(), this.filter.showNotInstalledProperty()));
// map the panels to tabs
return new MappedList<>(filteredEngineSubCategoryPanels, engineSubCategoryPanel -> new Tab(engineSubCategoryPanel.getEngineSubCategory().getDescription(), engineSubCategoryPanel));
}
use of javafx.collections.ObservableList in project POL-POM-5 by PlayOnLinux.
the class LibraryFeaturePanelSkin method createCombinedListWidget.
private CombinedListWidget<ShortcutDTO> createCombinedListWidget() {
final FilteredList<ShortcutDTO> filteredShortcuts = ConcatenatedList.create(new MappedList<>(getControl().getCategories().sorted(Comparator.comparing(ShortcutCategoryDTO::getName)), ShortcutCategoryDTO::getShortcuts)).filtered(getControl().getFilter()::filter);
filteredShortcuts.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty(), getControl().getFilter().selectedShortcutCategoryProperty()));
final SortedList<ShortcutDTO> sortedShortcuts = filteredShortcuts.sorted(Comparator.comparing(shortcut -> shortcut.getInfo().getName()));
final ObservableList<ListWidgetElement<ShortcutDTO>> listWidgetEntries = new MappedList<>(sortedShortcuts, ListWidgetElement::create);
final CombinedListWidget<ShortcutDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
// bind direction: controller property -> skin property
getControl().selectedShortcutProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
combinedListWidget.select(newValue);
} else {
combinedListWidget.deselect();
}
});
// bind direction: skin property -> controller properties
combinedListWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
final ShortcutDTO selectedItem = newValue.getItem();
final MouseEvent event = newValue.getEvent();
getControl().setSelectedShortcut(selectedItem);
getControl().setOpenedDetailsPanel(new ShortcutInformation(selectedItem));
if (event.getClickCount() == 2) {
getControl().runShortcut(selectedItem);
}
} else {
getControl().setSelectedShortcut(null);
getControl().setOpenedDetailsPanel(new None());
}
});
return combinedListWidget;
}
use of javafx.collections.ObservableList in project Retrospector by NonlinearFruit.
the class OverallSectionController method update.
protected void update(List<Media> allMedia) {
// Constants
int last__days = 20;
// Data Mining - Vars
Map<String, Integer> categories = new HashMap<>();
Map<LocalDate, Map<String, Integer>> last30Days = new HashMap<>();
InfoBlipAccumulator info = new InfoBlipAccumulator();
// Data Mining - Calcs
for (Media m : allMedia) {
categories.put(m.getCategory(), categories.getOrDefault(m.getCategory(), 0) + 1);
info.accumulate(m);
for (Review r : m.getReviews()) {
if (ChronoUnit.DAYS.between(r.getDate(), LocalDate.now()) <= last__days) {
Map<String, Integer> cat2Num = last30Days.getOrDefault(r.getDate(), new HashMap<>());
Integer num = cat2Num.getOrDefault(m.getCategory(), 1);
cat2Num.put(m.getCategory(), num + 1);
last30Days.put(r.getDate(), cat2Num);
}
info.accumulate(r);
}
}
// Stats
statsBox.getChildren().clear();
statsBox.getChildren().add(info.getInfo());
// Chart # Media / Category
chartMediaPerCategory.setData(FXCollections.observableArrayList(Arrays.asList(DataManager.getCategories()).stream().map(c -> {
int count = categories.getOrDefault(c, 0);
return new PieChart.Data(c + " - " + count, count);
}).collect(Collectors.toList())));
// Chart # Reviews / Day
ObservableList list = FXCollections.observableArrayList();
LocalDate now = LocalDate.now();
for (String category : DataManager.getCategories()) {
XYChart.Series data = new XYChart.Series();
data.setName(category);
for (int i = last__days; i > -1; i--) {
LocalDate target = now.minusDays(i);
int count = last30Days.getOrDefault(target, new HashMap<>()).getOrDefault(category, 0);
String key = target.getDayOfMonth() + "";
data.getData().add(new XYChart.Data(key, count));
}
list.add(data);
}
chartReviewsPerDay.setData(list);
}
Aggregations