<commit_before>/*
 * Copyright 2006-2015 The MZmine 2 Development Team
 * 
 * This file is part of MZmine 2.
 * 
 * MZmine 2 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 2 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 2; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA 02110-1301 USA
 */

package net.sf.mzmine.util.interpolatinglookuppaintscale;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.NumberFormat;
import java.util.TreeMap;
import java.util.logging.Logger;

import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import net.sf.mzmine.util.ExitCode;

public class InterpolatingLookupPaintScaleSetupDialog extends JDialog implements
	ActionListener, ListSelectionListener {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public static final int VALUEFIELD_COLUMNS = 4;

    private Logger logger = Logger.getLogger(this.getClass().getName());

    private JFormattedTextField fieldValue;

    private JScrollPane scrollpaneLookupValues;
    private JTable tableLookupValues;
    private InterpolatingLookupPaintScaleSetupDialogTableModel tableModel;

    private TreeMap<Double, Color> lookupTable;

    private JButton buttonAddModify;
    private JButton buttonDelete;
    private JButton buttonColor;
    private JButton buttonOK;
    private JButton buttonCancel;

    private ExitCode exitCode = ExitCode.CANCEL;

    public InterpolatingLookupPaintScaleSetupDialog(JFrame parent,
	    InterpolatingLookupPaintScale paintScale) {
	super(parent, "Select colors for paint scale", true);

	Double[] lookupValues = paintScale.getLookupValues();
	for (Double lookupValue : lookupValues) {
	    Color color = (Color) paintScale.getPaint(lookupValue);
	    lookupTable.put(lookupValue, color);
	}

	// Panel for controls and list
	JPanel panelControlsAndList = new JPanel(new BorderLayout());
	add(panelControlsAndList, BorderLayout.CENTER);

	// Sub-panel for controls
	JPanel panelControls = new JPanel(new BorderLayout());
	panelControlsAndList.add(panelControls, BorderLayout.NORTH);

	// Sub-sub panel for value and color chooser controls
	JPanel panelValueAndColor = new JPanel(new FlowLayout(FlowLayout.LEFT));
	panelControls.add(panelValueAndColor, BorderLayout.NORTH);

	JLabel labelValue = new JLabel("Value: ");
	panelValueAndColor.add(labelValue);
	fieldValue = new JFormattedTextField(NumberFormat.getNumberInstance());
	fieldValue.setColumns(VALUEFIELD_COLUMNS);
	panelValueAndColor.add(fieldValue);

	buttonColor = new JButton("Select color");
	buttonColor.setBackground(new Color(255, 255, 255));
	buttonColor.addActionListener(this);
	panelValueAndColor.add(buttonColor);

	// JPanel panelAddRemoveButtons = new JPanel(new
	// FlowLayout(FlowLayout.LEFT));
	buttonAddModify = new JButton("Add/Modify");
	buttonAddModify.addActionListener(this);
	buttonDelete = new JButton("Delete");
	buttonDelete.addActionListener(this);
	panelValueAndColor.add(new JPanel());
	panelValueAndColor.add(buttonAddModify);
	panelValueAndColor.add(buttonDelete);

	// Sub-panel for scrollpane & list
	JPanel panelList = new JPanel();
	lookupTable = new TreeMap<Double, Color>();
<commit_msg>Fixed null error in logratio plots<commit_after>/*
 * Copyright 2006-2015 The MZmine 2 Development Team
 * 
 * This file is part of MZmine 2.
 * 
 * MZmine 2 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 2 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 2; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA 02110-1301 USA
 */

package net.sf.mzmine.util.interpolatinglookuppaintscale;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.NumberFormat;
import java.util.TreeMap;
import java.util.logging.Logger;

import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import net.sf.mzmine.util.ExitCode;

public class InterpolatingLookupPaintScaleSetupDialog extends JDialog implements
	ActionListener, ListSelectionListener {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public static final int VALUEFIELD_COLUMNS = 4;

    private Logger logger = Logger.getLogger(this.getClass().getName());

    private JFormattedTextField fieldValue;

    private JScrollPane scrollpaneLookupValues;
    private JTable tableLookupValues;
    private InterpolatingLookupPaintScaleSetupDialogTableModel tableModel;

    private TreeMap<Double, Color> lookupTable = new TreeMap<Double, Color>();

    private JButton buttonAddModify;
    private JButton buttonDelete;
    private JButton buttonColor;
    private JButton buttonOK;
    private JButton buttonCancel;

    private ExitCode exitCode = ExitCode.CANCEL;

    public InterpolatingLookupPaintScaleSetupDialog(JFrame parent,
	    InterpolatingLookupPaintScale paintScale) {
	super(parent, "Select colors for paint scale", true);

	Double[] lookupValues = paintScale.getLookupValues();
	for (Double lookupValue : lookupValues) {
	    Color color = (Color) paintScale.getPaint(lookupValue);
	    lookupTable.put(lookupValue, color);
	}

	// Panel for controls and list
	JPanel panelControlsAndList = new JPanel(new BorderLayout());
	add(panelControlsAndList, BorderLayout.CENTER);

	// Sub-panel for controls
	JPanel panelControls = new JPanel(new BorderLayout());
	panelControlsAndList.add(panelControls, BorderLayout.NORTH);

	// Sub-sub panel for value and color chooser controls
	JPanel panelValueAndColor = new JPanel(new FlowLayout(FlowLayout.LEFT));
	panelControls.add(panelValueAndColor, BorderLayout.NORTH);

	JLabel labelValue = new JLabel("Value: ");
	panelValueAndColor.add(labelValue);
	fieldValue = new JFormattedTextField(NumberFormat.getNumberInstance());
	fieldValue.setColumns(VALUEFIELD_COLUMNS);
	panelValueAndColor.add(fieldValue);

	buttonColor = new JButton("Select color");
	buttonColor.setBackground(new Color(255, 255, 255));
	buttonColor.addActionListener(this);
	panelValueAndColor.add(buttonColor);

	// JPanel panelAddRemoveButtons = new JPanel(new
	// FlowLayout(FlowLayout.LEFT));
	buttonAddModify = new JButton("Add/Modify");
	buttonAddModify.addActionListener(this);
	buttonDelete = new JButton("Delete");
	buttonDelete.addActionListener(this);
	panelValueAndColor.add(new JPanel());
	panelValueAndColor.add(buttonAddModify);
	panelValueAndColor.add(buttonDelete);

	// Sub-panel for scrollpane & list
	JPanel panelList = new JPanel();

{'fraction_non_alphanumeric': 0.08390349297803384, 'fraction_numerical': 0.008642419877565718, 'mean_word_length': 5.190193164933135, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2899029', 'n_tokens_mistral': 2455, 'n_tokens_neox': 2323, 'n_words': 692}