Search in sources :

Example 76 with Tooltip

use of javafx.scene.control.Tooltip in project jgnash by ccavanaugh.

the class IncomeExpensePieChartDialogController method updateChart.

private void updateChart() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final Account a = accountComboBox.getValue();
    if (a != null) {
        final CurrencyNode defaultCurrency = a.getCurrencyNode();
        final NumberFormat numberFormat = NumericFormats.getFullCommodityFormat(defaultCurrency);
        final ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
        double total = a.getTreeBalance(startDatePicker.getValue(), endDatePicker.getValue(), defaultCurrency).doubleValue();
        for (final Account child : a.getChildren()) {
            double balance = child.getTreeBalance(startDatePicker.getValue(), endDatePicker.getValue(), defaultCurrency).doubleValue();
            if (balance > 0 || balance < 0) {
                final String label = child.getName() + " - " + numberFormat.format(balance);
                final PieChart.Data data = new PieChart.Data(label, balance / total * 100);
                // nodes are created lazily.  Set the user data (Account) after the node is created
                data.nodeProperty().addListener((observable, oldValue, newValue) -> newValue.setUserData(child));
                pieChartData.add(data);
            }
        }
        pieChart.setData(pieChartData);
        final NumberFormat percentFormat = NumberFormat.getPercentInstance();
        percentFormat.setMaximumFractionDigits(1);
        percentFormat.setMinimumFractionDigits(1);
        // Install tooltips on the data after it has been added to the chart
        pieChart.getData().forEach(data -> Tooltip.install(data.getNode(), new Tooltip((((Account) data.getNode().getUserData()).getName() + " - " + percentFormat.format(data.getPieValue() / 100d)))));
        // Indicate the node can be clicked on to zoom into the next account level
        for (final PieChart.Data data : pieChart.getData()) {
            data.getNode().setOnMouseEntered(event -> {
                final Account account = (Account) data.getNode().getUserData();
                if (account.isParent()) {
                    data.getNode().setCursor(CustomCursor.getZoomInCursor());
                } else {
                    data.getNode().setCursor(Cursor.DEFAULT);
                }
                nodeFocused = true;
            });
            data.getNode().setOnMouseExited(event -> nodeFocused = false);
            // zoom in on click if this is a parent account
            data.getNode().setOnMouseClicked(event -> {
                if (data.getNode().getUserData() != null) {
                    if (((Account) data.getNode().getUserData()).isParent()) {
                        accountComboBox.setValue((Account) data.getNode().getUserData());
                    }
                }
            });
        }
        final String title;
        // pick an appropriate title
        switch(a.getAccountType()) {
            case EXPENSE:
                title = resources.getString("Title.PercentExpense");
                break;
            case INCOME:
                title = resources.getString("Title.PercentIncome");
                break;
            default:
                title = resources.getString("Title.PercentDist");
                break;
        }
        pieChart.setTitle(title);
        pieChart.centerTitleProperty().set(accountComboBox.getValue().getName());
        pieChart.centerSubTitleProperty().set(numberFormat.format(total));
    // abs() on all values won't work if children aren't of uniform sign,
    // then again, this chart is not right to display those trees
    // boolean negate = total != null && total.signum() < 0;
    } else {
        pieChart.setData(FXCollections.emptyObservableList());
        pieChart.setTitle("No Data");
    }
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) Account(jgnash.engine.Account) PieChart(javafx.scene.chart.PieChart) Tooltip(javafx.scene.control.Tooltip) Engine(jgnash.engine.Engine) NumberFormat(java.text.NumberFormat)

Example 77 with Tooltip

use of javafx.scene.control.Tooltip in project jgnash by ccavanaugh.

the class ImportPageTwoController method buildTableView.

private void buildTableView() {
    final TableColumn<ImportTransaction, ImportState> stateColumn = new TableColumn<>();
    stateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getState()));
    stateColumn.setCellFactory(param -> {
        TableCell<ImportTransaction, ImportState> cell = new ImportStateTableCell();
        cell.addEventFilter(MouseEvent.MOUSE_CLICKED, event -> {
            if (event.getClickCount() > 1) {
                final ImportTransaction t = tableView.getItems().get(((TableCell<?, ?>) event.getSource()).getTableRow().getIndex());
                switch(t.getState()) {
                    case EQUAL:
                        t.setState(ImportState.NOT_EQUAL);
                        break;
                    case NOT_EQUAL:
                        t.setState(ImportState.EQUAL);
                        break;
                    case NEW:
                        t.setState(ImportState.IGNORE);
                        break;
                    case IGNORE:
                        t.setState(ImportState.NEW);
                        break;
                }
                JavaFXUtils.runLater(tableView::refresh);
            }
        });
        return cell;
    });
    tableView.getColumns().add(stateColumn);
    final TableColumn<ImportTransaction, LocalDate> dateColumn = new TableColumn<>(resources.getString("Column.Date"));
    dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDatePosted()));
    dateColumn.setCellFactory(param -> new ShortDateTableCell<>());
    tableView.getColumns().add(dateColumn);
    final TableColumn<ImportTransaction, String> numberColumn = new TableColumn<>(resources.getString("Column.Num"));
    numberColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getCheckNumber()));
    tableView.getColumns().add(numberColumn);
    final TableColumn<ImportTransaction, String> payeeColumn = new TableColumn<>(resources.getString("Column.Payee"));
    payeeColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPayee()));
    tableView.getColumns().add(payeeColumn);
    final TableColumn<ImportTransaction, String> memoColumn = new TableColumn<>(resources.getString("Column.Memo"));
    memoColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getMemo()));
    tableView.getColumns().add(memoColumn);
    final TableColumn<ImportTransaction, Account> accountColumn = new TableColumn<>(resources.getString("Column.Account"));
    accountColumn.setCellValueFactory(param -> {
        if (param.getValue() != null && param.getValue().getAccount() != null) {
            return new SimpleObjectProperty<>(param.getValue().getAccount());
        }
        return null;
    });
    accountColumn.setCellFactory(param -> new AccountComboBoxTableCell<>());
    accountColumn.setEditable(true);
    accountColumn.setOnEditCommit(event -> {
        event.getTableView().getItems().get(event.getTablePosition().getRow()).setAccount(event.getNewValue());
        lastAccount = event.getNewValue();
        JavaFXUtils.runLater(tableViewManager::packTable);
    });
    tableView.getColumns().add(accountColumn);
    incomeAccountColumn = new TableColumn<>(resources.getString("Column.Income"));
    incomeAccountColumn.setCellValueFactory(param -> {
        if (param.getValue() != null && param.getValue().getGainsAccount() != null) {
            return new SimpleObjectProperty<>(param.getValue().getGainsAccount());
        }
        return null;
    });
    incomeAccountColumn.setCellFactory(param -> new IncomeAccountComboBoxTableCell<>());
    incomeAccountColumn.setEditable(true);
    incomeAccountColumn.setOnEditCommit(event -> {
        event.getTableView().getItems().get(event.getTablePosition().getRow()).setGainsAccount(event.getNewValue());
        lastGainsAccount = event.getNewValue();
        JavaFXUtils.runLater(tableViewManager::packTable);
    });
    tableView.getColumns().add(incomeAccountColumn);
    expenseAccountColumn = new TableColumn<>(resources.getString("Column.Expense"));
    expenseAccountColumn.setCellValueFactory(param -> {
        if (param.getValue() != null && param.getValue().getFeesAccount() != null) {
            if (param.getValue().getFees().compareTo(BigDecimal.ZERO) != 0) {
                return new SimpleObjectProperty<>(param.getValue().getFeesAccount());
            }
            // nop account
            return new SimpleObjectProperty<>(NOP_EXPENSE_ACCOUNT);
        }
        return null;
    });
    expenseAccountColumn.setCellFactory(param -> new ExpenseAccountComboBoxTableCell<>());
    expenseAccountColumn.setEditable(true);
    expenseAccountColumn.setOnEditCommit(event -> {
        event.getTableView().getItems().get(event.getTablePosition().getRow()).setFeesAccount(event.getNewValue());
        JavaFXUtils.runLater(tableViewManager::packTable);
    });
    tableView.getColumns().add(expenseAccountColumn);
    final TableColumn<ImportTransaction, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
    amountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getAmount()));
    amountColumn.setCellFactory(param -> new BigDecimalTableCell<>(numberFormat));
    amountColumn.setCellFactory(param -> {
        final TableCell<ImportTransaction, BigDecimal> cell = new BigDecimalTableCell<>(numberFormat);
        // add tool tip
        cell.indexProperty().addListener((observable, oldValue, newValue) -> {
            final int index = newValue.intValue();
            if (index >= 0 && index < tableView.itemsProperty().get().size()) {
                cell.setTooltip(new Tooltip(tableView.itemsProperty().get().get(index).getToolTip()));
            }
        });
        return cell;
    });
    tableView.getColumns().add(amountColumn);
    typeColumn = new TableColumn<>(resources.getString("Column.Type"));
    typeColumn.setCellValueFactory(param -> {
        TransactionType transactionType = TransactionType.SINGLENTRY;
        if (param.getValue().isInvestmentTransaction()) {
            transactionType = param.getValue().getTransactionType();
        } else if (!param.getValue().getAccount().equals(baseAccount)) {
            transactionType = TransactionType.DOUBLEENTRY;
        }
        return new SimpleStringProperty(transactionType.toString());
    });
    tableView.getColumns().add(typeColumn);
}
Also used : Account(jgnash.engine.Account) TransactionType(jgnash.engine.TransactionType) ImportState(jgnash.convert.importat.ImportState) LocalDate(java.time.LocalDate) ImportTransaction(jgnash.convert.importat.ImportTransaction) BigDecimalTableCell(jgnash.uifx.control.BigDecimalTableCell) TableCell(javafx.scene.control.TableCell) ShortDateTableCell(jgnash.uifx.control.ShortDateTableCell) BigDecimalTableCell(jgnash.uifx.control.BigDecimalTableCell) Tooltip(javafx.scene.control.Tooltip) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) BigDecimal(java.math.BigDecimal) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty)

Example 78 with Tooltip

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

the class ApplicationSidebarSkin method createFilterGroup.

private SidebarGroup<CheckBox> createFilterGroup() {
    final CheckBox testingCheck = createCheckBox(tr("Testing"));
    testingCheck.setTooltip(new Tooltip(tr("Also show apps in testing state")));
    getControl().containTestingApplicationsProperty().bind(testingCheck.selectedProperty());
    final CheckBox requiresPatchCheck = createCheckBox(tr("Patch required"));
    requiresPatchCheck.setTooltip(new Tooltip(tr("Also show apps, where CD patch is necessary")));
    getControl().containRequiresPatchApplicationsProperty().bind(requiresPatchCheck.selectedProperty());
    final CheckBox commercialCheck = createCheckBox(tr("Commercial"));
    commercialCheck.setTooltip(new Tooltip(tr("Also show apps not free of costs")));
    commercialCheck.setSelected(true);
    getControl().containCommercialApplicationsProperty().bind(commercialCheck.selectedProperty());
    final CheckBox operatingSystemCheck = createCheckBox(tr("All Operating Systems"));
    operatingSystemCheck.setTooltip(new Tooltip(tr("Also show apps tested on different OS")));
    getControl().containAllOSCompatibleApplicationsProperty().bind(operatingSystemCheck.selectedProperty());
    return new SidebarGroup<>(tr("Filters"), FXCollections.observableArrayList(testingCheck, requiresPatchCheck, commercialCheck, operatingSystemCheck));
}
Also used : CheckBox(javafx.scene.control.CheckBox) Tooltip(javafx.scene.control.Tooltip) SidebarGroup(org.phoenicis.javafx.components.common.control.SidebarGroup)

Example 79 with Tooltip

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

the class IconsListElementSkin method createMiniature.

/**
 * Creates a region with the miniature of the list element
 *
 * @return A region with the miniature of the list element
 */
private Region createMiniature() {
    final Region miniature = new Region();
    miniature.getStyleClass().add("iconListMiniatureImage");
    miniature.styleProperty().bind(Bindings.createStringBinding(() -> String.format("-fx-background-image: url(\"%s\");", getControl().getMiniatureUri().toString()), getControl().miniatureUriProperty()));
    final Tooltip tooltip = new Tooltip();
    tooltip.textProperty().bind(getControl().titleProperty());
    Tooltip.install(miniature, tooltip);
    // set a gray filter for this element if it is not enabled
    getControl().enabledProperty().addListener((Observable invalidation) -> updateEnabled(miniature));
    // adopt the enable status during initialisation
    updateEnabled(miniature);
    return miniature;
}
Also used : Tooltip(javafx.scene.control.Tooltip) Region(javafx.scene.layout.Region) Observable(javafx.beans.Observable)

Example 80 with Tooltip

use of javafx.scene.control.Tooltip in project VocabHunter by VocabHunter.

the class MiniGraphTool method miniGraph.

public static ProgressBar miniGraph(final StatusModel statusModel) {
    ProgressBar bar = new ProgressBar();
    bar.getStyleClass().add(STYLE_CLASS);
    bar.managedProperty().bind(statusModel.graphShownProperty());
    bar.visibleProperty().bind(statusModel.graphShownProperty());
    bar.progressProperty().bind(statusModel.markedFractionProperty());
    bar.setPrefWidth(WIDTH);
    Tooltip tooltip = new Tooltip();
    bar.setTooltip(tooltip);
    tooltip.textProperty().bind(statusModel.graphTextProperty());
    return bar;
}
Also used : Tooltip(javafx.scene.control.Tooltip) ProgressBar(javafx.scene.control.ProgressBar)

Aggregations

Tooltip (javafx.scene.control.Tooltip)173 Button (javafx.scene.control.Button)61 Label (javafx.scene.control.Label)51 Insets (javafx.geometry.Insets)38 ImageView (javafx.scene.image.ImageView)34 VBox (javafx.scene.layout.VBox)32 List (java.util.List)31 TableColumn (javafx.scene.control.TableColumn)29 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)28 FXML (javafx.fxml.FXML)27 TableCell (javafx.scene.control.TableCell)27 ObservableList (javafx.collections.ObservableList)26 Node (javafx.scene.Node)26 TableView (javafx.scene.control.TableView)26 ArrayList (java.util.ArrayList)25 Inject (javax.inject.Inject)25 Res (bisq.core.locale.Res)24 FxmlView (bisq.desktop.common.view.FxmlView)23 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)23 Collectors (java.util.stream.Collectors)23