public RegIntTab(RegIntPlugin plugin) { super(JSplitPane.VERTICAL_SPLIT); tab = this; this.plugin = plugin; pathwayPanel.setLayout(new BorderLayout()); backpagePanel.setLayout(new BoxLayout(backpagePanel, BoxLayout.PAGE_AXIS)); swingEngine = plugin.getDesktop().getSwingEngine(); JScrollPane pathwayScroll = new JScrollPane(pathwayPanel); pathwayScroll.getVerticalScrollBar().setUnitIncrement(20); JScrollPane backpageScroll = new JScrollPane(backpagePanel); backpageScroll.getVerticalScrollBar().setUnitIncrement(20); setTopComponent(pathwayScroll); setBottomComponent(backpageScroll); setOneTouchExpandable(true); setDividerLocation(400); }
/** * Updates the bottom part of the {@link RegIntTab} with information about the Xref selected in * the top part of RIPTab and its interaction * * @param xref one of the interaction partners (displayed in the top part of the RIPTAB) of the * Xref selected in the main pathway * @param results the results object from updating the top part of the RIPTab by selecting an Xref * in the main pathway */ public void updateBackpagePanel(Xref xref, ResultsObj results) { backpagePanel.removeAll(); backpagePanel.setLayout(new BoxLayout(backpagePanel, BoxLayout.PAGE_AXIS)); PathwayElement e = PathwayElement.createPathwayElement(ObjectType.DATANODE); e.setDataSource(xref.getDataSource()); e.setElementID(xref.getId()); BackpageTextProvider bpt = new BackpageTextProvider(); bpt.addBackpageHook(new BackpageInfo(swingEngine.getGdbManager().getCurrentGdb(), results)); // TODO: fix file table, doesn't always show files bpt.addBackpageHook(new BackpageFileTable(results, plugin)); bpt.addBackpageHook(new BackpagePMID(results)); // TODO: change this to use multiple BridgeDb databases? bpt.addBackpageHook( new BackpageTextProvider.BackpageXrefs(swingEngine.getGdbManager().getCurrentGdb())); bpt.addBackpageHook(new BackpageExpression(plugin.getDesktop().getGexManager())); bpt.addBackpageHook(new BackpageMiscInfo(results)); BackpagePane bpp = new BackpagePane(bpt, swingEngine.getEngine()); bpp.setInput(e); bpp.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException e1) { e1.printStackTrace(); } catch (URISyntaxException e1) { e1.printStackTrace(); } } } }); backpagePanel.add(bpp); backpagePanel.revalidate(); backpagePanel.repaint(); }
/** * Creates the list of interaction partners displayed in the top part of the {@link RegIntTab} * * @param parent The {@link JScrollPane} containing either the regulators or the targets of the * selected element * @param map The map of interaction partners, either regulators or targets, also found in results * @param results The entire {@link ResultsObj}. Must have map as either its regulator or target * map * @param builder The {@link PanelBuilder} that will include this pathway * @return the list of interaction partners (in pathway form for expression visualization) */ private VPathwaySwing createPathway( JScrollPane parent, Map<Xref, Interaction> map, ResultsObj results, PanelBuilder builder) { VPathwaySwing vPathwaySwing = new VPathwaySwing(parent); VPathway vPathway = vPathwaySwing.createVPathway(); vPathway.setEditMode(false); Pathway sourcePw = new Pathway(); Map<Xref, Interaction> sorted = sortXrefs(map); x = 0; for (Xref xref : sorted.keySet()) { PathwayElement pwe = createPathwayELement(xref); sourcePw.add(pwe); JLabel linkout = new JLabel(icon); JPanel linkoutPane = new JPanel(); linkout.addMouseListener(new InfoButtonListener(xref, results, plugin)); linkoutPane.add(linkout); linkoutPane.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkoutPane.setVisible(true); List<File> uniqueFiles = new ArrayList<File>(); for (File intFile : sorted.get(xref).getFiles()) { if (!uniqueFiles.contains(intFile) && RegIntPreferences.getPreferences().getSelectedIntFiles().contains(intFile)) { uniqueFiles.add(intFile); } } builder.addLabel( uniqueFiles.size() + "/" + RegIntPreferences.getPreferences().getSelectedIntFiles().size(), cc.xy(6, y)); builder.add(linkoutPane, cc.xy(4, y)); y = y + 2; x++; } vPathway.fromModel(sourcePw); vPathway.setSelectionEnabled(false); vPathway.addVPathwayListener(plugin.getDesktop().getVisualizationManager()); return vPathwaySwing; }
/** * Updates the top part of the {@link RegIntTab} with a list of interaction partners of the * selected Xref * * @param xref The {@link Xref} from the selected pathway element */ public void updatePathwayPanel(PathwayElement elm) { Xref xref = elm.getXref(); backpagePanel.removeAll(); JLabel loading = new JLabel("<html><br> Loading...</html>", JLabel.LEFT); loading.setVerticalAlignment(JLabel.TOP); pathwayPanel.removeAll(); pathwayPanel.setLayout(new BorderLayout()); pathwayPanel.setBackground(Color.WHITE); pathwayPanel.add(loading, BorderLayout.CENTER); pathwayPanel.revalidate(); try { ResultsObj results = plugin.findInteractions(xref); if (results != null) { FormLayout layout = new FormLayout( "5dlu, 123px, 3dlu, pref, 3dlu, pref, 5dlu", tab.getRowLayout(results.getRegulatorMap().size(), results.getTargetMap().size())); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.addSeparator("", cc.xyw(1, 1, 7)); y = 2; int y2 = y; if (results.getRegulatorMap().size() > 0) { builder.addLabel("Regulators:", cc.xy(2, y)); y = y + 2; y2 = y; JScrollPane sourceScroll = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); sourceScroll.setMinimumSize(new Dimension(50, 50)); VPathwaySwing vPathwaySwing = createPathway(sourceScroll, results.getRegulatorMap(), results, builder); sourceScroll.add(vPathwaySwing); builder.add(sourceScroll, cc.xywh(2, y2, 1, (2 * results.getRegulatorMap().size()))); } if (results.getTargetMap().size() > 0) { y++; builder.addLabel("Targets:", cc.xy(2, y)); y = y + 2; y2 = y; JScrollPane targetScroll = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); targetScroll.setMinimumSize(new Dimension(50, 50)); VPathwaySwing vPathwaySwing = createPathway(targetScroll, results.getTargetMap(), results, builder); targetScroll.add(vPathwaySwing); builder.add(targetScroll, cc.xywh(2, y2, 1, (2 * results.getTargetMap().size()))); } JPanel panel = builder.getPanel(); pathwayPanel.removeAll(); JLabel selectedLabel = new JLabel( "<html><br /> <B>Selected: " + elm.getTextLabel() + " (" + xref.getDataSource().getSystemCode() + ": " + xref.getId() + ")</B></html>"); pathwayPanel.setLayout(new BorderLayout()); pathwayPanel.add(selectedLabel, BorderLayout.NORTH); pathwayPanel.add(panel, BorderLayout.CENTER); pathwayPanel.setBackground(Color.WHITE); pathwayPanel.revalidate(); pathwayPanel.repaint(); } else { setPathwayPanelText("<html><br> No results found.</html>"); } } catch (Exception e) { e.printStackTrace(); } }