Search in sources :

Example 1 with TimelineChartToolTip

use of name.abuchen.portfolio.ui.util.chart.TimelineChartToolTip in project portfolio by buchen.

the class SecuritiesChart method setupTooltip.

private void setupTooltip() {
    TimelineChartToolTip toolTip = chart.getToolTip();
    toolTip.setValueFormat(new DecimalFormat(Values.Quote.pattern()));
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.LabelChartDetailClosingIndicator + "Positive");
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.LabelChartDetailClosingIndicator + "Negative");
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.LabelChartDetailClosingIndicator + "Zero");
    toolTip.addSeriesExclude(Messages.SecurityMenuBuy);
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.SecurityMenuBuy + "1");
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.SecurityMenuBuy + "2");
    toolTip.addSeriesExclude(Messages.SecurityMenuSell);
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.SecurityMenuSell + "1");
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.SecurityMenuSell + "2");
    toolTip.addSeriesExclude(Messages.LabelChartDetailDividends);
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.LabelChartDetailDividends + "1");
    // $NON-NLS-1$
    toolTip.addSeriesExclude(Messages.LabelChartDetailDividends + "2");
    toolTip.addSeriesExclude(Messages.LabelChartDetailBollingerBands);
    toolTip.addExtraInfo((composite, focus) -> {
        if (focus instanceof Date) {
            Instant instant = ((Date) focus).toInstant();
            ZonedDateTime zdt = instant.atZone(ZoneId.systemDefault());
            LocalDate date = zdt.toLocalDate();
            Interval displayInterval = Interval.of(date.minusDays(5), date.plusDays(5));
            // 
            customTooltipEvents.stream().filter(// 
            t -> displayInterval.contains(t.getDateTime())).forEach(t -> {
                if (t instanceof AccountTransaction)
                    addDividendTooltip(composite, (AccountTransaction) t);
                else if (t instanceof PortfolioTransaction)
                    addInvestmentTooltip(composite, (PortfolioTransaction) t);
            });
        }
    });
}
Also used : Arrays(java.util.Arrays) Client(name.abuchen.portfolio.model.Client) Transaction(name.abuchen.portfolio.model.Transaction) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) LineStyle(org.swtchart.LineStyle) Point(org.eclipse.swt.graphics.Point) Composite(org.eclipse.swt.widgets.Composite) ILineSeries(org.swtchart.ILineSeries) Interval(name.abuchen.portfolio.util.Interval) EnumSet(java.util.EnumSet) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Separator(org.eclipse.jface.action.Separator) Button(org.eclipse.swt.widgets.Button) MenuManager(org.eclipse.jface.action.MenuManager) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) List(java.util.List) Colors(name.abuchen.portfolio.ui.util.Colors) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) LocalDate(java.time.LocalDate) RowLayoutFactory(org.eclipse.jface.layout.RowLayoutFactory) SWT(org.eclipse.swt.SWT) ClientSecurityFilter(name.abuchen.portfolio.snapshot.filter.ClientSecurityFilter) SeriesType(org.swtchart.ISeries.SeriesType) Optional(java.util.Optional) Label(org.eclipse.swt.widgets.Label) ClientSnapshot(name.abuchen.portfolio.snapshot.ClientSnapshot) SelectionListener(org.eclipse.swt.events.SelectionListener) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) PaintListener(org.eclipse.swt.events.PaintListener) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) IAxis(org.swtchart.IAxis) Images(name.abuchen.portfolio.ui.Images) AssetPosition(name.abuchen.portfolio.snapshot.AssetPosition) ArrayUtils(org.apache.commons.lang3.ArrayUtils) ISeries(org.swtchart.ISeries) TimelineChartToolTip(name.abuchen.portfolio.ui.util.chart.TimelineChartToolTip) Range(org.swtchart.Range) ArrayList(java.util.ArrayList) MessageFormat(com.ibm.icu.text.MessageFormat) Messages(name.abuchen.portfolio.ui.Messages) TemporalAmount(java.time.temporal.TemporalAmount) Period(java.time.Period) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) DecimalFormat(java.text.DecimalFormat) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) ILegend(org.swtchart.ILegend) Action(org.eclipse.jface.action.Action) TimelineChart(name.abuchen.portfolio.ui.util.chart.TimelineChart) PlotSymbolType(org.swtchart.ILineSeries.PlotSymbolType) PortfolioPlugin(name.abuchen.portfolio.ui.PortfolioPlugin) Color(org.eclipse.swt.graphics.Color) Unit(name.abuchen.portfolio.model.Transaction.Unit) IMenuManager(org.eclipse.jface.action.IMenuManager) DateTimeFormatter(java.time.format.DateTimeFormatter) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Collections(java.util.Collections) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) TimelineChartToolTip(name.abuchen.portfolio.ui.util.chart.TimelineChartToolTip) ZonedDateTime(java.time.ZonedDateTime) DecimalFormat(java.text.DecimalFormat) Instant(java.time.Instant) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) LocalDate(java.time.LocalDate) Date(java.util.Date) LocalDate(java.time.LocalDate) Interval(name.abuchen.portfolio.util.Interval)

Example 2 with TimelineChartToolTip

use of name.abuchen.portfolio.ui.util.chart.TimelineChartToolTip in project portfolio by buchen.

the class AbstractChartTab method attachTooltipTo.

protected void attachTooltipTo(Chart chart) {
    TimelineChartToolTip toolTip = new TimelineChartToolTip(chart);
    toolTip.enableCategory(true);
}
Also used : TimelineChartToolTip(name.abuchen.portfolio.ui.util.chart.TimelineChartToolTip)

Aggregations

TimelineChartToolTip (name.abuchen.portfolio.ui.util.chart.TimelineChartToolTip)2 MessageFormat (com.ibm.icu.text.MessageFormat)1 DecimalFormat (java.text.DecimalFormat)1 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 Period (java.time.Period)1 ZoneId (java.time.ZoneId)1 ZonedDateTime (java.time.ZonedDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 TemporalAmount (java.time.temporal.TemporalAmount)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Date (java.util.Date)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 Client (name.abuchen.portfolio.model.Client)1