|
31 | 31 | import javax.swing.BoxLayout;
|
32 | 32 | import javax.swing.ButtonGroup;
|
33 | 33 | import javax.swing.DefaultListCellRenderer;
|
| 34 | +import javax.swing.DefaultListModel; |
34 | 35 | import javax.swing.GroupLayout;
|
35 | 36 | import javax.swing.GroupLayout.Alignment;
|
36 | 37 | import javax.swing.GroupLayout.ParallelGroup;
|
@@ -109,7 +110,7 @@ public class ControlPanel extends JPanel implements CytoPanelComponent2, CyDispo
|
109 | 110 | private JButton closePanelButton;
|
110 | 111 |
|
111 | 112 | 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<>(); |
113 | 114 |
|
114 | 115 | private final Icon compIcon = new TextIcon(LAYERED_EM_ICON, getIconFont(18.0f), EM_ICON_COLORS, 16, 16);
|
115 | 116 |
|
@@ -294,14 +295,18 @@ EMViewControlPanel addEnrichmentMapView(CyNetworkView netView) {
|
294 | 295 | return null;
|
295 | 296 | }
|
296 | 297 |
|
297 |
| - AssociatedViewControlPanel addAssociatedView(CyNetworkView netView) { |
| 298 | + AbstractViewControlPanel addAssociatedView(CyNetworkView netView, AssociatedApp app) { |
298 | 299 | updateEmViewCombo();
|
299 | 300 |
|
300 | 301 | 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 | + } |
302 | 308 | getCtrlPanelsContainer().add(p, p.getName());
|
303 | 309 | gmViewCtrlPanels.put(netView.getSUID(), p);
|
304 |
| - |
305 | 310 | return p;
|
306 | 311 | }
|
307 | 312 | return null;
|
@@ -404,15 +409,15 @@ public Map<Long, EMViewControlPanel> getAllControlPanels() {
|
404 | 409 | return new HashMap<>(emViewCtrlPanels);
|
405 | 410 | }
|
406 | 411 |
|
407 |
| - AssociatedViewControlPanel getAssociatedViewControlPanel(CyNetworkView netView) { |
| 412 | + AbstractViewControlPanel getAssociatedViewControlPanel(CyNetworkView netView) { |
408 | 413 | return netView != null ? getAssociatedViewControlPanel(netView.getSUID()) : null;
|
409 | 414 | }
|
410 | 415 |
|
411 |
| - AssociatedViewControlPanel getAssociatedViewControlPanel(Long suid) { |
| 416 | + AbstractViewControlPanel getAssociatedViewControlPanel(Long suid) { |
412 | 417 | return gmViewCtrlPanels.get(suid);
|
413 | 418 | }
|
414 | 419 |
|
415 |
| - public Map<Long, AssociatedViewControlPanel> getAllAssociatedViewControlPanels() { |
| 420 | + public Map<Long, AbstractViewControlPanel> getAllAssociatedViewControlPanels() { |
416 | 421 | return new HashMap<>(gmViewCtrlPanels);
|
417 | 422 | }
|
418 | 423 |
|
@@ -1180,35 +1185,7 @@ JComboBox<ComboItem<Compress>> getCompressCombo() {
|
1180 | 1185 | JComboBox<EMDataSet> getDataSetCombo() {
|
1181 | 1186 | if (dataSetCombo == null) {
|
1182 | 1187 | 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()); |
1212 | 1189 | }
|
1213 | 1190 |
|
1214 | 1191 | return dataSetCombo;
|
@@ -1329,6 +1306,101 @@ void updateChartTypeCombo() {
|
1329 | 1306 | }
|
1330 | 1307 | }
|
1331 | 1308 |
|
| 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 | + |
1332 | 1404 | private class NullViewControlPanel extends JPanel {
|
1333 | 1405 |
|
1334 | 1406 | public static final String NAME = "__NULL_VIEW_CONTROL_PANEL";
|
|
0 commit comments