<commit_before>/*
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2009 - 2013 Board of Regents of the University of
 * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
 * Institute of Molecular Cell Biology and Genetics.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are
 * those of the authors and should not be interpreted as representing official
 * policies, either expressed or implied, of any organization.
 * #L%
 */

package imagej.core.commands.display;

import imagej.command.Command;
import imagej.command.InteractiveCommand;
import imagej.data.Dataset;
import imagej.data.display.ImageDisplay;
import imagej.data.display.ImageDisplayService;
import imagej.data.display.OverlayService;
import imagej.data.event.DatasetRestructuredEvent;
import imagej.data.event.DatasetUpdatedEvent;
import imagej.data.widget.HistogramBundle;
import imagej.module.MutableModuleItem;
import imagej.ui.UIService;
import imagej.widget.Button;
import net.imglib2.Cursor;
import net.imglib2.RandomAccess;
import net.imglib2.histogram.Histogram1d;
import net.imglib2.histogram.Real1dBinMapper;
import net.imglib2.meta.Axes;
import net.imglib2.ops.pointset.HyperVolumePointSet;
import net.imglib2.ops.pointset.PointSetIterator;
import net.imglib2.type.numeric.RealType;

import org.scijava.ItemVisibility;
import org.scijava.event.EventHandler;
import org.scijava.plugin.Menu;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

// TODO
// 1) some button commands unimplemented
// 2) dialog looks ugly

// TODO Add these features from IJ1
// [++] The horizontal LUT bar below the X-axis is scaled to reflect the display
// range of the image.
// [++] The modal gray value is displayed
//
// TODO This does lots of its own calcs. Rely on the final Histogram
// implementation when it's settled. Grant's impl used Larry's histogram. It
// also had a multithreaded stat calc method.

/**
 * Histogram plotter.
 * 
 * @author <NAME>
 * @author <NAME>
 */
@Plugin(type = Command.class, menu = {
	@Menu(label = "Analyze"),
	@Menu(label = "Histogram Plot", accelerator = "control shift alt H",
		weight = 0) })
public class HistogramPlot<T extends RealType<T>> extends InteractiveCommand
{

	// -- fields that are Parameters --

	@Parameter
	private UIService uiService;

	@Parameter
	private ImageDisplayService imageDisplayService;

	@Parameter
	private OverlayService overlayService;

	@Parameter
	private ImageDisplay display;

	@Parameter(label = "Histogram", initializer = "initBundle")
	private HistogramBundle bundle;

	@Parameter(visibility = ItemVisibility.MESSAGE)
	private String pixelsStr;

	@Parameter(visibility = ItemVisibility.MESSAGE)
	private String minStr;

	@Parameter(visibility = ItemVisibility.MESSAGE)
	private String maxStr;

	@Parameter(visibility = ItemVisibility.MESSAGE)
	private String meanStr;

	@Parameter(visibility = ItemVisibility.MESSAGE)
	private String stdDevStr;

	@Parameter(visibility = ItemVisibility.MESSAGE)
	private String binsStr;

	@Parameter(visibility = ItemVisibility.MESSAGE)
	private String binWidthStr;

	@Parameter(label = "Static", callback = "liveClicked")
	private Button liveButton;

	@Parameter(label = "List", callback = "listClicked")
	private Button listButton;

	@Parameter(label = "Copy", callback = "copyClicked")
	private Button copyButton;

	@Parameter(label = "Log", callback = "logClicked")
	private Button logButton;<commit_msg>Stop persisting HistogramPlot statistics fields<commit_after>/*
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2009 - 2013 Board of Regents of the University of
 * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
 * Institute of Molecular Cell Biology and Genetics.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are
 * those of the authors and should not be interpreted as representing official
 * policies, either expressed or implied, of any organization.
 * #L%
 */

package imagej.core.commands.display;

import imagej.command.Command;
import imagej.command.InteractiveCommand;
import imagej.data.Dataset;
import imagej.data.display.ImageDisplay;
import imagej.data.display.ImageDisplayService;
import imagej.data.display.OverlayService;
import imagej.data.event.DatasetRestructuredEvent;
import imagej.data.event.DatasetUpdatedEvent;
import imagej.data.widget.HistogramBundle;
import imagej.module.MutableModuleItem;
import imagej.ui.UIService;
import imagej.widget.Button;
import net.imglib2.Cursor;
import net.imglib2.RandomAccess;
import net.imglib2.histogram.Histogram1d;
import net.imglib2.histogram.Real1dBinMapper;
import net.imglib2.meta.Axes;
import net.imglib2.ops.pointset.HyperVolumePointSet;
import net.imglib2.ops.pointset.PointSetIterator;
import net.imglib2.type.numeric.RealType;

import org.scijava.ItemVisibility;
import org.scijava.event.EventHandler;
import org.scijava.plugin.Menu;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

// TODO
// 1) some button commands unimplemented
// 2) dialog looks ugly

// TODO Add these features from IJ1
// [++] The horizontal LUT bar below the X-axis is scaled to reflect the display
// range of the image.
// [++] The modal gray value is displayed
//
// TODO This does lots of its own calcs. Rely on the final Histogram
// implementation when it's settled. Grant's impl used Larry's histogram. It
// also had a multithreaded stat calc method.

/**
 * Histogram plotter.
 * 
 * @author <NAME>
 * @author <NAME>
 */
@Plugin(type = Command.class, menu = {
	@Menu(label = "Analyze"),
	@Menu(label = "Histogram Plot", accelerator = "control shift alt H",
		weight = 0) })
public class HistogramPlot<T extends RealType<T>> extends InteractiveCommand
{

	// -- fields that are Parameters --

	@Parameter
	private UIService uiService;

	@Parameter
	private ImageDisplayService imageDisplayService;

	@Parameter
	private OverlayService overlayService;

	@Parameter
	private ImageDisplay display;

	@Parameter(label = "Histogram", initializer = "initBundle")
	private HistogramBundle bundle;

	@Parameter(visibility = ItemVisibility.MESSAGE, persist = false)
	private String pixelsStr;

	@Parameter(visibility = ItemVisibility.MESSAGE, persist = false)
	private String minStr;

	@Parameter(visibility = ItemVisibility.MESSAGE, persist = false)
	private String maxStr;

	@Parameter(visibility = ItemVisibility.MESSAGE, persist = false)
	private String meanStr;

	@Parameter(visibility = ItemVisibility.MESSAGE, persist = false)
	private String stdDevStr;

	@Parameter(visibility = ItemVisibility.MESSAGE, persist = false)
	private String binsStr;

	@Parameter(visibility = ItemVisibility.MESSAGE, persist = false)
	private String binWidthStr;

	@Parameter(label = "Static", callback = "liveClicked")
	private Button liveButton;

	@Parameter(label = "List", callback = "listClicked")
	private Button listButton;

	@Parameter(label = "Copy", callback = "copyClicked")
	private Button copyButton;

	@Parameter(label = "Log", callback = "logClicked")
	private Button logButton;
{'fraction_non_alphanumeric': 0.08127751049237383, 'fraction_numerical': 0.004913501893745522, 'mean_word_length': 4.892641737032569, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3526090', 'n_tokens_mistral': 2812, 'n_tokens_neox': 2582, 'n_words': 1003}