コード例 #1
0
    @Override
    public void menuAboutToShow(IMenuManager manager) {
      manager.add(
          new Action(Messages.MenuExportChartData) {
            @Override
            public void run() {
              ScatterChartCSVExporter exporter = new ScatterChartCSVExporter(chart);
              exporter.setValueFormat(new DecimalFormat("0.##########%")); // $NON-NLS-1$
              exporter.export(getTitle() + ".csv"); // $NON-NLS-1$
            }
          });

      Set<Class<?>> exportTypes =
          new HashSet<Class<?>>(
              Arrays.asList(
                  new Class<?>[] { //
                    Client.class,
                    Security.class,
                    Portfolio.class,
                    Account.class,
                    Classification.class
                  }));

      for (DataSeries series : picker.getSelectedDataSeries()) {
        if (exportTypes.contains(series.getType())) addMenu(manager, series);
      }

      manager.add(new Separator());
      chart.exportMenuAboutToShow(manager, getTitle());
    }
コード例 #2
0
 private void addScatterSeries(DataSeries item, PerformanceIndex index) {
   Volatility volatility = index.getVolatility();
   ILineSeries series =
       chart.addScatterSeries(
           new double[] {volatility.getStandardDeviation()},
           new double[] {index.getFinalAccumulatedPercentage()},
           item.getLabel());
   item.configure(series);
 }
コード例 #3
0
  private void addPortfolio(DataSeries item, Portfolio portfolio, List<Exception> warnings) {
    Object cacheKey = item.isPortfolioPlus() ? portfolio.getUUID() : portfolio;
    PerformanceIndex portfolioIndex = dataCache.get(cacheKey);

    if (portfolioIndex == null) {
      portfolioIndex =
          item.isPortfolioPlus()
              ? PerformanceIndex //
                  .forPortfolioPlusAccount(getClient(), portfolio, getReportingPeriod(), warnings)
              : PerformanceIndex.forPortfolio(
                  getClient(), portfolio, getReportingPeriod(), warnings);
      dataCache.put(cacheKey, portfolioIndex);
    }

    addScatterSeries(item, portfolioIndex);
  }
コード例 #4
0
 private void addMenu(IMenuManager manager, final DataSeries series) {
   manager.add(
       new Action(MessageFormat.format(Messages.LabelExport, series.getLabel())) {
         @Override
         public void run() {
           exportDataSeries(series);
         }
       });
 }
コード例 #5
0
    private void exportDataSeries(DataSeries series) {
      AbstractCSVExporter exporter =
          new AbstractCSVExporter() {
            @Override
            protected void writeToFile(File file) throws IOException {
              PerformanceIndex index = null;

              if (series.getType() == Client.class) index = dataCache.get(Client.class);
              else if (series.isPortfolioPlus())
                index = dataCache.get(((Portfolio) series.getInstance()).getUUID());
              else if (series.getType() == Security.class && !series.isBenchmark())
                index = dataCache.get(((Security) series.getInstance()).getUUID());
              else index = dataCache.get(series.getInstance());

              index.exportVolatilityData(file);
            }

            @Override
            protected Control getControl() {
              return ExportDropDown.this.getToolBar();
            }
          };
      exporter.export(getTitle() + "_" + series.getLabel() + ".csv"); // $NON-NLS-1$ //$NON-NLS-2$
    }
コード例 #6
0
 private void addSecurity(DataSeries item, Security security, List<Exception> warnings) {
   if (item.isBenchmark()) addSecurityBenchmark(item, security, warnings);
   else addSecurityPerformance(item, security, warnings);
 }
コード例 #7
0
  private void setChartSeries() {
    List<Exception> warnings = new ArrayList<Exception>();

    for (DataSeries item : picker.getSelectedDataSeries()) {
      if (item.getType() == Client.class)
        addClient(item, (ClientDataSeries) item.getInstance(), warnings);
      else if (item.getType() == Security.class)
        addSecurity(item, (Security) item.getInstance(), warnings);
      else if (item.getType() == Portfolio.class)
        addPortfolio(item, (Portfolio) item.getInstance(), warnings);
      else if (item.getType() == Account.class)
        addAccount(item, (Account) item.getInstance(), warnings);
      else if (item.getType() == Classification.class)
        addClassification(item, (Classification) item.getInstance(), warnings);
    }

    PortfolioPlugin.log(warnings);
  }