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);
}
}
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;
}
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));
}
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");
}
}
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())));
}
}
Aggregations