예제 #1
0
  public List<DataSeries> fromString(DataSeriesSet set, String config) {
    List<DataSeries> series = new ArrayList<>();

    if (config != null && config.trim().length() > 0) load(set, config, series);

    if (series.isEmpty())
      set.getAvailableSeries()
          .stream()
          .filter(
              s ->
                  s.getType() == DataSeries.Type.CLIENT
                          && (s.getInstance() == ClientDataSeries.TOTALS
                              || s.getInstance() == ClientDataSeries.TRANSFERALS)
                      || s.getType() == DataSeries.Type.CONSUMER_PRICE_INDEX)
          .forEach(series::add);

    return series;
  }
예제 #2
0
  private void load(DataSeriesSet set, String config, List<DataSeries> series) {
    Map<String, DataSeries> uuid2series =
        set.getAvailableSeries().stream().collect(Collectors.toMap(s -> s.getUUID(), s -> s));

    String[] items = config.split(","); // $NON-NLS-1$
    for (String item : items) {
      String[] data = item.split(";"); // $NON-NLS-1$

      String uuid = data[0];
      DataSeries s = uuid2series.get(uuid);
      if (s != null) {
        series.add(s);

        if (data.length == 4) {
          s.setColor(Colors.toRGB(data[1]));
          s.setLineStyle(LineStyle.valueOf(data[2]));
          s.setShowArea(Boolean.parseBoolean(data[3]));
        }
      }
    }
  }