Skip to content

Commit 5befb76

Browse files
committed
Show data sets for AA summary networks.
Refs #498
1 parent 024daf6 commit 5befb76

File tree

2 files changed

+115
-40
lines changed

2 files changed

+115
-40
lines changed

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

Lines changed: 108 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import javax.swing.BoxLayout;
3232
import javax.swing.ButtonGroup;
3333
import javax.swing.DefaultListCellRenderer;
34+
import javax.swing.DefaultListModel;
3435
import javax.swing.GroupLayout;
3536
import javax.swing.GroupLayout.Alignment;
3637
import javax.swing.GroupLayout.ParallelGroup;
@@ -109,7 +110,7 @@ public class ControlPanel extends JPanel implements CytoPanelComponent2, CyDispo
109110
private JButton closePanelButton;
110111

111112
private Map<Long/*CynetworkView SUID*/, EMViewControlPanel> emViewCtrlPanels = new HashMap<>();
112-
private Map<Long/*CynetworkView SUID*/, AssociatedViewControlPanel> gmViewCtrlPanels = new HashMap<>();
113+
private Map<Long/*CynetworkView SUID*/, AbstractViewControlPanel> gmViewCtrlPanels = new HashMap<>();
113114

114115
private final Icon compIcon = new TextIcon(LAYERED_EM_ICON, getIconFont(18.0f), EM_ICON_COLORS, 16, 16);
115116

@@ -294,14 +295,18 @@ EMViewControlPanel addEnrichmentMapView(CyNetworkView netView) {
294295
return null;
295296
}
296297

297-
AssociatedViewControlPanel addAssociatedView(CyNetworkView netView) {
298+
AbstractViewControlPanel addAssociatedView(CyNetworkView netView, AssociatedApp app) {
298299
updateEmViewCombo();
299300

300301
if (getAssociatedViewControlPanel(netView) == null) {
301-
AssociatedViewControlPanel p = new AssociatedViewControlPanel(netView);
302+
AbstractViewControlPanel p;
303+
if(app == AssociatedApp.AUTOANNOTATE) {
304+
p = new AutoAnnotateControlPanel(netView);
305+
} else {
306+
p = new AssociatedViewControlPanel(netView);
307+
}
302308
getCtrlPanelsContainer().add(p, p.getName());
303309
gmViewCtrlPanels.put(netView.getSUID(), p);
304-
305310
return p;
306311
}
307312
return null;
@@ -404,15 +409,15 @@ public Map<Long, EMViewControlPanel> getAllControlPanels() {
404409
return new HashMap<>(emViewCtrlPanels);
405410
}
406411

407-
AssociatedViewControlPanel getAssociatedViewControlPanel(CyNetworkView netView) {
412+
AbstractViewControlPanel getAssociatedViewControlPanel(CyNetworkView netView) {
408413
return netView != null ? getAssociatedViewControlPanel(netView.getSUID()) : null;
409414
}
410415

411-
AssociatedViewControlPanel getAssociatedViewControlPanel(Long suid) {
416+
AbstractViewControlPanel getAssociatedViewControlPanel(Long suid) {
412417
return gmViewCtrlPanels.get(suid);
413418
}
414419

415-
public Map<Long, AssociatedViewControlPanel> getAllAssociatedViewControlPanels() {
420+
public Map<Long, AbstractViewControlPanel> getAllAssociatedViewControlPanels() {
416421
return new HashMap<>(gmViewCtrlPanels);
417422
}
418423

@@ -1180,35 +1185,7 @@ JComboBox<ComboItem<Compress>> getCompressCombo() {
11801185
JComboBox<EMDataSet> getDataSetCombo() {
11811186
if (dataSetCombo == null) {
11821187
dataSetCombo = new JComboBox<>();
1183-
1184-
final Font iconFont = iconManager.getIconFont(12.0f);
1185-
final int iconSize = 16;
1186-
Icon sigIcon = new TextIcon(ICON_STAR, iconFont, EMStyleBuilder.Colors.SIG_EDGE_COLOR, iconSize, iconSize);
1187-
1188-
dataSetCombo.setRenderer(new DefaultListCellRenderer() {
1189-
@Override
1190-
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
1191-
boolean isSelected, boolean cellHasFocus) {
1192-
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
1193-
1194-
Icon icon = null;
1195-
String text = Labels.ALL;
1196-
1197-
if (value instanceof EMSignatureDataSet) {
1198-
icon = sigIcon;
1199-
text = ((EMSignatureDataSet) value).getName();
1200-
} else if (value instanceof EMDataSet) {
1201-
EMDataSet ds = (EMDataSet) value;
1202-
icon = new TextIcon(ICON_FILE, iconFont, ds.getColor(), iconSize, iconSize);
1203-
text = ds.getName();
1204-
}
1205-
1206-
setIcon(icon);
1207-
setText(text);
1208-
1209-
return this;
1210-
}
1211-
});
1188+
dataSetCombo.setRenderer(new DataSetListCellRenderer());
12121189
}
12131190

12141191
return dataSetCombo;
@@ -1329,6 +1306,101 @@ void updateChartTypeCombo() {
13291306
}
13301307
}
13311308

1309+
1310+
class DataSetListCellRenderer extends DefaultListCellRenderer {
1311+
1312+
final Font iconFont = iconManager.getIconFont(12.0f);
1313+
final int iconSize = 16;
1314+
final Icon sigIcon = new TextIcon(ICON_STAR, iconFont, EMStyleBuilder.Colors.SIG_EDGE_COLOR, iconSize, iconSize);
1315+
1316+
@Override
1317+
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
1318+
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
1319+
1320+
Icon icon = null;
1321+
String text = Labels.ALL;
1322+
1323+
if (value instanceof EMSignatureDataSet) {
1324+
icon = sigIcon;
1325+
text = ((EMSignatureDataSet) value).getName();
1326+
} else if (value instanceof EMDataSet) {
1327+
EMDataSet ds = (EMDataSet) value;
1328+
icon = new TextIcon(ICON_FILE, iconFont, ds.getColor(), iconSize, iconSize);
1329+
text = ds.getName();
1330+
}
1331+
1332+
setIcon(icon);
1333+
setText(text);
1334+
return this;
1335+
}
1336+
}
1337+
1338+
1339+
class AutoAnnotateControlPanel extends AbstractViewControlPanel {
1340+
1341+
private JList<EMDataSet> dataSetList;
1342+
1343+
private AutoAnnotateControlPanel(CyNetworkView networkView) {
1344+
super(networkView, "__EM_CHILD_VIEW_CONTROL_PANEL_" + networkView.getSUID());
1345+
}
1346+
1347+
@Override
1348+
protected void init() {
1349+
super.init();
1350+
update();
1351+
}
1352+
1353+
@Override
1354+
JPanel getContentPane() {
1355+
if (contentPane == null) {
1356+
contentPane = new JPanel();
1357+
1358+
var layout = new GroupLayout(contentPane);
1359+
contentPane.setLayout(layout);
1360+
layout.setAutoCreateContainerGaps(true);
1361+
layout.setAutoCreateGaps(true);
1362+
1363+
JLabel titleLabel = new JLabel("Data Sets:");
1364+
makeSmall(titleLabel);
1365+
1366+
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING)
1367+
.addComponent(titleLabel)
1368+
.addComponent(getDataSetList(), 100, PREFERRED_SIZE, Short.MAX_VALUE)
1369+
);
1370+
layout.setVerticalGroup(layout.createSequentialGroup()
1371+
.addComponent(titleLabel)
1372+
.addComponent(getDataSetList(), 100, DEFAULT_SIZE, PREFERRED_SIZE)
1373+
);
1374+
1375+
if (LookAndFeelUtil.isAquaLAF())
1376+
contentPane.setOpaque(false);
1377+
}
1378+
1379+
return contentPane;
1380+
}
1381+
1382+
private JList<EMDataSet> getDataSetList() {
1383+
if(dataSetList == null) {
1384+
dataSetList = new JList<>(new DefaultListModel<>());
1385+
dataSetList.setCellRenderer(new DataSetListCellRenderer());
1386+
}
1387+
return dataSetList;
1388+
}
1389+
1390+
@Override
1391+
void update() {
1392+
EnrichmentMap em = networkView != null ? emManager.getEnrichmentMap(networkView.getModel().getSUID()) : null;
1393+
1394+
var listModel = (DefaultListModel<EMDataSet>) getDataSetList().getModel();
1395+
listModel.removeAllElements();
1396+
1397+
if(em != null)
1398+
em.getDataSetList().forEach(listModel::addElement);
1399+
1400+
}
1401+
}
1402+
1403+
13321404
private class NullViewControlPanel extends JPanel {
13331405

13341406
public static final String NAME = "__NULL_VIEW_CONTROL_PANEL";

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,17 @@ private void setCurrentNetworkView(CyNetworkView netView) {
468468
*/
469469
private AbstractViewControlPanel addNetworkView(CyNetworkView netView) {
470470
AbstractViewControlPanel viewPanel = null;
471-
EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
471+
var network = netView.getModel();
472+
EnrichmentMap map = emManager.getEnrichmentMap(network.getSUID());
472473

473474
// Is the new view an EnrichmentMap one?
474475
if (map != null) {
475-
if (NetworkUtil.isAssociatedNetwork(netView.getModel()))
476-
viewPanel = getControlPanel().addAssociatedView(netView);
477-
else
476+
if (NetworkUtil.isAssociatedNetwork(network)) {
477+
var app = NetworkUtil.getAssociatedApp(network);
478+
viewPanel = getControlPanel().addAssociatedView(netView, app);
479+
} else {
478480
viewPanel = getControlPanel().addEnrichmentMapView(netView);
481+
}
479482

480483
if (viewPanel instanceof EMViewControlPanel)
481484
addListeners((EMViewControlPanel) viewPanel, map);

0 commit comments

Comments
 (0)