Skip to content

Commit 501c93a

Browse files
committed
Set heatmap output to not output by default
Resolves #37
1 parent ddd6668 commit 501c93a

2 files changed

Lines changed: 44 additions & 10 deletions

File tree

src/scripts/Figure_Generation/HeatmapPlot.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class HeatmapPlot extends JFrame {
3838
public static Color MINCOLOR = new Color(255, 255, 255);
3939
public static Color MAXCOLOR = new Color(255, 0, 0);
4040

41+
protected static boolean OUTPUTSTATUS = false;
4142
protected static File OUTPUTPATH = null;
4243
protected static String FILEID = null;
4344

@@ -46,7 +47,7 @@ public class HeatmapPlot extends JFrame {
4647

4748
JTabbedPane newpane;
4849

49-
public HeatmapPlot(ArrayList<File> in, Color c, int startR, int startC, int pHeight, int pWidth, String scale, double abs, double quant, File OUT) {
50+
public HeatmapPlot(ArrayList<File> in, Color c, int startR, int startC, int pHeight, int pWidth, String scale, double abs, double quant, File OUT, boolean outstatus) {
5051
setTitle("Heatmap");
5152
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
5253
setBounds(150, 150, 600, 800);
@@ -66,6 +67,8 @@ public HeatmapPlot(ArrayList<File> in, Color c, int startR, int startC, int pHei
6667
quantile = quant;
6768

6869
OUTPUTPATH = OUT;
70+
OUTPUTSTATUS = outstatus;
71+
System.out.println(OUTPUTSTATUS);
6972
}
7073

7174
public void run() throws IOException {
@@ -89,8 +92,9 @@ public void run() throws IOException {
8992

9093
System.out.println("Contrast threshold: " + COLOR_RATIO);
9194
BufferedImage treeMap = generateHeatMap(newMatrix);
92-
ImageIO.write(treeMap, "png", new File(OUTPUT + "_" + scaleType + ".png"));
9395
picLabel = new JLabel(new ImageIcon(treeMap));
96+
//Don't output PNG if OUTPUTSTATUS is false, which is the flag for not outputing figures
97+
if(OUTPUTSTATUS) { ImageIO.write(treeMap, "png", new File(OUTPUT + "_" + scaleType + ".png")); }
9498
} else if(!scaleType.equalsIgnoreCase("treeview")) {
9599
//COLOR_RATIO = 2 * getNonZeroAvg(MATRIX);
96100
if(absolute != -999) { COLOR_RATIO = absolute; }
@@ -99,8 +103,10 @@ public void run() throws IOException {
99103

100104
BufferedImage rawMap = generateHeatMap(MATRIX);
101105
BufferedImage compressedMap = resize(rawMap, pixelWidth, pixelHeight);
102-
ImageIO.write(compressedMap, "png", new File(OUTPUT + "_" + scaleType + ".png"));
103106
picLabel = new JLabel(new ImageIcon(compressedMap));
107+
108+
//Don't output PNG if OUTPUTSTATUS is false, which is the flag for not outputing figures
109+
if(OUTPUTSTATUS) { ImageIO.write(compressedMap, "png", new File(OUTPUT + "_" + scaleType + ".png")); }
104110
}
105111
//Output image/error to GUI
106112
newpane.addTab(FILEID, new JScrollPane(picLabel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));

src/window_interface/Figure_Generation/HeatMapWindow.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import scripts.Figure_Generation.HeatmapPlot;
4040
import util.FileSelection;
41+
import javax.swing.JCheckBox;
4142

4243
@SuppressWarnings("serial")
4344
public class HeatMapWindow extends JFrame implements ActionListener, PropertyChangeListener {
@@ -67,6 +68,11 @@ public class HeatMapWindow extends JFrame implements ActionListener, PropertyCha
6768
private JRadioButton rdbtnBilinear;
6869
private JRadioButton rdbtnNearestNeighbor;
6970

71+
private JCheckBox chckbxOutputHeatmap;
72+
private JButton btnOutput;
73+
private JLabel lblOutput;
74+
private JLabel lblCurrentOutput;
75+
7076
private File OUTPUTPATH = null;
7177

7278
class Task extends SwingWorker<Void, Void> {
@@ -93,13 +99,13 @@ public Void doInBackground() throws IOException {
9399
else if(rdbtnBilinear.isSelected()) { scaletype = "bilinear"; }
94100
else if(rdbtnNearestNeighbor.isSelected()) { scaletype = "neighbor"; }
95101
if(OUTPUTPATH == null) { OUTPUTPATH = new File(System.getProperty("user.dir")); }
96-
102+
97103
double absolute = Double.parseDouble(txtAbsolute.getText());
98104
if(rdbtnPercentileValue.isSelected()) { absolute = -999; }
99105
double quantile = Double.parseDouble(txtPercent.getText());
100106

101107
//System.out.println(COLOR + "\n" + startR+ "\n" + startC+ "\n" + pHeight+ "\n" + pWidth+ "\n" + scaletype+ "\n" + absolute+ "\n" + quantile+ "\n" + OUTPUTPATH);
102-
HeatmapPlot heat = new HeatmapPlot(txtFiles, COLOR, startR, startC, pHeight, pWidth, scaletype, absolute, quantile, OUTPUTPATH);
108+
HeatmapPlot heat = new HeatmapPlot(txtFiles, COLOR, startR, startC, pHeight, pWidth, scaletype, absolute, quantile, OUTPUTPATH, chckbxOutputHeatmap.isSelected());
103109

104110
heat.addPropertyChangeListener("heat", new PropertyChangeListener() {
105111
public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
@@ -192,7 +198,7 @@ public void actionPerformed(ActionEvent arg0) {
192198

193199
btnGen.setActionCommand("start");
194200

195-
JLabel lblInputMatrixParameters = new JLabel("Input Matrix Parameters");
201+
JLabel lblInputMatrixParameters = new JLabel("Input Matrix Parameters (0-based)");
196202
sl_contentPane.putConstraint(SpringLayout.NORTH, lblInputMatrixParameters, 10, SpringLayout.SOUTH, scrollPane);
197203
sl_contentPane.putConstraint(SpringLayout.WEST, lblInputMatrixParameters, 10, SpringLayout.WEST, contentPane);
198204
contentPane.add(lblInputMatrixParameters);
@@ -416,7 +422,8 @@ public void itemStateChanged(ItemEvent e) {
416422
Scale.add(rdbtnNearestNeighbor);
417423
rdbtnTreeview.setSelected(true);
418424

419-
JButton btnOutput = new JButton("Output Directory");
425+
btnOutput = new JButton("Output Directory");
426+
btnOutput.setEnabled(false);
420427
sl_contentPane.putConstraint(SpringLayout.WEST, btnOutput, 150, SpringLayout.WEST, contentPane);
421428
sl_contentPane.putConstraint(SpringLayout.SOUTH, btnOutput, -45, SpringLayout.NORTH, btnGen);
422429
sl_contentPane.putConstraint(SpringLayout.EAST, btnOutput, -150, SpringLayout.EAST, contentPane);
@@ -429,20 +436,22 @@ public void itemStateChanged(ItemEvent e) {
429436
sl_contentPane.putConstraint(SpringLayout.EAST, separator_1, -10, SpringLayout.EAST, contentPane);
430437
contentPane.add(separator_1);
431438

432-
JLabel lblCurrentOutput = new JLabel("Current Output:");
439+
lblCurrentOutput = new JLabel("Current Output:");
440+
lblCurrentOutput.setEnabled(false);
433441
sl_contentPane.putConstraint(SpringLayout.NORTH, lblCurrentOutput, 15, SpringLayout.SOUTH, btnOutput);
434442
sl_contentPane.putConstraint(SpringLayout.WEST, lblCurrentOutput, 10, SpringLayout.WEST, contentPane);
435443
lblCurrentOutput.setFont(new Font("Lucida Grande", Font.BOLD, 13));
436444
contentPane.add(lblCurrentOutput);
437445

438-
JLabel lblOutput = new JLabel("Default to Local Directory");
446+
lblOutput = new JLabel("Default to Local Directory");
447+
lblOutput.setEnabled(false);
439448
sl_contentPane.putConstraint(SpringLayout.NORTH, lblOutput, 0, SpringLayout.NORTH, lblCurrentOutput);
440449
sl_contentPane.putConstraint(SpringLayout.WEST, lblOutput, 6, SpringLayout.EAST, lblCurrentOutput);
441450
sl_contentPane.putConstraint(SpringLayout.EAST, lblOutput, 0, SpringLayout.EAST, contentPane);
442451
lblOutput.setFont(new Font("Dialog", Font.PLAIN, 12));
443452
lblOutput.setBackground(Color.WHITE);
444453
contentPane.add(lblOutput);
445-
454+
446455
btnOutput.addActionListener(new ActionListener() {
447456
public void actionPerformed(ActionEvent e) {
448457
OUTPUTPATH = FileSelection.getOutputDir(fc);
@@ -451,10 +460,26 @@ public void actionPerformed(ActionEvent e) {
451460
}
452461
}
453462
});
463+
464+
chckbxOutputHeatmap = new JCheckBox("Output Heatmap");
465+
sl_contentPane.putConstraint(SpringLayout.WEST, chckbxOutputHeatmap, 0, SpringLayout.WEST, scrollPane);
466+
sl_contentPane.putConstraint(SpringLayout.SOUTH, chckbxOutputHeatmap, 0, SpringLayout.SOUTH, btnOutput);
467+
contentPane.add(chckbxOutputHeatmap);
468+
chckbxOutputHeatmap.addItemListener(new ItemListener() {
469+
public void itemStateChanged(ItemEvent e) {
470+
activateOutput(chckbxOutputHeatmap.isSelected());
471+
}
472+
});
454473

455474
btnGen.addActionListener(this);
456475
}
457476

477+
public void activateOutput(boolean activate) {
478+
btnOutput.setEnabled(activate);
479+
lblOutput.setEnabled(activate);
480+
lblCurrentOutput.setEnabled(activate);
481+
}
482+
458483
@Override
459484
public void actionPerformed(ActionEvent arg0) {
460485
massXable(contentPane, false);
@@ -489,8 +514,11 @@ public void massXable(Container con, boolean status) {
489514
txtAbsolute.setEnabled(true);
490515
txtPercent.setEnabled(false);
491516
}
517+
if(chckbxOutputHeatmap.isSelected()) { activateOutput(true); }
518+
else { activateOutput(false); }
492519
}
493520
}
521+
494522
}
495523

496524

0 commit comments

Comments
 (0)