コード例 #1
0
  public PlotData(PlotInstance plotInstance, DataTable dataTable) {
    if (plotInstance == null) {
      throw new IllegalArgumentException("null not allowed for plotInstance");
    }
    this.plotInstance = plotInstance;
    plotInstance.setPlotData(this);
    PlotConfiguration plotConfiguration = plotInstance.getMasterPlotConfiguration();
    //		if (plotConfiguration.getPrioritizedListenerCount() > 0) {
    //			plotConfiguration.clearPrioritizedListeners();
    //		}
    plotConfiguration.addPlotConfigurationListener(this, true);

    this.originalDataTable = dataTable;
    originalDataTable.addDataTableListener(this, true);

    valueMappingDataTable = new ValueMappingDataTableView(originalDataTable);
    for (int i = 0; i < valueMappingDataTable.getColumnNumber(); ++i) {
      if (valueMappingDataTable.isNominal(i)) {
        valueMappingDataTable.setMappingProvider(
            i, new NominalSortingDataTableMapping(valueMappingDataTable, i, true));
      }
    }

    // add filtered data table view to view stack
    filteredDataTableView = new FilteredDataTable(valueMappingDataTable);

    // add sorted data table view on view stack (without sort provider for now)
    sortedDataTableView = new SortedDataTableView(filteredDataTableView, null);
    sortedDataTableView.addDataTableListener(this, true);

    // init valueSourceDataMap
    for (ValueSource valueSource : plotConfiguration.getAllValueSources()) {
      ValueSourceData valueSourceData = new ValueSourceData(valueSource, plotInstance);
      valueSourceDataMap.put(valueSource.getId(), valueSourceData);
    }

    // init dimensionConfigDataMap
    for (DefaultDimensionConfig dimensionConfig :
        plotConfiguration.getDefaultDimensionConfigs().values()) {
      DimensionConfigData dimensionConfigData =
          new DimensionConfigData(plotInstance, dimensionConfig);
      dimensionConfigDataMap.put(dimensionConfig.getId(), dimensionConfigData);
    }
    DefaultDimensionConfig domainConfig;
    domainConfig = plotConfiguration.getDomainConfigManager().getDomainConfig(true);
    dimensionConfigDataMap.put(
        domainConfig.getId(), new DimensionConfigData(plotInstance, domainConfig));
    domainConfig = plotConfiguration.getDomainConfigManager().getDomainConfig(false);
    dimensionConfigDataMap.put(
        domainConfig.getId(), new DimensionConfigData(plotInstance, domainConfig));

    // init DomainConfigManagerData
    domainConfigManagerData = new DomainConfigManagerData(plotInstance);

    // init RangeAxisDataMap
    for (RangeAxisConfig rangeAxisConfig : plotConfiguration.getRangeAxisConfigs()) {
      RangeAxisData rangeAxisData = new RangeAxisData(rangeAxisConfig, plotInstance);
      rangeAxisDataMap.put(rangeAxisConfig.getId(), rangeAxisData);
    }

    clearCache();
  }
コード例 #2
0
  private List<Set<PlotDimension>> findCompatibleDimensions(
      PlotConfiguration plotConfiguration, List<ValueSource> allValueSources) {
    Map<PlotDimension, DefaultDimensionConfig> dimensionConfigMap =
        plotConfiguration.getDefaultDimensionConfigs();

    // find all Dimensions for which we create a legend item
    List<Set<PlotDimension>> dimensionsWithLegend = new LinkedList<Set<PlotDimension>>();
    for (Entry<PlotDimension, DefaultDimensionConfig> dimensionEntry :
        dimensionConfigMap.entrySet()) {
      PlotDimension dimension = dimensionEntry.getKey();
      DefaultDimensionConfig dimensionConfig = dimensionEntry.getValue();

      boolean createLegend = false;
      if (dimensionConfig.isGrouping()) {
        createLegend = true;
      } else {
        for (ValueSource valueSource : allValueSources) {
          if (!valueSource.isUsingDomainGrouping()) {
            createLegend = true;
            break;
          }
        }
      }

      if (createLegend) {
        if (!dimensionConfig.isNominal()) {
          Set<PlotDimension> newSet = new HashSet<DimensionConfig.PlotDimension>();
          newSet.add(dimension);
          dimensionsWithLegend.add(newSet);
        } else {
          // iterate over list and find dimensions with compatible properties
          boolean compatibleToSomething = false;
          for (Set<PlotDimension> dimensionSet : dimensionsWithLegend) {
            boolean compatible = true;
            for (PlotDimension comparedDimension : dimensionSet) {
              DefaultDimensionConfig comparedDimensionConfig =
                  (DefaultDimensionConfig) plotConfiguration.getDimensionConfig(comparedDimension);
              if (!comparedDimensionConfig.isNominal()) {
                compatible = false;
                break;
              }
              if (!dimensionConfig
                  .getDataTableColumn()
                  .equals(comparedDimensionConfig.getDataTableColumn())) {
                compatible = false;
                break;
              } else if (comparedDimensionConfig.isGrouping()
                  && comparedDimensionConfig.getGrouping() instanceof DistinctValueGrouping
                  && !dimensionConfig.isGrouping()
                  && dimensionConfig.isNominal()) {
                compatible = true;
              } else if (dimensionConfig.isGrouping()
                  && dimensionConfig.getGrouping() instanceof DistinctValueGrouping
                  && !comparedDimensionConfig.isGrouping()
                  && comparedDimensionConfig.isNominal()) {
                compatible = true;
              } else if (dimensionConfig.isGrouping() != comparedDimensionConfig.isGrouping()) {
                compatible = false;
                break;
              } else if (!dimensionConfig.isGrouping()) {
                compatible = true;
              } else if (dimensionConfig
                  .getGrouping()
                  .equals(comparedDimensionConfig.getGrouping())) {
                compatible = true;
              } else {
                compatible = false;
                break;
              }
            }
            if (compatible) {
              dimensionSet.add(dimension);
              compatibleToSomething = true;
              break;
            }
          }
          if (!compatibleToSomething) {
            Set<PlotDimension> newSet = new HashSet<DimensionConfig.PlotDimension>();
            newSet.add(dimension);
            dimensionsWithLegend.add(newSet);
          }
        }
      }
    }
    return dimensionsWithLegend;
  }