<commit_before>/*
 * Copyright 2006-2020 The MZmine Development Team
 *
 * This file is part of MZmine.
 *
 * MZmine is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with MZmine; if not,
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 * USA
 */

package io.github.mzmine.modules.visualization.msms;

import com.google.common.collect.Range;
import io.github.mzmine.datamodel.RawDataFile;
import io.github.mzmine.gui.chartbasics.simplechart.SimpleXYZScatterPlot;
import io.github.mzmine.gui.chartbasics.simplechart.datasets.ColoredXYZDataset;
import io.github.mzmine.gui.chartbasics.simplechart.renderers.ColoredXYZDotRenderer;
import io.github.mzmine.main.MZmineCore;
import io.github.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerModule;
import io.github.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerParameters;
import io.github.mzmine.parameters.ParameterSet;
import io.github.mzmine.parameters.parametertypes.selectors.RawDataFilesSelectionType;
import io.github.mzmine.taskcontrol.TaskStatus;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.canvas.Canvas;
import javafx.scene.input.MouseButton;
import org.jetbrains.annotations.Nullable;
import org.jfree.chart.util.SortOrder;

public class MsMsChart extends SimpleXYZScatterPlot<MsMsDataProvider> {

  private MsMsDataProvider dataProvider;
  private ColoredXYZDataset dataset;
  private ColoredXYZDotRenderer renderer;
  private SortOrder zOrder;

  public MsMsChart(ParameterSet parameters) {
    super("MS/MS visualizer");

    MsMsXYAxisType xAxisType = parameters.getParameter(MsMsParameters.xAxisType).getValue();
    MsMsXYAxisType yAxisType = parameters.getParameter(MsMsParameters.yAxisType).getValue();
    RawDataFile[] dataFiles = parameters.getParameter(MsMsParameters.dataFiles).getValue()
        .getMatchingRawDataFiles();

    setDomainAxisLabel(xAxisType.toString());
    setRangeAxisLabel(yAxisType.toString());
    setDomainAxisNumberFormatOverride(MZmineCore.getConfiguration().getRTFormat());
    setRangeAxisNumberFormatOverride(MZmineCore.getConfiguration().getMZFormat());

    renderer = new ColoredXYZDotRenderer();

    dataProvider = new MsMsDataProvider(parameters);
    dataset = new ColoredXYZDataset(dataProvider);
    addDataset(dataset, renderer);

    getXYPlot().getDomainAxis().setUpperMargin(0);
    getXYPlot().getDomainAxis().setLowerMargin(0);
    getXYPlot().getRangeAxis().setUpperMargin(0);
    getXYPlot().getRangeAxis().setLowerMargin(0);

    // Show spectrum of the clicked data point scan
    setOnMousePressed(event -> {

      if (!event.getButton().equals(MouseButton.PRIMARY) || event.getClickCount() != 2) {
        return;
      }

      MsMsDataPoint clickedDataPoint = dataProvider.getDataPoint(getCursorPosition().getValueIndex());

      // Run spectrum module
      ParameterSet spectrumParameters =
          MZmineCore.getConfiguration().getModuleParameters(SpectraVisualizerModule.class);
      spectrumParameters.getParameter(SpectraVisualizerParameters.dataFiles)
          .setValue(RawDataFilesSelectionType.SPECIFIC_FILES, dataFiles);
      spectrumParameters.getParameter(SpectraVisualizerParameters.scanNumber)
          .setValue(clickedDataPoint.getScanNumber());
      MZmineCore.runMZmineModule(SpectraVisualizerModule.class, spectrumParameters);
    });

    // Do not show legend
    setLegendCanvas(new Canvas());
  }

  public MsMsXYAxisType getXAxisType() {
    return dataProvider.getXAxisType();
  }<commit_msg>Fix MS/MS visualizer background color<commit_after>/*
 * Copyright 2006-2020 The MZmine Development Team
 *
 * This file is part of MZmine.
 *
 * MZmine is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with MZmine; if not,
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 * USA
 */

package io.github.mzmine.modules.visualization.msms;

import com.google.common.collect.Range;
import io.github.mzmine.datamodel.RawDataFile;
import io.github.mzmine.gui.chartbasics.simplechart.SimpleXYZScatterPlot;
import io.github.mzmine.gui.chartbasics.simplechart.datasets.ColoredXYZDataset;
import io.github.mzmine.gui.chartbasics.simplechart.renderers.ColoredXYZDotRenderer;
import io.github.mzmine.main.MZmineCore;
import io.github.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerModule;
import io.github.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerParameters;
import io.github.mzmine.parameters.ParameterSet;
import io.github.mzmine.parameters.parametertypes.selectors.RawDataFilesSelectionType;
import io.github.mzmine.taskcontrol.TaskStatus;
import java.awt.Color;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.canvas.Canvas;
import javafx.scene.input.MouseButton;
import org.jetbrains.annotations.Nullable;
import org.jfree.chart.util.SortOrder;

public class MsMsChart extends SimpleXYZScatterPlot<MsMsDataProvider> {

  private MsMsDataProvider dataProvider;
  private ColoredXYZDataset dataset;
  private ColoredXYZDotRenderer renderer;
  private SortOrder zOrder;

  public MsMsChart(ParameterSet parameters) {
    super("MS/MS visualizer");

    MsMsXYAxisType xAxisType = parameters.getParameter(MsMsParameters.xAxisType).getValue();
    MsMsXYAxisType yAxisType = parameters.getParameter(MsMsParameters.yAxisType).getValue();
    RawDataFile[] dataFiles = parameters.getParameter(MsMsParameters.dataFiles).getValue()
        .getMatchingRawDataFiles();

    setDomainAxisLabel(xAxisType.toString());
    setRangeAxisLabel(yAxisType.toString());
    setDomainAxisNumberFormatOverride(MZmineCore.getConfiguration().getRTFormat());
    setRangeAxisNumberFormatOverride(MZmineCore.getConfiguration().getMZFormat());

    renderer = new ColoredXYZDotRenderer();

    dataProvider = new MsMsDataProvider(parameters);
    dataset = new ColoredXYZDataset(dataProvider);
    addDataset(dataset, renderer);

    getXYPlot().getDomainAxis().setUpperMargin(0);
    getXYPlot().getDomainAxis().setLowerMargin(0);
    getXYPlot().getRangeAxis().setUpperMargin(0);
    getXYPlot().getRangeAxis().setLowerMargin(0);

    getXYPlot().setBackgroundPaint(Color.WHITE);

    // Show spectrum of the clicked data point scan
    setOnMousePressed(event -> {

      if (!event.getButton().equals(MouseButton.PRIMARY) || event.getClickCount() != 2) {
        return;
      }

      MsMsDataPoint clickedDataPoint = dataProvider.getDataPoint(getCursorPosition().getValueIndex());

      // Run spectrum module
      ParameterSet spectrumParameters =
          MZmineCore.getConfiguration().getModuleParameters(SpectraVisualizerModule.class);
      spectrumParameters.getParameter(SpectraVisualizerParameters.dataFiles)
          .setValue(RawDataFilesSelectionType.SPECIFIC_FILES, dataFiles);
      spectrumParameters.getParameter(SpectraVisualizerParameters.scanNumber)
          .setValue(clickedDataPoint.getScanNumber());
      MZmineCore.runMZmineModule(SpectraVisualizerModule.class, spectrumParameters);
    });

    // Do not show legend
    setLegendCanvas(new Canvas());
  }

  public MsMsXYAxisType getXAxisType() {
    return dataProvider.getXAxisType();
  }
{'fraction_non_alphanumeric': 0.08998178506375228, 'fraction_numerical': 0.006071645415907711, 'mean_word_length': 5.155455904334828, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7661953', 'n_tokens_mistral': 2399, 'n_tokens_neox': 2313, 'n_words': 505}