Search in sources :

Example 11 with Label

use of javafx.scene.control.Label in project DistributedFractalNetwork by Budder21.

the class NetworkCreationTool method displayDialog2.

private Pair<Integer, Integer> displayDialog2() {
    Dialog<Pair<String, String>> dialog2 = new Dialog<>();
    dialog2.setTitle("Create Network");
    dialog2.setHeaderText("Step 2");
    dialog2.setContentText("Choose an image resolution:");
    dialog2.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));
    TextField widthField = new TextField("1600");
    widthField.textProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (!newValue.matches("\\d*")) {
                widthField.setText(newValue.replaceAll("[^\\d]", ""));
            }
        }
    });
    TextField heightField = new TextField("1600");
    heightField.textProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (!newValue.matches("\\d*")) {
                heightField.setText(newValue.replaceAll("[^\\d]", ""));
            }
        }
    });
    grid.add(new Label("Width:"), 0, 0);
    grid.add(widthField, 1, 0);
    grid.add(new Label("Height:"), 0, 1);
    grid.add(heightField, 1, 1);
    dialog2.getDialogPane().setContent(grid);
    dialog2.setResultConverter(dialogButton -> {
        if (dialogButton == ButtonType.OK)
            return new Pair<String, String>(widthField.getText(), heightField.getText());
        return null;
    });
    Optional<Pair<String, String>> result = dialog2.showAndWait();
    int width = 0;
    int height = 0;
    try {
        width = Integer.valueOf(result.get().getKey());
        height = Integer.valueOf(result.get().getValue());
    } catch (NumberFormatException e) {
        AlertMenu aMenu = new AlertMenu("INVALID INPUT: Must be an integer.", "Please try again");
        return displayDialog2();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return new Pair<Integer, Integer>(width, height);
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) Dialog(javafx.scene.control.Dialog) ChoiceDialog(javafx.scene.control.ChoiceDialog) TextInputDialog(javafx.scene.control.TextInputDialog) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair)

Example 12 with Label

use of javafx.scene.control.Label 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 13 with Label

use of javafx.scene.control.Label in project POL-POM-5 by PlayOnLinux.

the class AppPanel method populateCenter.

private void populateCenter() {
    this.appDescription = new WebView();
    this.appDescription.getEngine().loadContent("<body>" + application.getDescription() + "</body>");
    themeManager.bindWebEngineStylesheet(appDescription.getEngine().userStyleSheetLocationProperty());
    this.installers = new Label(tr("Installers"));
    this.installers.getStyleClass().add("descriptionTitle");
    this.scriptGrid = new GridPane();
    filteredScripts.addListener((InvalidationListener) change -> this.refreshScripts());
    this.refreshScripts();
    this.miniaturesPane = new HBox();
    this.miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
    this.miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
    this.miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
    for (URI miniatureUri : application.getMiniatures()) {
        Region image = new Region();
        image.getStyleClass().add("appMiniature");
        image.setStyle(String.format("-fx-background-image: url(\"%s\");", miniatureUri.toString()));
        image.prefHeightProperty().bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
        image.prefWidthProperty().bind(image.prefHeightProperty().multiply(1.5));
        miniaturesPane.getChildren().add(image);
    }
    this.center = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
    VBox.setVgrow(appDescription, Priority.ALWAYS);
    this.setCenter(center);
}
Also used : Button(javafx.scene.control.Button) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) javafx.scene.layout(javafx.scene.layout) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) FilteredList(javafx.collections.transformation.FilteredList) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) InvalidationListener(javafx.beans.InvalidationListener) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Consumer(java.util.function.Consumer) ScrollPane(javafx.scene.control.ScrollPane) DetailsView(org.phoenicis.javafx.views.common.widgets.lists.DetailsView) SettingsManager(org.phoenicis.settings.SettingsManager) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) ThemeManager(org.phoenicis.javafx.views.common.ThemeManager) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) URI(java.net.URI)

Example 14 with Label

use of javafx.scene.control.Label in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerInformationTab method populate.

private void populate() {
    final VBox informationPane = new VBox();
    final Text title = new TextWithStyle(tr("Information"), TITLE_CSS_CLASS);
    informationPane.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS);
    informationPane.getChildren().add(title);
    final GridPane informationContentPane = new GridPane();
    informationContentPane.getStyleClass().add("grid");
    informationContentPane.add(new TextWithStyle(tr("Name:"), CAPTION_TITLE_CSS_CLASS), 0, 0);
    Label name = new Label(container.getName());
    name.setWrapText(true);
    informationContentPane.add(name, 1, 0);
    informationContentPane.add(new TextWithStyle(tr("Path:"), CAPTION_TITLE_CSS_CLASS), 0, 1);
    Label path = new Label(container.getPath());
    path.setWrapText(true);
    informationContentPane.add(path, 1, 1);
    informationContentPane.add(new TextWithStyle(tr("Wine version:"), CAPTION_TITLE_CSS_CLASS), 0, 2);
    Label version = new Label(container.getVersion());
    version.setWrapText(true);
    informationContentPane.add(version, 1, 2);
    informationContentPane.add(new TextWithStyle(tr("Wine architecture:"), CAPTION_TITLE_CSS_CLASS), 0, 3);
    Label architecture = new Label(container.getArchitecture());
    architecture.setWrapText(true);
    informationContentPane.add(architecture, 1, 3);
    informationContentPane.add(new TextWithStyle(tr("Wine distribution:"), CAPTION_TITLE_CSS_CLASS), 0, 4);
    Label distribution = new Label(container.getDistribution());
    distribution.setWrapText(true);
    informationContentPane.add(distribution, 1, 4);
    Region spacer = new Region();
    spacer.setPrefHeight(20);
    VBox.setVgrow(spacer, Priority.NEVER);
    ComboBox<EngineVersionDTO> changeEngineComboBox = new ComboBox<EngineVersionDTO>(FXCollections.observableList(engineVersions));
    changeEngineComboBox.setConverter(new StringConverter<EngineVersionDTO>() {

        @Override
        public String toString(EngineVersionDTO object) {
            return object.getVersion();
        }

        @Override
        public EngineVersionDTO fromString(String string) {
            return engineVersions.stream().filter(engineVersion -> engineVersion.getVersion().equals(string)).findFirst().get();
        }
    });
    changeEngineComboBox.getSelectionModel().select(engineVersions.stream().filter(engineVersion -> engineVersion.getVersion().equals(container.getVersion())).findFirst().get());
    Button deleteButton = new Button(tr("Delete container"));
    deleteButton.setOnMouseClicked(event -> this.onDeletePrefix.accept(container));
    informationPane.getChildren().addAll(informationContentPane, spacer, changeEngineComboBox, deleteButton);
    this.setContent(informationPane);
}
Also used : Button(javafx.scene.control.Button) Label(javafx.scene.control.Label) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) StringConverter(javafx.util.StringConverter) VBox(javafx.scene.layout.VBox) EngineVersionDTO(org.phoenicis.engines.dto.EngineVersionDTO) Text(javafx.scene.text.Text) Consumer(java.util.function.Consumer) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) ComboBox(javafx.scene.control.ComboBox) Tab(javafx.scene.control.Tab) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) GridPane(javafx.scene.layout.GridPane) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) Text(javafx.scene.text.Text) EngineVersionDTO(org.phoenicis.engines.dto.EngineVersionDTO) Button(javafx.scene.control.Button) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox)

Example 15 with Label

use of javafx.scene.control.Label in project POL-POM-5 by PlayOnLinux.

the class AboutPanel method populate.

private void populate() {
    this.title = new TextWithStyle(tr("About"), "title");
    this.aboutGrid = new GridPane();
    this.aboutGrid.getStyleClass().add("grid");
    this.aboutGrid.setHgap(20);
    this.aboutGrid.setVgap(10);
    this.nameDescription = new TextWithStyle(tr("Name:"), "captionTitle");
    this.nameLabel = new Label(buildInformation.getApplicationName());
    this.versionDescription = new TextWithStyle(tr("Version:"), "captionTitle");
    this.versionLabel = new Label(buildInformation.getApplicationVersion());
    this.gitRevisionDescription = new TextWithStyle(tr("Git Revision:"), "captionTitle");
    this.gitRevisionHyperlink = new Hyperlink(buildInformation.getApplicationGitRevision());
    this.gitRevisionHyperlink.setOnAction(event -> {
        try {
            URI uri = new URI("https://github.com/PlayOnLinux/POL-POM-5/commit/" + buildInformation.getApplicationGitRevision());
            opener.open(uri);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    });
    this.buildTimestampDescription = new TextWithStyle(tr("Build Timestamp:"), "captionTitle");
    this.buildTimestampLabel = new Label(buildInformation.getApplicationBuildTimestamp());
    this.aboutGrid.add(nameDescription, 0, 0);
    this.aboutGrid.add(nameLabel, 1, 0);
    this.aboutGrid.add(versionDescription, 0, 1);
    this.aboutGrid.add(versionLabel, 1, 1);
    this.aboutGrid.add(gitRevisionDescription, 0, 2);
    this.aboutGrid.add(gitRevisionHyperlink, 1, 2);
    this.aboutGrid.add(buildTimestampDescription, 0, 3);
    this.aboutGrid.add(buildTimestampLabel, 1, 3);
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Hyperlink(javafx.scene.control.Hyperlink)

Aggregations

Label (javafx.scene.control.Label)138 Insets (javafx.geometry.Insets)47 Button (javafx.scene.control.Button)38 Scene (javafx.scene.Scene)26 HBox (javafx.scene.layout.HBox)26 VBox (javafx.scene.layout.VBox)25 GridPane (javafx.scene.layout.GridPane)20 TextField (javafx.scene.control.TextField)19 BorderPane (javafx.scene.layout.BorderPane)19 Node (javafx.scene.Node)17 ImageView (javafx.scene.image.ImageView)13 ArrayList (java.util.ArrayList)12 InputTextField (io.bitsquare.gui.components.InputTextField)11 List (java.util.List)11 Tooltip (javafx.scene.control.Tooltip)11 Stage (javafx.stage.Stage)11 Map (java.util.Map)9 ObservableList (javafx.collections.ObservableList)9 Image (javafx.scene.image.Image)9 StackPane (javafx.scene.layout.StackPane)9