Skip to content

Commit 9421358

Browse files
committed
Add "sparser"/"denser" to slider labels.
Refs #224
1 parent b584ec9 commit 9421358

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control/ControlPanel.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,9 @@
66
import static javax.swing.GroupLayout.Alignment.LEADING;
77
import static javax.swing.GroupLayout.Alignment.TRAILING;
88
import static org.baderlab.csplugins.enrichmentmap.EMBuildProps.HELP_URL_CONTROL;
9-
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.EM_ICON_COLORS;
10-
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.GENEMANIA_ICON;
11-
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.GENEMANIA_ICON_COLOR;
12-
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.LAYERED_EM_ICON;
13-
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.LAYERED_STRING_ICON;
14-
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.STRING_ICON_COLORS;
15-
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.getIconFont;
9+
import static org.baderlab.csplugins.enrichmentmap.view.util.IconUtil.*;
1610
import static org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil.makeSmall;
17-
import static org.cytoscape.util.swing.IconManager.ICON_BARS;
18-
import static org.cytoscape.util.swing.IconManager.ICON_FILE;
19-
import static org.cytoscape.util.swing.IconManager.ICON_PLUS;
20-
import static org.cytoscape.util.swing.IconManager.ICON_REFRESH;
21-
import static org.cytoscape.util.swing.IconManager.ICON_STAR;
11+
import static org.cytoscape.util.swing.IconManager.*;
2212
import static org.cytoscape.util.swing.LookAndFeelUtil.isAquaLAF;
2313

2414
import java.awt.BorderLayout;
@@ -697,6 +687,7 @@ private JPanel createFilterPanel() {
697687
similaritySliderPanel = createSimilaritySlider(map);
698688
sliderPanelFields.add(similaritySliderPanel.getTextField());
699689

690+
vGroup.addGap(15);
700691
hGroup.addComponent(similaritySliderPanel);
701692
vGroup.addComponent(similaritySliderPanel);
702693

@@ -787,7 +778,10 @@ private SliderBarPanel createPvalueSlider(EnrichmentMap map) {
787778
return new SliderBarPanel(
788779
(pvalueMin == 1 || pvalueMin >= pvalue ? 0 : pvalueMin),
789780
pvalue,
790-
pvalue
781+
pvalue,
782+
null,
783+
"sparser",
784+
"denser"
791785
);
792786
}
793787

@@ -798,7 +792,10 @@ private SliderBarPanel createQvalueSlider(EnrichmentMap map) {
798792
return new SliderBarPanel(
799793
(qvalueMin == 1 || qvalueMin >= qvalue ? 0 : qvalueMin),
800794
qvalue,
801-
qvalue
795+
qvalue,
796+
null,
797+
"sparser",
798+
"denser"
802799
);
803800
}
804801

@@ -809,7 +806,9 @@ private SliderBarPanel createSimilaritySlider(EnrichmentMap map) {
809806
similarityCutOff,
810807
1,
811808
similarityCutOff,
812-
"Edge Cutoff (Similarity):"
809+
"Edge Cutoff (Similarity):",
810+
"denser",
811+
"sparser"
813812
);
814813
}
815814

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/util/SliderBarPanel.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,25 @@ public class SliderBarPanel extends JPanel {
9999
private final DecimalFormat format;
100100
private boolean ignore;
101101

102+
private String minExtraLabel;
103+
private String maxExtraLabel;
104+
105+
102106
public SliderBarPanel(double min, double max, double value) {
103-
this(min, max, value, null);
107+
this(min, max, value, null, null, null);
104108
}
105109

106110
public SliderBarPanel(double min, double max, double value, String title) {
111+
this(min, max, value, title, null, null);
112+
}
113+
114+
public SliderBarPanel(double min, double max, double value, String title, String minLabel, String maxLabel) {
107115
this.min = min;
108116
this.max = max;
109117
this.value = value;
110118
this.title = title;
119+
this.minExtraLabel = minLabel;
120+
this.maxExtraLabel = maxLabel;
111121
listeners = new ArrayList<>();
112122

113123
String pattern = getFormatPattern(min, max, value);
@@ -120,6 +130,7 @@ public SliderBarPanel(double min, double max, double value, String title) {
120130

121131
init();
122132
}
133+
123134

124135
@SuppressWarnings("unchecked")
125136
protected void init() {
@@ -219,6 +230,16 @@ public void focusLost(FocusEvent e) {
219230
return textField;
220231
}
221232

233+
234+
private JLabel createTickLabel(double val, String extra) {
235+
var valText = format.format(val);
236+
if(extra == null)
237+
return new JLabel(valText);
238+
else
239+
return new JLabel("<html><div style='text-align: center'>" + valText + "<br>" + extra + "</div></html>");
240+
}
241+
242+
222243
JSlider getSlider() {
223244
if (slider == null) {
224245
slider = new JSlider(S_MIN, S_MAX);
@@ -241,12 +262,12 @@ JSlider getSlider() {
241262
slider.setMinorTickSpacing(S_RANGE / (n * 2));
242263
}
243264

244-
labelTable.put(S_MIN, new JLabel(format.format(min)));
265+
labelTable.put(S_MIN, createTickLabel(min, minExtraLabel));
245266

246267
if ((S_MIN + S_RANGE / 2) % 2 == 0)
247268
labelTable.put(S_MIN + S_RANGE / 2, new JLabel(format.format(min + range / 2)));
248269

249-
labelTable.put(S_MAX, new JLabel(format.format(max)));
270+
labelTable.put(S_MAX, createTickLabel(max, maxExtraLabel));
250271

251272
slider.setLabelTable(labelTable);
252273
slider.setPaintTicks(true);

0 commit comments

Comments
 (0)