<commit_before>package de.mpicbg.tds.knime.hcstools.visualization.heatmapviewer;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.Point2D;

/**
 * User: <NAME>
 * Date: 12/7/12
 * Time: 21:09
 *
 * Class to create a panel with a color gradient to produce a color bar
 */

public class ColorGradientPanel extends JPanel{

    private LinearGradientPaint gradientPaint;
    private static final Dimension dimension = new Dimension(400, 30);


    // Constructors
    public ColorGradientPanel() {
        initialize();
    }

    public ColorGradientPanel(LinearGradientPaint paint) {
        this();
        configure(paint);
    }


    // Utilities
    private void initialize() {
        setMinimumSize(dimension);
    }

    public void configure(LinearGradientPaint painter) {
        setGradientPaint(painter);
    }

    public void setGradientPaint(LinearGradientPaint painter) {
        gradientPaint = painter;
    }

    public LinearGradientPaint getGradientPaint() {
        return gradientPaint;
    }

    // Overwrite the JPanel renderer
    @Override
    public void paintComponent(Graphics graphics) {
        // Create the 2D copy
        Graphics2D graphics2D = (Graphics2D) graphics.create();

        // Create a new gradient painter with the current panel width.
        Point2D sta = new Point2D.Double(0, 0);
        Point2D sto = new Point2D.Double(getWidth(), 0);
        float[] pos = gradientPaint.getFractions();
        Color[] col = gradientPaint.getColors();
        LinearGradientPaint gradient = new LinearGradientPaint(sta, sto, pos, col);

        // Render the graphics
        graphics2D.setPaint(gradient);
        graphics2D.fillRect(0, 0, getWidth(), getHeight());

        // Dispose of copy
        graphics2D.dispose();
    }


    public static void main(String[] args) {
        ColorGradientDialog dialog = new ColorGradientDialog();
        dialog.setVisible(true);
        JFrame frame = new JFrame("ColorGradientToolBar Test");
        frame.setSize(dimension);
        if (dialog.getGradientPainter() == null) {
            frame.add(new JLabel("Well, from nothing comes nothing."));
        } else {
            ColorGradientPanel bar = new ColorGradientPanel(dialog.getGradientPainter());
            frame.add(bar);
        }
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

}<commit_msg>adding default color gradient configurations<commit_after>package de.mpicbg.tds.knime.hcstools.visualization.heatmapviewer;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.Point2D;

/**
 * User: <NAME>
 * Date: 12/7/12
 * Time: 21:09
 *
 * Class to create a panel with a color gradient to produce a color bar
 */

public class ColorGradientPanel extends JPanel{

    private LinearGradientPaint gradientPaint;

    // Defaults
    private static final Dimension dimension = new Dimension(400, 30);
    private static final Color[] defaultColors = {new Color(0,255,0),
                                                  new Color(0,0,0),
                                                  new Color(255, 0,0)};
    private static final float[] defaultPositions = new float[] {0, (float) 0.5, 1};


    // Constructors
    public ColorGradientPanel() {
        initialize();
    }

    public ColorGradientPanel(LinearGradientPaint paint) {
        this();
        configure(paint);
    }


    // Utilities
    private void initialize() {
        gradientPaint = new LinearGradientPaint(new Point2D.Double(0,0),
                                                new Point2D.Double(dimension.getWidth(), 0),
                                                defaultPositions,
                                                defaultColors);
        setMinimumSize(dimension);
    }

    public void configure(LinearGradientPaint painter) {
        setGradientPaint(painter);
    }

    public void setGradientPaint(LinearGradientPaint painter) {
        gradientPaint = painter;
    }

    public LinearGradientPaint getGradientPaint() {
        return gradientPaint;
    }

    // Overwrite the JPanel renderer
    @Override
    public void paintComponent(Graphics graphics) {
        // Create the 2D copy
        Graphics2D graphics2D = (Graphics2D) graphics.create();

        // Create a new gradient painter with the current panel width.
        Point2D sta = new Point2D.Double(0, 0);
        Point2D sto = new Point2D.Double(getWidth(), 0);
        float[] pos = gradientPaint.getFractions();
        Color[] col = gradientPaint.getColors();
        LinearGradientPaint gradient = new LinearGradientPaint(sta, sto, pos, col);

        // Render the graphics
        graphics2D.setPaint(gradient);
        graphics2D.fillRect(0, 0, getWidth(), getHeight());

        // Dispose of copy
        graphics2D.dispose();
    }


    public static void main(String[] args) {
        ColorGradientPanel bar = new ColorGradientPanel();
        JFrame frame = new JFrame("ColorGradientToolBar Test");
        frame.setSize(dimension);
        frame.add(bar);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

}
{'fraction_non_alphanumeric': 0.09530253237966364, 'fraction_numerical': 0.016238159675236806, 'mean_word_length': 2.4061882817643188, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7593843', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1343, 'n_words': 360}