Skip to content

Commit c991b6e

Browse files
committed
Export heat map pdf respects show values checkbox
1 parent 30d6578 commit c991b6e

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/heatmap/ExportPDFTask.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,15 @@ private PdfPCell createRankCell(int modelRow) {
186186

187187
private PdfPCell createExpressionCell(int row, int col) {
188188
double value = (double) getModel().getValueAt(row, col);
189-
Color color = getCellRenderer().getColor(getModel(), col, value);
189+
HeatMapCellRenderer cellRenderer = getCellRenderer();
190+
Color color = cellRenderer.getColor(getModel(), col, value);
191+
boolean showValues = cellRenderer.getShowValues();
190192

191193
PdfPCell cell = new PdfPCell();
192194
cell.setBackgroundColor(color(color));
193-
if(Double.isFinite(value)) {
195+
if(showValues && Double.isFinite(value)) {
194196
cell.setPhrase(new Phrase(ExportTXTTask.getExpressionText(value)));
195197
}
196-
197198
return cell;
198199
}
199200

@@ -206,11 +207,11 @@ private void setColumnWidths(PdfPTable table) throws DocumentException {
206207
widths[1] = getPreferredColumnWidth(table, 1);
207208
widths[2] = getPreferredColumnWidth(table, 2);
208209

209-
float maxExpression = 0;
210+
// equalize widths of expression columns
211+
float maxExpression = 30;
210212
for(int col = 3; col < n; col++) {
211213
maxExpression = Math.max(maxExpression, getPreferredColumnWidth(table, col));
212214
}
213-
214215
for(int col = 3; col < n; col++) {
215216
widths[col] = maxExpression;
216217
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/heatmap/table/HeatMapCellRenderer.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ public class HeatMapCellRenderer implements TableCellRenderer {
2828
private boolean showValue;
2929

3030

31-
public void setShowValues(boolean showValue) {
32-
this.showValue = showValue;
33-
}
34-
3531
@Override
3632
public JLabel getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
3733
JLabel label = new JLabel();
@@ -59,6 +55,16 @@ public JLabel getTableCellRendererComponent(JTable table, Object value, boolean
5955
return label;
6056
}
6157

58+
59+
public void setShowValues(boolean showValue) {
60+
this.showValue = showValue;
61+
}
62+
63+
public boolean getShowValues() {
64+
return showValue;
65+
}
66+
67+
6268
public static String getText(double d) {
6369
return Double.isFinite(d) ? format.format(d) : "NaN";
6470
}

0 commit comments

Comments
 (0)