Search in sources :

Example 1 with ClientFilterMenu

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

the class DataSeriesSet method buildCommonDataSeries.

private void buildCommonDataSeries(Client client, IPreferenceStore preferences, ColorWheel wheel) {
    int index = client.getSecurities().size();
    for (Security security : client.getSecurities()) {
        // as equity data series (only as benchmark)
        if (security.getCurrencyCode() == null)
            continue;
        availableSeries.add(new // 
        DataSeries(// 
        DataSeries.Type.SECURITY, // 
        security, // 
        security.getName(), wheel.getRGB(index++)));
    }
    for (Portfolio portfolio : client.getPortfolios()) availableSeries.add(new // 
    DataSeries(// 
    DataSeries.Type.PORTFOLIO, // 
    portfolio, // 
    portfolio.getName(), wheel.getRGB(index++)));
    // portfolio + reference account
    for (Portfolio portfolio : client.getPortfolios()) {
        DataSeries series = new DataSeries(DataSeries.Type.PORTFOLIO_PLUS_ACCOUNT, portfolio, // $NON-NLS-1$
        portfolio.getName() + " + " + portfolio.getReferenceAccount().getName(), wheel.getRGB(index++));
        availableSeries.add(series);
    }
    // custom client filters
    ClientFilterMenu menu = new ClientFilterMenu(client, preferences);
    // quick fix: users can create duplicate client filters that end up to
    // have the same UUID. Avoid adding both violates the precondition that
    // every data series must have a unique id
    Set<String> addedSeries = new HashSet<>();
    for (ClientFilterMenu.Item item : menu.getCustomItems()) {
        DataSeries series = new DataSeries(DataSeries.Type.CLIENT_FILTER, item, item.getLabel(), wheel.getRGB(index++));
        if (addedSeries.add(series.getUUID()))
            availableSeries.add(series);
    }
    for (Account account : client.getAccounts()) availableSeries.add(new DataSeries(DataSeries.Type.ACCOUNT, account, account.getName(), wheel.getRGB(index++)));
    for (Taxonomy taxonomy : client.getTaxonomies()) {
        taxonomy.foreach(new Taxonomy.Visitor() {

            @Override
            public void visit(Classification classification) {
                if (classification.getParent() == null)
                    return;
                availableSeries.add(new DataSeries(DataSeries.Type.CLASSIFICATION, classification, classification.getName(), Colors.toRGB(classification.getColor())));
            }
        });
    }
}
Also used : Account(name.abuchen.portfolio.model.Account) Taxonomy(name.abuchen.portfolio.model.Taxonomy) Portfolio(name.abuchen.portfolio.model.Portfolio) Security(name.abuchen.portfolio.model.Security) Classification(name.abuchen.portfolio.model.Classification) ClientDataSeries(name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries) ClientFilterMenu(name.abuchen.portfolio.ui.util.ClientFilterMenu) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Account (name.abuchen.portfolio.model.Account)1 Classification (name.abuchen.portfolio.model.Classification)1 Portfolio (name.abuchen.portfolio.model.Portfolio)1 Security (name.abuchen.portfolio.model.Security)1 Taxonomy (name.abuchen.portfolio.model.Taxonomy)1 ClientFilterMenu (name.abuchen.portfolio.ui.util.ClientFilterMenu)1 ClientDataSeries (name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries)1