Search in sources :

Example 71 with Tooltip

use of javafx.scene.control.Tooltip in project trex-stateless-gui by cisco-system-traffic-generator.

the class TrexApp method speedupTooltip.

/**
 * Speeding up displaying tootlip for JDK 8 ref:
 * http://stackoverflow.com/questions/26854301/control-javafx-tooltip-delay
 */
private void speedupTooltip() {
    try {
        Tooltip tooltip = new Tooltip();
        Field fieldBehavior = tooltip.getClass().getDeclaredField("BEHAVIOR");
        fieldBehavior.setAccessible(true);
        Object objBehavior = fieldBehavior.get(tooltip);
        Field fieldTimer = objBehavior.getClass().getDeclaredField("activationTimer");
        fieldTimer.setAccessible(true);
        Timeline objTimer = (Timeline) fieldTimer.get(objBehavior);
        objTimer.getKeyFrames().clear();
        objTimer.getKeyFrames().add(new KeyFrame(new Duration(250)));
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        LOG.error(e);
    }
}
Also used : Field(java.lang.reflect.Field) Timeline(javafx.animation.Timeline) Tooltip(javafx.scene.control.Tooltip) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration)

Example 72 with Tooltip

use of javafx.scene.control.Tooltip in project trex-stateless-gui by cisco-system-traffic-generator.

the class StatsTableGenerator method generateXStatPane.

public GridPane generateXStatPane(boolean full, Port port, boolean notempty, String filter, boolean resetCounters) {
    if (full) {
        statXTable.getChildren().clear();
        Util.optimizeMemory();
    }
    Map<String, Long> xstatsList = port.getXstats();
    Map<String, Long> xstatsListPinned = port.getXstatsPinned();
    String pinnedChar = "\u2716";
    String notPinnedChar = "\u271a";
    /*String pinnedChar = "\u2611";
        String notPinnedChar = "\u2610";*/
    rowIndex = 0;
    addHeaderCell(statXTable, "xstats-header0", "Counter", 0, WIDTH_COL_0 * 1.5);
    addHeaderCell(statXTable, "xstats-header1", "Value", 1, WIDTH_COL_1);
    addHeaderCell(statXTable, "xstats-header2", "Pin", 2, WIDTH_COL_PIN);
    rowIndex = 1;
    odd = true;
    xstatsListPinned.forEach((k, v) -> {
        if (v != null) {
            if (resetCounters) {
                fixCounter(port.getIndex(), k, v);
            }
            Node check = new Label(pinnedChar);
            GridPane.setHalignment(check, HPos.CENTER);
            addXstatRow(statXTable, (event) -> xstatsListPinned.remove(k, v), "xstat-red", "xstat-green", new Tooltip("Click '" + pinnedChar + "' to un-pin the counter."), "xstats-val-0-" + rowIndex, k, WIDTH_COL_0 * 1.5, 0, "xstats-val-1-" + rowIndex, String.valueOf(v - getShadowCounter(port.getIndex(), k)), WIDTH_COL_1, 1, "xstats-val-2-" + rowIndex, pinnedChar, WIDTH_COL_PIN, 2);
        }
    });
    xstatsList.forEach((k, v) -> {
        if (v != null && (!notempty || (notempty && (v - getShadowCounter(port.getIndex(), k) != 0))) && xstatsListPinned.get(k) == null) {
            if ((filter == null || filter.trim().length() == 0) || k.contains(filter)) {
                if (resetCounters) {
                    fixCounter(port.getIndex(), k, v);
                }
                Node check = new Label(notPinnedChar);
                GridPane.setHalignment(check, HPos.CENTER);
                addXstatRow(statXTable, (event) -> xstatsListPinned.put(k, v), "xstat-green", "xstat-red", new Tooltip("Click '" + notPinnedChar + "' to pin the counter.\nPinned counter is always visible."), "xstats-val-0-" + rowIndex, k, WIDTH_COL_0 * 1.5, 0, "xstats-val-1-" + rowIndex, String.valueOf(v - getShadowCounter(port.getIndex(), k)), WIDTH_COL_1, 1, "xstats-val-2-" + rowIndex, notPinnedChar, WIDTH_COL_PIN, 2);
            }
        }
    });
    GridPane gp = new GridPane();
    gp.setGridLinesVisible(false);
    gp.add(statXTable, 1, 1, 1, 2);
    return gp;
}
Also used : GridPane(javafx.scene.layout.GridPane) Node(javafx.scene.Node) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label)

Example 73 with Tooltip

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

the class OpenDatabaseController method setDatabaseField.

private void setDatabaseField(final String database) {
    localDatabaseField.setText(database);
    localDatabaseField.setTooltip(new Tooltip(database));
}
Also used : Tooltip(javafx.scene.control.Tooltip)

Example 74 with Tooltip

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

the class IncomeExpensePayeePieChartDialogController method updateCharts.

private void updateCharts() {
    final Account account = accountComboBox.getValue();
    if (account != null) {
        final ObservableList<PieChart.Data>[] chartData = createPieDataSet(account);
        creditPieChart.setData(chartData[CREDIT]);
        debitPieChart.setData(chartData[DEBIT]);
        final NumberFormat numberFormat = NumericFormats.getFullCommodityFormat(account.getCurrencyNode());
        // Calculate the totals for percentage value
        final double creditTotal = chartData[CREDIT].parallelStream().mapToDouble(PieChart.Data::getPieValue).sum();
        final double debitTotal = chartData[DEBIT].parallelStream().mapToDouble(PieChart.Data::getPieValue).sum();
        final NumberFormat percentFormat = NumberFormat.getPercentInstance();
        percentFormat.setMaximumFractionDigits(1);
        percentFormat.setMinimumFractionDigits(1);
        // Install tooltips on the data after it has been added to the chart
        creditPieChart.getData().forEach(data -> Tooltip.install(data.getNode(), new Tooltip((data.getNode().getUserData() + "\n" + numberFormat.format(data.getPieValue()) + "(" + percentFormat.format(data.getPieValue() / creditTotal)) + ")")));
        // Install tooltips on the data after it has been added to the chart
        debitPieChart.getData().forEach(data -> Tooltip.install(data.getNode(), new Tooltip(((data.getNode().getUserData()) + "\n" + numberFormat.format(data.getPieValue()) + "(" + percentFormat.format(data.getPieValue() / debitTotal)) + ")")));
        creditPieChart.centerSubTitleProperty().set(numberFormat.format(creditTotal));
        debitPieChart.centerSubTitleProperty().set(numberFormat.format(debitTotal));
    } else {
        creditPieChart.setData(FXCollections.emptyObservableList());
        creditPieChart.setTitle("No Data");
        debitPieChart.setData(FXCollections.emptyObservableList());
        debitPieChart.setTitle("No Data");
    }
}
Also used : Account(jgnash.engine.Account) PieChart(javafx.scene.chart.PieChart) ObservableList(javafx.collections.ObservableList) Tooltip(javafx.scene.control.Tooltip) NumberFormat(java.text.NumberFormat)

Example 75 with Tooltip

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

the class IncomeExpenseBarChartDialogController method updateChart.

private void updateChart() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final List<Account> incomeAccounts = engine.getIncomeAccountList();
    final List<Account> expenseAccounts = engine.getExpenseAccountList();
    barChart.getData().clear();
    final List<ReportPeriodUtils.Descriptor> descriptors = ReportPeriodUtils.getDescriptors(periodComboBox.getValue(), startDatePicker.getValue(), endDatePicker.getValue());
    // Income Series
    final XYChart.Series<String, Number> incomeSeries = new XYChart.Series<>();
    incomeSeries.setName(AccountType.INCOME.toString());
    barChart.getData().add(incomeSeries);
    // Expense Series
    final XYChart.Series<String, Number> expenseSeries = new XYChart.Series<>();
    expenseSeries.setName(AccountType.EXPENSE.toString());
    barChart.getData().add(expenseSeries);
    // Profit Series
    final XYChart.Series<String, Number> profitSeries = new XYChart.Series<>();
    profitSeries.setName(resources.getString("Word.NetIncome"));
    barChart.getData().add(profitSeries);
    for (final ReportPeriodUtils.Descriptor descriptor : descriptors) {
        final BigDecimal income = getSum(incomeAccounts, descriptor.getStartDate(), descriptor.getEndDate());
        final BigDecimal expense = getSum(expenseAccounts, descriptor.getStartDate(), descriptor.getEndDate());
        incomeSeries.getData().add(new XYChart.Data<>(descriptor.getLabel(), income));
        expenseSeries.getData().add(new XYChart.Data<>(descriptor.getLabel(), expense));
        profitSeries.getData().add(new XYChart.Data<>(descriptor.getLabel(), income.add(expense)));
    }
    int descriptorsIndex = 0;
    for (final XYChart.Data<String, Number> data : incomeSeries.getData()) {
        Tooltip.install(data.getNode(), new Tooltip(numberFormat.format(data.getYValue())));
        setupPieChartLaunch(data, AccountType.INCOME, descriptors.get(descriptorsIndex).getStartDate(), descriptors.get(descriptorsIndex).getEndDate());
        descriptorsIndex++;
    }
    descriptorsIndex = 0;
    for (final XYChart.Data<String, Number> data : expenseSeries.getData()) {
        Tooltip.install(data.getNode(), new Tooltip(numberFormat.format(data.getYValue())));
        setupPieChartLaunch(data, AccountType.EXPENSE, descriptors.get(descriptorsIndex).getStartDate(), descriptors.get(descriptorsIndex).getEndDate());
        descriptorsIndex++;
    }
    for (final XYChart.Data<String, Number> data : profitSeries.getData()) {
        Tooltip.install(data.getNode(), new Tooltip(numberFormat.format(data.getYValue())));
    }
}
Also used : Account(jgnash.engine.Account) ReportPeriodUtils(jgnash.report.ReportPeriodUtils) Tooltip(javafx.scene.control.Tooltip) BigDecimal(java.math.BigDecimal) XYChart(javafx.scene.chart.XYChart) Engine(jgnash.engine.Engine)

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