Search in sources :

Example 1 with Rectangle

use of javafx.scene.shape.Rectangle 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] + ";");
        }
    }
}
Also used : Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) ListView(javafx.scene.control.ListView) StackedBarChart(javafx.scene.chart.StackedBarChart) URL(java.net.URL) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) Factoid(retrospector.model.Factoid) XYChart(javafx.scene.chart.XYChart) VBox(javafx.scene.layout.VBox) ArrayList(java.util.ArrayList) Media(retrospector.model.Media) HashSet(java.util.HashSet) LineChart(javafx.scene.chart.LineChart) ResourceBundle(java.util.ResourceBundle) Map(java.util.Map) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) NaturalOrderComparator(retrospector.util.NaturalOrderComparator) Circle(javafx.scene.shape.Circle) HBox(javafx.scene.layout.HBox) ObjectProperty(javafx.beans.property.ObjectProperty) Label(javafx.scene.control.Label) Review(retrospector.model.Review) Node(javafx.scene.Node) Set(java.util.Set) Rectangle(javafx.scene.shape.Rectangle) CategoryAxis(javafx.scene.chart.CategoryAxis) BarChart(javafx.scene.chart.BarChart) Collectors(java.util.stream.Collectors) ChoiceBox(javafx.scene.control.ChoiceBox) TAB(retrospector.fxml.CoreController.TAB) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Text(javafx.scene.text.Text) PieChart(javafx.scene.chart.PieChart) Stroolean(retrospector.util.Stroolean) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) LocalDate(java.time.LocalDate) ObservableList(javafx.collections.ObservableList) NumberAxis(javafx.scene.chart.NumberAxis) DataManager(retrospector.model.DataManager) Shape(javafx.scene.shape.Shape) Shape(javafx.scene.shape.Shape) HashMap(java.util.HashMap) Node(javafx.scene.Node) Label(javafx.scene.control.Label) Rectangle(javafx.scene.shape.Rectangle) Review(retrospector.model.Review) LocalDate(java.time.LocalDate) PieChart(javafx.scene.chart.PieChart) Factoid(retrospector.model.Factoid) Circle(javafx.scene.shape.Circle) Media(retrospector.model.Media) XYChart(javafx.scene.chart.XYChart) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with Rectangle

use of javafx.scene.shape.Rectangle in project Malai by arnobl.

the class MoveRectHelpAnimation method createTransition.

@Override
public Transition createTransition() {
    final Transition transition = super.createTransition();
    final Rectangle rec = new Rectangle(110d, 70d);
    helpPane.getChildren().add(rec);
    rec.toBack();
    rec.setFocusTraversable(false);
    rec.setMouseTransparent(true);
    rec.setFill(Color.LIGHTGRAY);
    rec.setStroke(Color.GRAY);
    rec.xProperty().bind(ell.centerXProperty().subtract(rec.getWidth() / 2d));
    rec.yProperty().bind(ell.centerYProperty().subtract(rec.getHeight() / 2d));
    rec.visibleProperty().bind(ell.visibleProperty());
    return transition;
}
Also used : Transition(javafx.animation.Transition) Rectangle(javafx.scene.shape.Rectangle)

Example 3 with Rectangle

use of javafx.scene.shape.Rectangle in project Malai by arnobl.

the class MoveShape method start.

@Override
public void start(Stage stage) {
    widget1 = new Pane();
    widget2 = new Pane();
    widget1.setPrefWidth(400d);
    widget1.setPrefHeight(400d);
    widget2.setPrefWidth(400d);
    widget2.setPrefHeight(400d);
    rec = new Rectangle(100d, 100d, 70d, 50d);
    widget1.getChildren().addAll(rec);
    super.start(stage);
}
Also used : Rectangle(javafx.scene.shape.Rectangle) Pane(javafx.scene.layout.Pane)

Example 4 with Rectangle

use of javafx.scene.shape.Rectangle in project OTP2_R6_svaap by JNuutinen.

the class Component method rectangle.

/**
 * Luo komponentista neliön muotoisen.
 * @param size Komponentin koko.
 * @param orientation Komponentin orientaatio.
 * @param color Komponentin väri.
 * @return Tehty Shape neliö.
 */
private Shape rectangle(int size, int orientation, Color color) {
    double x = 10 * size;
    double y = 6 * size;
    Rectangle rectangle = new Rectangle(x * 0.5, y * 0.5);
    rectangle.setFill(Color.BLACK);
    rectangle.setStroke(color);
    rectangle.setStrokeWidth(4.0);
    rectangle.setX(x * -0.25);
    rectangle.setY(y * -0.25);
    // rectangle.getTransforms().add(new Rotate(90 * orientation, x, y));
    return rectangle;
}
Also used : Rectangle(javafx.scene.shape.Rectangle)

Example 5 with Rectangle

use of javafx.scene.shape.Rectangle in project Gargoyle by callakrsos.

the class AbstractGoogleTrendChart method fillChartData.

/**
	 * 차트 그리는 작업 처리
	 * @작성자 : KYJ
	 * @작성일 : 2016. 11. 2.
	 */
protected void fillChartData() {
    IGargoyleChartAdapter<T, C> adapter = this.adapter;
    String title = adapter.getTitle(this.json.get());
    setTitle(title);
    //this.getJson();
    T json = this.json.get();
    if (ValueUtil.isNotEmpty(json)) {
        int columnCount = adapter.getColumnCount();
        for (int i = 0; i < columnCount; i++) {
            String columnName = adapter.getColumnName(i);
            ObservableList<Data<String, Number>> data = FXCollections.observableArrayList();
            javafx.scene.chart.XYChart.Series<String, Number> series = new Series<>(columnName, data);
            getData().add(series);
            int valueCount = adapter.getValueCount(columnName);
            for (int v = 0; v < valueCount; v++) {
                Data<String, Number> value = adapter.getValue(i, columnName, v);
                if (value == null)
                    continue;
                StackPane s = new StackPane(new Rectangle());
                value.setNode(s);
                s.setUserData(new ChartOverTooltip(i, columnName, value));
                data.add(value);
            }
        }
    }
}
Also used : Rectangle(javafx.scene.shape.Rectangle) StackPane(javafx.scene.layout.StackPane)

Aggregations

Rectangle (javafx.scene.shape.Rectangle)135 Text (javafx.scene.text.Text)23 Entity (com.almasb.fxgl.entity.Entity)21 Point2D (javafx.geometry.Point2D)17 Circle (javafx.scene.shape.Circle)16 Group (javafx.scene.Group)13 Pane (javafx.scene.layout.Pane)13 Scene (javafx.scene.Scene)11 Color (javafx.scene.paint.Color)11 EntityView (com.almasb.fxgl.entity.view.EntityView)10 Label (javafx.scene.control.Label)10 HitBox (com.almasb.fxgl.physics.HitBox)8 TextFlow (javafx.scene.text.TextFlow)8 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)7 Node (javafx.scene.Node)7 PlayerControl (common.PlayerControl)6 Timeline (javafx.animation.Timeline)6 StackPane (javafx.scene.layout.StackPane)6 Stage (javafx.stage.Stage)6 Region (javafx.scene.layout.Region)5