コード例 #1
0
 public RangeAxisData getRangeAxisData(RangeAxisConfig rangeAxisConfig) {
   if (rangeAxisConfig != null) {
     int id = rangeAxisConfig.getId();
     return rangeAxisDataMap.get(id);
   }
   return null;
 }
コード例 #2
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();
  }
コード例 #3
0
  private void rangeAxisConfigChanged(RangeAxisConfigChangeEvent rangeAxisConfigChange) {

    PlotConfiguration currentPlotConfig =
        plotInstance.getCurrentPlotConfigurationClone(); // get current plot config
    int id = rangeAxisConfigChange.getSource().getId(); // fetch id
    RangeAxisConfig currentRangeAxisConfig =
        currentPlotConfig.getRangeAxisConfigById(id); // look up range axis config

    if (currentRangeAxisConfig == null) {
      // if current range axis config is null it has been deleted afterwards in a meta change event
      debug(
          "#### CAUTION #### RANGE AXIS CONFIG CHANGE: current range axis config "
              + rangeAxisConfigChange.getSource().getLabel()
              + " with id "
              + rangeAxisConfigChange.getSource().getId()
              + " is null! Meta change event?");
      return;
    }

    // inform range axis data
    RangeAxisData rangeAxisData = getRangeAxisData(currentRangeAxisConfig);
    rangeAxisData.rangeAxisConfigChanged(rangeAxisConfigChange);

    // and also process event here
    ValueSource changeValueSource = rangeAxisConfigChange.getValueSource();
    ValueSource currentValueSource = null;
    if (changeValueSource != null) {
      id = changeValueSource.getId(); // fetch id from value source add/remove event
      currentValueSource =
          currentRangeAxisConfig.getValueSourceById(id); // look up current value source
    }
    //		else {
    //			return; // nothing to be done
    //		}

    switch (rangeAxisConfigChange.getType()) {
      case VALUE_SOURCE_ADDED:
        if (currentValueSource != null) {
          debug(
              "value source ADDED - "
                  + currentValueSource.getLabel()
                  + " ## ID: "
                  + currentValueSource.getId());
          valueSourceDataMap.put(
              currentValueSource.getId(), new ValueSourceData(currentValueSource, plotInstance));
          clearCache();
        } else {
          // if current value source is null it has been deleted afterwards in a meta change event
          debug(
              "#### CAUTION #### VALUE SOURCE ADDED: current value source"
                  + changeValueSource.getLabel()
                  + " with id "
                  + changeValueSource.getId()
                  + " is null! Meta change event?");
          return; // nothing to be done
        }
        break;
      case VALUE_SOURCE_CHANGED:
        ValueSourceChangeEvent valueSourceChange = rangeAxisConfigChange.getValueSourceChange();
        changeValueSource = valueSourceChange.getSource(); // get source
        id = changeValueSource.getId(); // fetch id from changed value source
        currentValueSource =
            currentRangeAxisConfig.getValueSourceById(id); // look up current value source

        if (currentValueSource != null) {
          debug("value source CHANGED - " + currentValueSource.getLabel() + " ## ID: " + id);
          getValueSourceData(currentValueSource)
              .valueSourceChanged(valueSourceChange, currentValueSource);
        } else {
          // if current value source is null it has been deleted afterwards in a meta change event
          debug(
              "#### CAUTION #### VALUE SOURCE CHANGED: current value source"
                  + changeValueSource.getLabel()
                  + " with id "
                  + changeValueSource.getId()
                  + " is null! Meta change event?");
          return; // nothing to be done
        }
        break;
      case VALUE_SOURCE_REMOVED:
        debug(
            "value source REMOVED - "
                + changeValueSource.getLabel()
                + " ## ID: "
                + changeValueSource.getId());
        valueSourceDataMap.remove(changeValueSource.getId());
        clearCache();
        break;
    }
  }
コード例 #4
0
  @Override
  public synchronized boolean plotConfigurationChanged(PlotConfigurationChangeEvent change) {
    if (change == null || change == lastProcessedEvent) {
      return true;
    }
    lastProcessedEvent = change;

    PlotConfiguration currentPlotConfig =
        plotInstance.getCurrentPlotConfigurationClone(); // get current plot config

    // prepare temp variables
    int id = -1;
    DimensionConfig currentDimensionConfig = null;
    RangeAxisConfig currentRangeAxis = null;

    DimensionConfig changeDimensionConfig = change.getDimensionConfig();
    if (changeDimensionConfig != null) {
      // if event is a dimension config add/remove event, get current dimension config
      // (may be null if meta event is processed and it has been deleted afterwards)
      id = changeDimensionConfig.getId();
      currentDimensionConfig = currentPlotConfig.getDefaultDimensionConfigById(id);
    }

    RangeAxisConfig changeRangeAxis = change.getRangeAxisConfig();
    if (changeRangeAxis != null) {
      // if event is a range axis config add/remove event, get current range axis config
      // (may be null if meta event is processed and it has been deleted afterwards)
      id = changeRangeAxis.getId();
      currentRangeAxis = currentPlotConfig.getRangeAxisConfigById(id);
    }

    switch (change.getType()) {
      case TRIGGER_REPLOT:
        clearCache();
        break;
      case AXES_FONT:
        break;
      case AXIS_LINE_COLOR:
        break;
      case AXIS_LINE_WIDTH:
        break;
      case FRAME_BACKGROUND_COLOR:
        break;
      case CHART_TITLE:
        break;
      case COLOR_SCHEME:
        break;
      case DATA_TABLE_EXCHANGED:
        break;
      case DIMENSION_CONFIG_ADDED:
        // if current plot configuration still contains item..
        if (currentDimensionConfig != null && id != -1) {
          // add new dimension config data to map
          dimensionConfigDataMap.put(
              id,
              new DimensionConfigData(
                  plotInstance, (DefaultDimensionConfig) currentDimensionConfig));
          debug(
              "ADDED dimension "
                  + currentDimensionConfig.getDimension().getName()
                  + " ## ID: "
                  + id);
          clearCache();
        } else {
          debug(
              "#### CAUTION ###### ADD DIMENSION CONFIG: CURRENT DIMENSIONCONFIG "
                  + changeDimensionConfig.getLabel()
                  + " with id "
                  + changeDimensionConfig.getId()
                  + " IS NULL! Processing meta event?");
        }
        break;
      case DIMENSION_CONFIG_CHANGED:
        dimensionConfigChanged(change.getDimensionChange());
        break;
      case DIMENSION_CONFIG_REMOVED:
        debug(
            "REMOVED dimension "
                + changeDimensionConfig.getDimension().getName()
                + " ## ID: "
                + changeDimensionConfig.getId());
        dimensionConfigDataMap.remove(
            changeDimensionConfig.getId()); // remove dimension config data from map
        clearCache();
        break;
      case LEGEND_CHANGED:
        break;
      case PLOT_BACKGROUND_COLOR:
        break;
      case PLOT_ORIENTATION:
        break;
      case RANGE_AXIS_CONFIG_ADDED:
        // if current plot configuration still contains item..
        if (currentRangeAxis != null && id != -1) {
          // add new range axis data to map
          debug("range axis ADDED - " + currentRangeAxis.getLabel() + " ## ID: " + id);
          rangeAxisDataMap.put(id, new RangeAxisData(currentRangeAxis, plotInstance));
          for (ValueSource valueSource :
              currentRangeAxis.getValueSources()) { // also add containing value sources data to map
            debug(
                "value source ADDED - "
                    + valueSource.getLabel()
                    + " ## ID: "
                    + valueSource.getId());
            valueSourceDataMap.put(
                valueSource.getId(), new ValueSourceData(valueSource, plotInstance));
          }
        } else {
          debug(
              "#### CAUTION ###### ADD RANGE AXIS CONFIG: CURRENT RANGEAXISCONFIG "
                  + changeRangeAxis.getLabel()
                  + " with id "
                  + changeRangeAxis.getId()
                  + " IS NULL! Processing meta event?");
        }
        break;
      case RANGE_AXIS_CONFIG_CHANGED:
        RangeAxisConfigChangeEvent rangeAxisConfigChange = change.getRangeAxisConfigChange();
        debug(
            "range axis CHANGED - "
                + rangeAxisConfigChange.getSource().getLabel()
                + " ## ID: "
                + rangeAxisConfigChange.getSource().getId());
        rangeAxisConfigChanged(rangeAxisConfigChange);
        break;
      case RANGE_AXIS_CONFIG_MOVED:
        break;
      case RANGE_AXIS_CONFIG_REMOVED:
        RangeAxisConfig rangeAxis = change.getRangeAxisConfig();
        debug("range axis REMOVED - " + rangeAxis.getLabel() + " ## ID: " + rangeAxis.getId());
        rangeAxisDataMap.remove(rangeAxis.getId()); // remove range axis config from map
        for (ValueSource valueSource :
            rangeAxis.getValueSources()) { // also remove all containing value sources from data map
          valueSourceDataMap.remove(valueSource.getId());
        }
        clearCache();
        break;
      case LINK_AND_BRUSH_SELECTION:
        break;
      case META_CHANGE:
        for (PlotConfigurationChangeEvent e : change.getPlotConfigChangeEvents()) {
          plotConfigurationChanged(e);
        }
        break;
    }

    return true;
  }
コード例 #5
0
  @Override
  protected void updatePlotConfiguration() {
    // don't do anything if updates are suspended due to batch updating
    if (suspendUpdates) {
      return;
    }

    PlotConfiguration plotConfiguration = plotInstance.getMasterPlotConfiguration();

    // value when "None" is selected
    String noSelection =
        I18N.getMessage(I18N.getGUIBundle(), "gui.plotter.column.empty_selection.label");

    // stop event processing
    boolean plotConfigurationProcessedEvents = plotConfiguration.isProcessingEvents();
    plotConfiguration.setProcessEvents(false);

    // restore crosshairs
    List<AxisParallelLineConfiguration> clonedListOfDomainLines =
        new LinkedList<AxisParallelLineConfiguration>(listOfDomainLines);
    for (AxisParallelLineConfiguration lineConfig : clonedListOfDomainLines) {
      plotConfiguration.getDomainConfigManager().getCrosshairLines().addLine(lineConfig);
    }

    // x axis column selection
    if (!xAxisColumn.equals(noSelection)) {
      plotConfiguration
          .getDimensionConfig(PlotDimension.DOMAIN)
          .setDataTableColumn(
              new DataTableColumn(currentDataTable, currentDataTable.getColumnIndex(xAxisColumn)));
      plotConfiguration.getDimensionConfig(PlotDimension.DOMAIN).setLogarithmic(xAxisLogarithmic);
    } else {
      // remove config
      if (currentRangeAxisConfig != null) {
        currentRangeAxisConfig.removeRangeAxisConfigListener(rangeAxisConfigListener);
        plotConfiguration.removeRangeAxisConfig(currentRangeAxisConfig);
        currentRangeAxisConfig = null;
      }
      plotConfiguration.setProcessEvents(plotConfigurationProcessedEvents);
      return;
    }

    // y axis column selection
    if (!yAxisColumn.equals(noSelection)) {
      RangeAxisConfig newRangeAxisConfig = new RangeAxisConfig(yAxisColumn, plotConfiguration);
      newRangeAxisConfig.addRangeAxisConfigListener(rangeAxisConfigListener);
      ValueSource valueSource;
      valueSource =
          new ValueSource(
              plotConfiguration,
              new DataTableColumn(currentDataTable, currentDataTable.getColumnIndex(yAxisColumn)),
              AggregationFunctionType.count,
              false);
      SeriesFormat sFormat = new SeriesFormat();
      valueSource.setSeriesFormat(sFormat);
      newRangeAxisConfig.addValueSource(valueSource, null);
      newRangeAxisConfig.setLogarithmicAxis(yAxisLogarithmic);

      // remove old config
      if (currentRangeAxisConfig != null) {
        currentRangeAxisConfig.removeRangeAxisConfigListener(rangeAxisConfigListener);
        plotConfiguration.removeRangeAxisConfig(currentRangeAxisConfig);
      }
      currentRangeAxisConfig = newRangeAxisConfig;
      // add new config and restore crosshairs
      List<AxisParallelLineConfiguration> clonedRangeAxisLineList =
          rangeAxisCrosshairLinesMap.get(newRangeAxisConfig.getLabel());
      if (clonedRangeAxisLineList != null) {
        for (AxisParallelLineConfiguration lineConfig : clonedRangeAxisLineList) {
          newRangeAxisConfig.getCrossHairLines().addLine(lineConfig);
        }
      }
      plotConfiguration.addRangeAxisConfig(newRangeAxisConfig);
      // remember the new config so we can remove it later again
    } else {
      // remove config
      if (currentRangeAxisConfig != null) {
        currentRangeAxisConfig.removeRangeAxisConfigListener(rangeAxisConfigListener);
        plotConfiguration.removeRangeAxisConfig(currentRangeAxisConfig);
        currentRangeAxisConfig = null;
      }
    }

    // color column selection
    if (!colorColumn.equals(noSelection)) {
      plotConfiguration.setDimensionConfig(PlotDimension.COLOR, null);
      DefaultDimensionConfig dimConfig =
          new DefaultDimensionConfig(
              plotConfiguration,
              new DataTableColumn(currentDataTable, currentDataTable.getColumnIndex(colorColumn)),
              PlotDimension.COLOR);
      dimConfig.setLogarithmic(colorLogarithmic);
      plotConfiguration.setDimensionConfig(PlotDimension.COLOR, dimConfig);
    } else {
      plotConfiguration.setDimensionConfig(PlotDimension.COLOR, null);
    }

    // general settings
    plotConfiguration.setAxesFont(styleProvider.getAxesFont());
    plotConfiguration.setTitleFont(styleProvider.getTitleFont());
    plotConfiguration.getLegendConfiguration().setLegendFont(styleProvider.getLegendFont());
    plotConfiguration.addColorSchemeAndSetActive(styleProvider.getColorScheme());
    if (styleProvider.isShowLegend()) {
      plotConfiguration.getLegendConfiguration().setLegendPosition(LegendPosition.BOTTOM);
    } else {
      plotConfiguration.getLegendConfiguration().setLegendPosition(LegendPosition.NONE);
    }
    plotConfiguration.setFrameBackgroundColor(
        ColorRGB.convertToColor(styleProvider.getFrameBackgroundColor()));
    plotConfiguration.setPlotBackgroundColor(
        ColorRGB.convertToColor(styleProvider.getPlotBackgroundColor()));
    plotConfiguration.setTitleText(styleProvider.getTitleText());

    // continue event processing
    plotConfiguration.setProcessEvents(plotConfigurationProcessedEvents);
  }