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

package io.github.mzmine.modules.dataprocessing.featdet_imagebuilder.imageplot;

import java.awt.Color;
import java.awt.Font;
import java.text.DecimalFormat;
import java.util.Arrays;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.title.PaintScaleLegend;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.data.xy.XYZDataset;
import com.google.common.collect.Range;
import io.github.mzmine.gui.chartbasics.chartthemes.EStandardChartTheme;
import io.github.mzmine.gui.chartbasics.chartutils.XYBlockRendererSmallBlocks;
import io.github.mzmine.gui.chartbasics.chartutils.paintscales.PaintScale;
import io.github.mzmine.gui.chartbasics.chartutils.paintscales.PaintScaleFactory;
import io.github.mzmine.gui.chartbasics.gui.javafx.EChartViewer;
import io.github.mzmine.main.MZmineCore;

/*
 * @author <NAME> (<EMAIL>)
 */
public class ImageHeatMapPlot extends EChartViewer {

  private final XYPlot plot;
  static final Font legendFont = new Font("SansSerif", Font.PLAIN, 8);
  private PaintScaleLegend legend;
  private XYBlockRendererSmallBlocks blockRenderer;
  private double dataPointHeight;
  private double dataPointWidth;
  private PaintScale paintScale;

  public ImageHeatMapPlot(XYZDataset dataset, PaintScale paintScale, double dataPointWidth,
      double dataPointHeight) {

    super(ChartFactory.createScatterPlot("", "[\u00B5m]", "[\u00B5m]", dataset,
        PlotOrientation.VERTICAL, true, true, true));
    this.dataPointWidth = dataPointWidth;
    this.dataPointHeight = dataPointHeight;
    this.paintScale = paintScale;
    JFreeChart chart = getChart();
    // copy and sort z-Values for min and max of the paint scale
    double[] copyZValues = new double[dataset.getItemCount(0)];
    for (int i = 0; i < dataset.getItemCount(0); i++) {
      copyZValues[i] = dataset.getZValue(0, i);
    }
    Arrays.sort(copyZValues);
    double min = copyZValues[0];
    double max = copyZValues[copyZValues.length - 1];

    updatePaintScale(paintScale);
    PaintScaleFactory paintScaleFactoy = new PaintScaleFactory();
    paintScaleFactoy.createColorsForPaintScale(paintScale);
    // contourColors = XYBlockPixelSizePaintScales.scaleAlphaForPaintScale(contourColors);

    plot = chart.getXYPlot();
    EStandardChartTheme theme = MZmineCore.getConfiguration().getDefaultChartTheme();
    theme.apply(chart);
    ((NumberAxis) chart.getXYPlot().getRangeAxis())
        .setNumberFormatOverride(new DecimalFormat("0.0E0"));
    ((NumberAxis) chart.getXYPlot().getDomainAxis())
        .setNumberFormatOverride(new DecimalFormat("0.0E0"));
    setPixelRenderer();
    prepareLegend(min, max);

    blockRenderer.setPaintScale(paintScale);
    plot.setRenderer(blockRenderer);
    plot.setBackgroundPaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));<commit_msg>optimized zoom<commit_after>/*
 * Copyright 2006-2020 The MZmine Development Team
 * 
 * This file is part of MZmine 3.
 * 
 * MZmine 3 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 3 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 3; if not,
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 * USA
 */

package io.github.mzmine.modules.dataprocessing.featdet_imagebuilder.imageplot;

import java.awt.Color;
import java.awt.Font;
import java.text.DecimalFormat;
import java.util.Arrays;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.title.PaintScaleLegend;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.data.xy.XYZDataset;
import com.google.common.collect.Range;
import io.github.mzmine.gui.chartbasics.chartthemes.EStandardChartTheme;
import io.github.mzmine.gui.chartbasics.chartutils.XYBlockRendererSmallBlocks;
import io.github.mzmine.gui.chartbasics.chartutils.paintscales.PaintScale;
import io.github.mzmine.gui.chartbasics.chartutils.paintscales.PaintScaleFactory;
import io.github.mzmine.gui.chartbasics.gui.javafx.EChartViewer;
import io.github.mzmine.main.MZmineCore;

/*
 * @author <NAME> (<EMAIL>)
 */
public class ImageHeatMapPlot extends EChartViewer {

  private final XYPlot plot;
  static final Font legendFont = new Font("SansSerif", Font.PLAIN, 8);
  private PaintScaleLegend legend;
  private XYBlockRendererSmallBlocks blockRenderer;
  private double dataPointHeight;
  private double dataPointWidth;
  private PaintScale paintScale;

  public ImageHeatMapPlot(XYZDataset dataset, PaintScale paintScale, double dataPointWidth,
      double dataPointHeight) {

    super(ChartFactory.createScatterPlot("", "[\u00B5m]", "[\u00B5m]", dataset,
        PlotOrientation.VERTICAL, true, true, true));
    this.dataPointWidth = dataPointWidth;
    this.dataPointHeight = dataPointHeight;
    this.paintScale = paintScale;
    JFreeChart chart = getChart();
    // copy and sort z-Values for min and max of the paint scale and axis
    double[] copyXValues = new double[dataset.getItemCount(0)];
    double[] copyYValues = new double[dataset.getItemCount(0)];
    double[] copyZValues = new double[dataset.getItemCount(0)];
    for (int i = 0; i < dataset.getItemCount(0); i++) {
      copyXValues[i] = dataset.getXValue(0, i);
      copyYValues[i] = dataset.getYValue(0, i);
      copyZValues[i] = dataset.getZValue(0, i);
    }
    Arrays.sort(copyXValues);
    Arrays.sort(copyYValues);
    Arrays.sort(copyZValues);
    double min = copyZValues[0];
    double max = copyZValues[copyZValues.length - 1];

    updatePaintScale(paintScale);
    PaintScaleFactory paintScaleFactoy = new PaintScaleFactory();
    paintScaleFactoy.createColorsForPaintScale(paintScale);

    plot = chart.getXYPlot();
    EStandardChartTheme theme = MZmineCore.getConfiguration().getDefaultChartTheme();
    theme.apply(chart);
    ((NumberAxis) chart.getXYPlot().getRangeAxis())
        .setNumberFormatOverride(new DecimalFormat("0.0E0"));
    ((NumberAxis) chart.getXYPlot().getRangeAxis()).setRange(0,
        copyYValues[copyYValues.length - 1]);
    ((NumberAxis) chart.getXYPlot().getDomainAxis())
        .setNumberFormatOverride(new DecimalFormat("0.0E0"));
    ((NumberAxis) chart.getXYPlot().getDomainAxis()).setRange(0,
        copyXValues[copyXValues.length - 1]);

    setPixelRenderer();
    prepareLegend(min, max);

    blockRenderer.setPaintScale(paintScale);
    plot.setRenderer(blockRenderer);
    plot.setBackgroundPaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
{'fraction_non_alphanumeric': 0.10241182886922798, 'fraction_numerical': 0.012362137922676038, 'mean_word_length': 4.683195592286501, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6653388', 'n_tokens_mistral': 2618, 'n_tokens_neox': 2500, 'n_words': 624}