8888import sc .fiji .snt .gui .cmds .SaveMeasurementsCmd ;
8989import sc .fiji .snt .util .SNTColor ;
9090import smile .plot .swing .Heatmap ;
91- import smile .plot .swing .Palette ;
9291
9392/**
9493 * Extension of {@link ChartPanel} modified for scientific publications and
@@ -2069,7 +2068,7 @@ public static List<SNTChart> openCharts() {
20692068
20702069 /** Closes all open charts */
20712070 public static void closeAll () {
2072- for (SNTChart openInstance : openInstances ) {
2071+ for (final SNTChart openInstance : openInstances ) {
20732072 openInstance .disposeInternal ();
20742073 }
20752074 openInstances .clear ();
@@ -2090,7 +2089,7 @@ public static void tileAll() {
20902089 public static void tile (final Collection <SNTChart > charts ) {
20912090 final List <JFrame > frames = new ArrayList <>();
20922091 charts .forEach (oi -> frames .add (oi .getFrame ()));
2093- GuiUtils .tile (frames );
2092+ GuiUtils .tile (frames , charts . size () > 4 );
20942093 }
20952094
20962095 /**
@@ -2170,13 +2169,16 @@ public static SNTChart combine(final Collection<SNTChart> charts, final String c
21702169 * @param colorTable the color table (LUT) used to color histogram bars (null allowed)
21712170 * @param prob Whether frequencies should be normalized to probabilities
21722171 * @param axisLabels Labels for the axes (optional)
2172+ * @return the frame holding the histogram
21732173 * @throws InterruptedException if the histogram cannot be displayed
21742174 * @throws InvocationTargetException if the histogram cannot be displayed
21752175 */
2176- public static void showHistogram3D (final double [][] data , final ColorTable colorTable , final boolean prob , final String ... axisLabels ) throws InterruptedException , InvocationTargetException {
2176+ public static JFrame showHistogram3D (final double [][] data , final ColorTable colorTable , final boolean prob , final String ... axisLabels ) throws InterruptedException , InvocationTargetException {
21772177 final int nBins1 = AnalysisUtils .computeNBins (new DescriptiveStatistics (data [0 ]));
21782178 final int nBins2 = AnalysisUtils .computeNBins (new DescriptiveStatistics (data [1 ]));
2179- showSmilePlot (smile .plot .swing .Histogram3D .class , null , data , nBins1 , nBins2 , prob , colorTable , axisLabels );
2179+ final JFrame frame = showSmilePlot (smile .plot .swing .Histogram3D .class , null , data , nBins1 , nBins2 , prob , colorTable , axisLabels );
2180+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2181+ return frame ;
21802182 }
21812183
21822184 /**
@@ -2191,8 +2193,9 @@ public static void showHistogram3D(final double[][] data, final ColorTable color
21912193 */
21922194 public static JFrame showHeatmap (final double [][] data , final ColorTable colorTable , final String ... axisLabels )
21932195 throws InterruptedException , InvocationTargetException {
2194- return showHeatmap (null , data , colorTable , axisLabels );
2195-
2196+ final JFrame frame = showHeatmap (null , data , colorTable , axisLabels );
2197+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2198+ return frame ;
21962199 }
21972200
21982201 /**
@@ -2210,7 +2213,9 @@ public static JFrame showHeatmap(final String title, final double[][] data, fina
22102213 throws InterruptedException , InvocationTargetException {
22112214 if (data == null || data .length < 2 || data [0 ].length < 2 )
22122215 throw new IllegalArgumentException ("Heatmap requires at least a 2x2 matrix (got " + (data == null ? "null" : data .length + "x" + data [0 ].length ) + ")" );
2213- return showSmilePlot (smile .plot .swing .Heatmap .class , title , data , -1 , -1 , false , colorTable , axisLabels );
2216+ final JFrame frame = showSmilePlot (smile .plot .swing .Heatmap .class , title , data , -1 , -1 , false , colorTable , axisLabels );
2217+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2218+ return frame ;
22142219 }
22152220
22162221 /**
@@ -2233,7 +2238,9 @@ public static JFrame showHistogram3D(final Collection<Double> values1, final Col
22332238 .mapToObj (i -> new double []{v1 [i ], v2 [i ]}).toArray (double [][]::new );
22342239 final int nBins1 = AnalysisUtils .computeNBins (new DescriptiveStatistics (v1 ));
22352240 final int nBins2 = AnalysisUtils .computeNBins (new DescriptiveStatistics (v2 ));
2236- return showSmilePlot (smile .plot .swing .Histogram3D .class , null , data , nBins1 , nBins2 , false , colorTable , axisLabels );
2241+ final JFrame frame = showSmilePlot (smile .plot .swing .Histogram3D .class , null , data , nBins1 , nBins2 , false , colorTable , axisLabels );
2242+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2243+ return frame ;
22372244 }
22382245
22392246 /**
@@ -2249,7 +2256,9 @@ public static JFrame showHistogram3D(final Collection<Double> values1, final Col
22492256 */
22502257 public static JFrame showHeatmap (final Collection <Double > values1 , final Collection <Double > values2 ,
22512258 final ColorTable colorTable , final String ... axisLabels ) throws InterruptedException , InvocationTargetException {
2252- return showHeatmap (null , values1 , values2 , colorTable , axisLabels );
2259+ final JFrame frame = showHeatmap (null , values1 , values2 , colorTable , axisLabels );
2260+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2261+ return frame ;
22532262 }
22542263
22552264 /**
@@ -2270,7 +2279,9 @@ public static JFrame showHeatmap(final String title, final Collection<Double> va
22702279 final double [] v2 = values2 .stream ().mapToDouble (Double ::doubleValue ).toArray ();
22712280 final double [][] data = IntStream .range (0 , Math .min (v1 .length , v2 .length ))
22722281 .mapToObj (i -> new double []{v1 [i ], v2 [i ]}).toArray (double [][]::new );
2273- return showSmilePlot (smile .plot .swing .Heatmap .class , title , data , -1 , -1 , false , colorTable , axisLabels );
2282+ final JFrame frame = showSmilePlot (smile .plot .swing .Heatmap .class , title , data , -1 , -1 , false , colorTable , axisLabels );
2283+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2284+ return frame ;
22742285 }
22752286
22762287 /**
@@ -2293,7 +2304,9 @@ public static JFrame showHeatmap(final String title, final double[] xCoords, fin
22932304 figure .setTitle (title != null ? title : "Heatmap" );
22942305 if (axisLabels != null && axisLabels .length > 0 )
22952306 figure .setAxisLabels (Arrays .copyOf (axisLabels , figure .getAxisLabels ().length ));
2296- return figure .show ();
2307+ final JFrame frame = figure .show ();
2308+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2309+ return frame ;
22972310 }
22982311
22992312 /**
@@ -2311,7 +2324,9 @@ public static JFrame showHeatmap(final String title, final double[] xCoords, fin
23112324 */
23122325 public static JFrame showHistogram3D (final String title , final DescriptiveStatistics stats1 , final DescriptiveStatistics stats2 ,
23132326 final ColorTable colorTable , final String ... axisLabels ) throws InterruptedException , InvocationTargetException {
2314- return showSmileHistogram (smile .plot .swing .Histogram3D .class , title , stats1 , stats2 , colorTable , axisLabels );
2327+ final JFrame frame = showSmileHistogram (smile .plot .swing .Histogram3D .class , title , stats1 , stats2 , colorTable , axisLabels );
2328+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2329+ return frame ;
23152330 }
23162331
23172332 /**
@@ -2328,7 +2343,9 @@ public static JFrame showHistogram3D(final String title, final DescriptiveStatis
23282343 */
23292344 public static JFrame showHistogram3D (final DescriptiveStatistics stats1 , final DescriptiveStatistics stats2 ,
23302345 final ColorTable colorTable , final String ... axisLabels ) throws InterruptedException , InvocationTargetException {
2331- return showSmileHistogram (smile .plot .swing .Histogram3D .class , null , stats1 , stats2 , colorTable , axisLabels );
2346+ final JFrame frame = showSmileHistogram (smile .plot .swing .Histogram3D .class , null , stats1 , stats2 , colorTable , axisLabels );
2347+ frame .setName ("snt-smile-plot" ); // see GuiUtils.closeAllPlots
2348+ return frame ;
23322349 }
23332350
23342351 private static <T extends smile .plot .swing .Plot > JFrame showSmileHistogram (final Class <T > smilePlotClass , final String title , final DescriptiveStatistics stats1 , final DescriptiveStatistics stats2 ,
0 commit comments