use of javafx.scene.shape.Shape 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.scene.shape.Shape in project aima-java by aimacode.
the class MapEnvironmentViewCtrl method update.
protected void update() {
envStateView.getChildren().clear();
if (env != null) {
double scale = adjustTransform();
Map map = env.getMap();
// print connections
for (String loc1 : map.getLocations()) {
Point2D pt1 = map.getPosition(loc1);
for (String loc2 : map.getPossibleNextLocations(loc1)) {
Point2D pt2 = map.getPosition(loc2);
Shape line = new Line(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
line.setStroke(Color.LIGHTGRAY);
envStateView.getChildren().add(line);
}
}
// print track of first agent
if (!env.getAgents().isEmpty()) {
String aLoc = env.getAgentLocation(env.getAgents().get(0));
if (track.isEmpty() || !Objects.equals(track.get(track.size() - 1), aLoc))
track.add(aLoc);
for (int i = 1; i < track.size(); i++) {
Point2D pt1 = map.getPosition(track.get(i - 1));
Point2D pt2 = map.getPosition(track.get(i));
Shape line = new Line(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
line.setStroke(Color.RED);
line.setStrokeWidth(2);
envStateView.getChildren().add(line);
}
}
// print locations
for (String loc : map.getLocations()) {
Point2D point = map.getPosition(loc);
Text text = new Text(point.getX() + 10 / scale, point.getY(), loc);
text.setFont(new Font(12.0 / scale));
envStateView.getChildren().add(text);
envStateView.getChildren().add(new Circle(point.getX(), point.getY(), 2 / scale));
}
// print agent locations
for (Agent agent : env.getAgents()) {
String loc = env.getAgentLocation(agent);
if (loc != null) {
Point2D pt = map.getPosition(loc);
envStateView.getChildren().add(new Circle(pt.getX(), pt.getY(), 8 / scale, Color.RED));
}
}
// print goal
if (goal != null) {
Point2D pt = map.getPosition(goal);
envStateView.getChildren().add(new Circle(pt.getX(), pt.getY(), 6 / scale, Color.GREEN));
}
}
}
use of javafx.scene.shape.Shape in project jphp by jphp-compiler.
the class UXPathAnimation method path.
protected Path path() {
Shape path = getWrappedObject().getPath();
if (path == null) {
path = new Path();
getWrappedObject().setPath(path);
}
return (Path) path;
}
use of javafx.scene.shape.Shape in project OTP2_R6_svaap by JNuutinen.
the class Unit method equipComponent.
/**
* Kiinnittää komponentin Unittiin.
* @param component Komponentti, joka lisätään.
*/
public void equipComponent(Component component) {
Shape shape = component.getShape();
shape.setLayoutY(component.getyOffset());
shape.setLayoutX(component.getxOffset());
this.getChildren().add(component.getShape());
setTag(getTag());
}
use of javafx.scene.shape.Shape in project Gargoyle by callakrsos.
the class FxControlsTreeItem method createNode.
/**
* 파일 트리를 생성하기 위한 노드를 반환한다.
*
* @Date 2015. 10. 14.
* @param f
* @return
* @User KYJ
*/
public TreeItem<Node> createNode(final Node f) {
TreeItem<Node> treeItem = new TreeItem<Node>(f) {
private boolean isLeaf;
private boolean isFirstTimeChildren = true;
private boolean isFirstTimeLeaf = true;
@Override
public ObservableList<TreeItem<Node>> getChildren() {
if (isFirstTimeChildren) {
isFirstTimeChildren = false;
super.getChildren().setAll(buildChildren(this));
}
return super.getChildren();
}
@Override
public boolean isLeaf() {
if (isFirstTimeLeaf) {
isFirstTimeLeaf = false;
Node f = getValue();
if (f == null) {
isLeaf = true;
} else if (f instanceof Control) {
isLeaf = ((Control) f).getChildrenUnmodifiable().isEmpty();
} else if (f instanceof Parent) {
isLeaf = ((Parent) f).getChildrenUnmodifiable().isEmpty();
} else if (f instanceof Shape)
isLeaf = true;
else
isLeaf = false;
}
return isLeaf;
}
private ObservableList<TreeItem<Node>> buildChildren(TreeItem<Node> treeItem) {
Node f = treeItem.getValue();
if (f == null) {
return FXCollections.emptyObservableList();
}
treeItem.setGraphic(new HBox(/* new CheckBox(), */
getImage(getName(f))));
List<Node> childrens = getChildrens(f);
if (childrens == null || childrens.isEmpty()) {
return FXCollections.emptyObservableList();
} else {
ObservableList<TreeItem<Node>> children = FXCollections.observableArrayList();
for (Node child : childrens) {
children.add(createNode(child));
}
return children;
}
}
};
treeItem.setGraphic(new HBox(/* new CheckBox(), */
getImage(getName(f))));
return treeItem;
}
Aggregations