use of javafx.collections.ObservableList in project Retrospector by NonlinearFruit.
the class StatsTabController method updateOverall.
private void updateOverall() {
// Constants
int last__days = DataManager.getPastDays();
// Graph Title
chartReviewsPerDay.setTitle("Past " + last__days + " Days");
// 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) {
boolean used = false;
for (Review r : m.getReviews()) {
if (strooleans.stream().anyMatch(x -> x.getString().equalsIgnoreCase(r.getUser()) && x.isBoolean())) {
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(), 0);
cat2Num.put(m.getCategory(), num + 1);
last30Days.put(r.getDate(), cat2Num);
}
info.accumulate(r);
used = true;
}
}
if (used) {
categories.put(m.getCategory(), categories.getOrDefault(m.getCategory(), 0) + 1);
info.accumulate(m);
for (Factoid f : m.getFactoids()) {
info.accumulate(f);
}
// media++;
}
}
if (overallContainer.getChildren().size() > 3)
overallContainer.getChildren().remove(2);
overallContainer.getChildren().add(2, info.getInfo());
// Chart # Media / Category
chartMediaPerCategory.setData(FXCollections.observableArrayList(Arrays.asList(DataManager.getCategories()).stream().map(c -> {
int count = categories.getOrDefault(c, 0);
PieChart.Data data = new PieChart.Data(c + " - " + count, count);
return data;
}).collect(Collectors.toList())));
for (PieChart.Data data : chartMediaPerCategory.getData()) {
String category = data.getName().substring(0, data.getName().indexOf(" - "));
int i = Arrays.asList(DataManager.getCategories()).indexOf(category);
data.getNode().setStyle("-fx-pie-color: " + colors[(i > 0 ? i : 0) % colors.length] + ";");
}
for (Node node : chartMediaPerCategory.lookupAll("Label.chart-legend-item")) {
Shape symbol = new Circle(5);
Label label = (Label) node;
String category = label.getText().substring(0, label.getText().indexOf(" - "));
int i = Arrays.asList(DataManager.getCategories()).indexOf(category);
symbol.setStyle("-fx-fill: " + colors[(i > 0 ? i : 0) % colors.length]);
label.setGraphic(symbol);
}
// Chart # Reviews / Day
ObservableList<XYChart.Series<String, Number>> 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);
for (Node node : chartReviewsPerDay.lookupAll("Label.chart-legend-item")) {
Shape symbol = new Rectangle(7, 7);
Label label = (Label) node;
String category = label.getText();
int i = Arrays.asList(DataManager.getCategories()).indexOf(category);
symbol.setStyle("-fx-fill: " + colors[(i > 0 ? i : 0) % colors.length]);
label.setGraphic(symbol);
}
for (XYChart.Series<String, Number> serie : chartReviewsPerDay.getData()) {
String category = serie.getName();
int i = Arrays.asList(DataManager.getCategories()).indexOf(category);
for (XYChart.Data<String, Number> data : serie.getData()) {
data.getNode().setStyle("-fx-background-color: " + colors[(i > 0 ? i : 0) % colors.length] + ";");
}
}
}
use of javafx.collections.ObservableList in project jphp by jphp-compiler.
the class UXTableView method update.
@Signature
public void update() {
ObservableList items = getWrappedObject().getItems();
getWrappedObject().setItems(null);
getWrappedObject().setItems(items);
getWrappedObject().setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
}
use of javafx.collections.ObservableList in project jphp by jphp-compiler.
the class UXList method offsetGet.
@Override
public Memory offsetGet(Environment environment, Memory... memories) {
ObservableList list = getWrappedObject();
int index = memories[0].toInteger();
return index >= 0 && index < list.size() ? wrap(environment, (T) list.get(index)) : Memory.NULL;
}
use of javafx.collections.ObservableList in project jphp by jphp-compiler.
the class UXList method offsetUnset.
@Override
public Memory offsetUnset(Environment environment, Memory... memories) {
ObservableList list = getWrappedObject();
int index = memories[0].toInteger();
if (index >= 0 && index < list.size()) {
list.remove(index);
}
return Memory.NULL;
}
use of javafx.collections.ObservableList in project jphp by jphp-compiler.
the class UXListView method update.
@Signature
@SuppressWarnings("unchecked")
public void update() {
ObservableList items = getWrappedObject().getItems();
getWrappedObject().setItems(null);
getWrappedObject().setItems(items);
}
Aggregations