use of retrospector.model.Media in project Retrospector by NonlinearFruit.
the class MediaSectionController method updateMedia.
private void updateMedia() {
// Media Filtering
Boolean title = checkTitle.isSelected();
Boolean creator = checkCreator.isSelected();
Boolean season = checkSeason.isSelected();
Boolean episode = checkEpisode.isSelected();
Boolean category = checkCategory.isSelected();
// Filter Table
mediaTableFilter.setPredicate(m -> ((checkTitle.isSelected() && currentMedia.getTitle().equals(((Media) m).getTitle())) || !checkTitle.isSelected()) && ((checkCreator.isSelected() && currentMedia.getCreator().equals(((Media) m).getCreator())) || !checkCreator.isSelected()) && ((checkSeason.isSelected() && currentMedia.getSeasonId().equals(((Media) m).getSeasonId())) || !checkSeason.isSelected()) && ((checkEpisode.isSelected() && currentMedia.getEpisodeId().equals(((Media) m).getEpisodeId())) || !checkEpisode.isSelected()) && ((checkCategory.isSelected() && currentMedia.getCategory().equals(((Media) m).getCategory())) || !checkCategory.isSelected()));
// Data Mining - Vars
XYChart.Series data = new XYChart.Series();
InfoBlipAccumulator info = new InfoBlipAccumulator();
// Data Mining - Calcs
for (Media m : mediaTable.getItems()) {
info.accumulate(m);
for (Review r : m.getReviews()) {
data.getData().add(new XYChart.Data(dateToDouble(r.getDate()), r.getRating().intValue()));
info.accumulate(r);
}
}
// Stats
statsBox.getChildren().clear();
statsBox.getChildren().add(info.getInfo());
// Chart
chartRatingOverTime.getData().clear();
if (data.getData().size() < 1500)
chartRatingOverTime.getData().add(data);
chartRotX.setLowerBound(dateToDouble(info.getEarliest()) - 1.0 / 12);
chartRotX.setUpperBound(dateToDouble(LocalDate.now()) + 1.0 / 12);
}
use of retrospector.model.Media 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);
}
use of retrospector.model.Media in project Retrospector by NonlinearFruit.
the class SearchTabController method isMatchForMedia.
private boolean isMatchForMedia(String query, Media media) {
boolean pass = true;
if (query.endsWith("|") && !query.endsWith("||"))
query = query.substring(0, query.length() - 1);
String[] queries = query.toLowerCase().split(":");
List<String> searchables = new ArrayList<>();
searchables.addAll(Arrays.asList(media.getTitle().toLowerCase(), media.getCreator().toLowerCase(), media.getSeasonId().toLowerCase(), media.getEpisodeId().toLowerCase(), media.getCategory().toLowerCase()));
for (Factoid fact : media.getFactoids()) {
searchables.add(fact.getContent().toLowerCase());
}
for (String q : queries) {
String[] optns = q.split("\\|\\|");
boolean minorPass = false;
for (String optn : optns) {
boolean negator = optn.length() > 1 && optn.startsWith("!");
if (!negator && searchables.stream().anyMatch(s -> s.contains(optn)))
minorPass = true;
if (negator && !searchables.stream().anyMatch(s -> s.contains(optn.substring(1))))
minorPass = true;
}
if (!minorPass) {
pass = false;
}
}
return pass;
}
use of retrospector.model.Media in project Retrospector by NonlinearFruit.
the class SearchTabController method updateStats.
private void updateStats() {
int totalNumberReviews = 0;
int totalNumberMedia = 0;
int totalReviewRating = 0;
int totalCurrentRating = 0;
totalNumberMedia = searchTable.getItems().size();
for (Media media : searchTable.getItems()) {
totalNumberReviews += media.getReviews().size();
for (Review review : media.getReviews()) {
totalReviewRating += review.getRating().intValue();
}
totalCurrentRating += media.getCurrentRating().intValue();
}
searchResults.setText(totalNumberMedia + "");
searchMeanAverage.setText(String.format("%.2f", totalReviewRating * 1.0 / totalNumberReviews));
searchCurrentAverage.setText(String.format("%.2f", totalCurrentRating * 1.0 / totalNumberMedia));
}
use of retrospector.model.Media in project Retrospector by NonlinearFruit.
the class Dumpster method getRandomMedia.
public static Media getRandomMedia(int numOfReviews) {
Media m = new Media();
String[] uuid = UUID.randomUUID().toString().split("-");
m.setTitle(uuid[0]);
m.setCreator(uuid[1]);
if (random.nextBoolean()) {
m.setEpisodeId(uuid[2]);
if (random.nextBoolean()) {
m.setSeasonId(uuid[3]);
m.setType(Media.Type.SERIES);
}
m.setType(Media.Type.MINISERIES);
} else {
m.setType(Media.Type.SINGLE);
}
m.setCategory(DataManager.getCategories()[random.nextInt(DataManager.getCategories().length)]);
for (int i = 0; i < numOfReviews; i++) {
m.getReviews().add(getRandomReview());
}
return m;
}
Aggregations