Search in sources :

Example 6 with Circle

use of javafx.scene.shape.Circle in project fxexperience2 by EricCanull.

the class SplineEditor method createCircle.

private Circle createCircle(Color fill, Color stroke, double width, double radius, Cursor cursor) {
    Circle circle = new Circle();
    circle.fillProperty().set(fill);
    circle.setStroke(stroke);
    circle.strokeWidthProperty().set(width);
    circle.setRadius(radius);
    circle.setCursor(cursor);
    return circle;
}
Also used : Circle(javafx.scene.shape.Circle)

Example 7 with Circle

use of javafx.scene.shape.Circle 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 8 with Circle

use of javafx.scene.shape.Circle in project aima-java by aimacode.

the class ConnectFourApp method createRootPane.

@Override
public Pane createRootPane() {
    model = new ConnectFourModel();
    BorderPane root = new BorderPane();
    ToolBar toolBar = new ToolBar();
    toolBar.setStyle("-fx-background-color: rgb(0, 0, 200)");
    clearBtn = new Button("Clear");
    clearBtn.setOnAction(ev -> model.initGame());
    strategyCombo = new ComboBox<>();
    strategyCombo.getItems().addAll("Iterative Deepening Alpha-Beta", "Advanced Alpha-Beta");
    strategyCombo.getSelectionModel().select(0);
    timeCombo = new ComboBox<>();
    timeCombo.getItems().addAll("2sec", "4sec", "6sec", "8sec");
    timeCombo.getSelectionModel().select(1);
    proposeBtn = new Button("Propose Move");
    proposeBtn.setOnAction(ev -> model.proposeMove((timeCombo.getSelectionModel().getSelectedIndex() + 1) * 2, strategyCombo.getSelectionModel().getSelectedIndex()));
    toolBar.getItems().addAll(clearBtn, new Separator(), strategyCombo, timeCombo, proposeBtn);
    root.setTop(toolBar);
    final int rows = model.getRows();
    final int cols = model.getCols();
    BorderPane boardPane = new BorderPane();
    ColumnConstraints colCons = new ColumnConstraints();
    colCons.setPercentWidth(100.0 / cols);
    GridPane btnPane = new GridPane();
    GridPane diskPane = new GridPane();
    btnPane.setHgap(10);
    btnPane.setPadding(new Insets(10, 10, 0, 10));
    btnPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    diskPane.setPadding(new Insets(10, 10, 10, 10));
    diskPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    colBtns = new Button[cols];
    for (int i = 0; i < cols; i++) {
        Button colBtn = new Button("" + (i + 1));
        colBtn.setId("" + (i + 1));
        colBtn.setMaxWidth(Double.MAX_VALUE);
        colBtn.setOnAction(ev -> {
            String id = ((Button) ev.getSource()).getId();
            int col = Integer.parseInt(id);
            model.makeMove(col - 1);
        });
        colBtns[i] = colBtn;
        btnPane.add(colBtn, i, 0);
        GridPane.setHalignment(colBtn, HPos.CENTER);
        btnPane.getColumnConstraints().add(colCons);
        diskPane.getColumnConstraints().add(colCons);
    }
    boardPane.setTop(btnPane);
    diskPane.setMinSize(0, 0);
    diskPane.setPrefSize(cols * 100, rows * 100);
    RowConstraints rowCons = new RowConstraints();
    rowCons.setPercentHeight(100.0 / rows);
    for (int i = 0; i < rows; i++) diskPane.getRowConstraints().add(rowCons);
    disks = new Circle[rows * cols];
    for (int i = 0; i < rows * cols; i++) {
        Circle disk = new Circle(30);
        disk.radiusProperty().bind(Bindings.min(Bindings.divide(diskPane.widthProperty(), cols * 3), Bindings.divide(diskPane.heightProperty(), rows * 3)));
        disks[i] = disk;
        diskPane.add(disk, i % cols, i / cols);
        GridPane.setHalignment(disk, HPos.CENTER);
    }
    boardPane.setCenter(diskPane);
    root.setCenter(boardPane);
    statusBar = new Label();
    statusBar.setMaxWidth(Double.MAX_VALUE);
    statusBar.setStyle("-fx-background-color: rgb(0, 0, 200); -fx-font-size: 20");
    root.setBottom(statusBar);
    model.addObserver(this::update);
    return root;
}
Also used : Circle(javafx.scene.shape.Circle) BorderPane(javafx.scene.layout.BorderPane) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Label(javafx.scene.control.Label) RowConstraints(javafx.scene.layout.RowConstraints) Button(javafx.scene.control.Button) ToolBar(javafx.scene.control.ToolBar) Separator(javafx.scene.control.Separator)

Example 9 with Circle

use of javafx.scene.shape.Circle in project aima-java by aimacode.

the class CspViewCtrl method visualize.

protected void visualize(VAR var) {
    Point2D pos = getPosition(var);
    String label = var.getName();
    VAL value = null;
    Color fillColor = null;
    if (assignment != null)
        value = assignment.getValue(var);
    if (value != null) {
        label += " = " + value;
        fillColor = colorMapping.get(value);
    }
    Circle circle = new Circle(pos.getX(), pos.getY(), 20);
    circle.setStroke(Color.BLACK);
    circle.setFill(fillColor != null ? fillColor : Color.WHITE);
    Text t1 = new Text(pos.getX() + 25, pos.getY(), label);
    t1.setTextOrigin(VPos.CENTER);
    Text t2 = new Text(pos.getX(), pos.getY() + 40, csp.getDomain(var).toString());
    pane.getChildren().addAll(circle, t1, t2);
}
Also used : Circle(javafx.scene.shape.Circle) Point2D(aima.core.util.math.geom.shapes.Point2D) Color(javafx.scene.paint.Color) Text(javafx.scene.text.Text)

Example 10 with Circle

use of javafx.scene.shape.Circle 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));
        }
    }
}
Also used : Line(javafx.scene.shape.Line) Circle(javafx.scene.shape.Circle) Agent(aima.core.agent.Agent) Shape(javafx.scene.shape.Shape) Point2D(aima.core.util.math.geom.shapes.Point2D) Text(javafx.scene.text.Text) Map(aima.core.environment.map.Map) Font(javafx.scene.text.Font)

Aggregations

Circle (javafx.scene.shape.Circle)13 Label (javafx.scene.control.Label)5 Line (javafx.scene.shape.Line)5 Text (javafx.scene.text.Text)5 Group (javafx.scene.Group)4 Paint (javafx.scene.paint.Paint)3 Rectangle (javafx.scene.shape.Rectangle)3 Shape (javafx.scene.shape.Shape)3 Font (javafx.scene.text.Font)3 Rotate (javafx.scene.transform.Rotate)3 Point2D (aima.core.util.math.geom.shapes.Point2D)2 Insets (javafx.geometry.Insets)2 Node (javafx.scene.Node)2 StackPane (javafx.scene.layout.StackPane)2 Color (javafx.scene.paint.Color)2 Agent (aima.core.agent.Agent)1 Map (aima.core.environment.map.Map)1 JFXTimePicker (com.jfoenix.controls.JFXTimePicker)1 URL (java.net.URL)1 LocalDate (java.time.LocalDate)1