/** * @param title Title of the new Visual Style * @param lexManager */ public VisualStyleImpl( final String title, final VisualLexiconManager lexManager, final CyServiceRegistrar serviceRegistrar, final CyEventHelper eventHelper) { if (lexManager == null) throw new NullPointerException("Lexicon Manager is missing."); if (title == null) this.title = DEFAULT_TITLE; else this.title = title; this.eventHelper = eventHelper; mappings = new HashMap<VisualProperty<?>, VisualMappingFunction<?, ?>>(); styleDefaults = new HashMap<VisualProperty<?>, Object>(); // Init Apply handlers for node, egde and network. applyHandlersMap = new HashMap<Class<? extends CyIdentifiable>, ApplyHandler>(); applyHandlersMap.put(CyNetwork.class, new ApplyToNetworkHandler(this, lexManager)); applyHandlersMap.put(CyNode.class, new ApplyToNodeHandler(this, lexManager)); applyHandlersMap.put(CyEdge.class, new ApplyToEdgeHandler(this, lexManager)); dependencies = new HashSet<VisualPropertyDependency<?>>(); // Listening to dependencies serviceRegistrar.registerServiceListener( this, "registerDependencyFactory", "unregisterDependencyFactory", VisualPropertyDependencyFactory.class); serviceRegistrar.registerService( this, VisualMappingFunctionChangedListener.class, new Properties()); logger.info("New Visual Style Created: Style Name = " + this.title); }
@Override public void run(TaskMonitor taskMonitor) throws Exception { taskMonitor.setTitle("Loading Gene Association File"); taskMonitor.setStatusMessage("Importing annotation file. Please wait..."); taskMonitor.setProgress(-1.0); this.ontologyDAG = OntologyDAGManager.getOntologyDAG(ontologyDagName); if (ontologyDAG == null) logger.warn("Could not find associated Ontology DAG."); else { termIDList = ontologyDAG.getDefaultNodeTable().getColumn(CyNetwork.NAME).getValues(String.class); } BufferedReader bufRd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8").newDecoder())); String line = null; String[] parts; while ((line = bufRd.readLine()) != null) { // Validate. if (line.contains(COMPATIBLE_VERSION)) break; } // Create result table table = serviceRegistrar .getService(CyTableFactory.class) .createTable(tableName, CyNetwork.NAME, String.class, true, true); createColumns(); while ((line = bufRd.readLine()) != null) { if (line.startsWith("!")) continue; parts = line.split(GA_DELIMITER); // GA is a fixed format file. Read only valid lines. if (parts.length >= EXPECTED_COL_COUNT) { parseGA(parts); } } bufRd.close(); is.close(); is = null; tables = new CyTable[1]; tables[0] = table; serviceRegistrar.getService(CyTableManager.class).addTable(table); }
/** Initializes the button. */ private void initButtons() { final IconManager iconManager = serviceRegistrar.getService(IconManager.class); // Create Float / Dock Button floatButton = new JButton(ICON_SQUARE_O); floatButton.setToolTipText(TOOL_TIP_FLOAT); CytoPanelUtil.styleButton(floatButton); floatButton.setFont(iconManager.getIconFont(12)); floatButton.setSelected(true); // Create close button closeButton = new JButton(ICON_REMOVE); closeButton.setToolTipText(TOOL_TIP_CLOSE); CytoPanelUtil.styleButton(closeButton); closeButton.setFont(iconManager.getIconFont(13)); closeButton.setSelected(true); floatButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (isFloating()) DockCytoPanel(); else FloatCytoPanel(); notifyListeners(NOTIFICATION_STATE_CHANGE); } }); closeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setState(CytoPanelState.HIDE); notifyListeners(NOTIFICATION_STATE_CHANGE); } }); }
void setNetworkView(final CyNetworkView view) { getApplyBtn().setEnabled(view != null); if (layoutAttrPnl == null) return; layoutAttrPnl.removeAll(); layoutAttrTunable = new LayoutAttributeTunable(); if (view != null) { List<String> attributeList = getAttributeList( view.getModel(), currentLayout.getSupportedNodeAttributeTypes(), currentLayout.getSupportedEdgeAttributeTypes()); if (attributeList.size() > 0) { layoutAttrTunable.layoutAttribute = new ListSingleSelection<String>(attributeList); layoutAttrTunable.layoutAttribute.setSelectedValue(attributeList.get(0)); final PanelTaskManager taskMgr = serviceRegistrar.getService(PanelTaskManager.class); JPanel panel = taskMgr.getConfiguration(null, layoutAttrTunable); setPanelsTransparent(panel); layoutAttrPnl.add(panel); panel.invalidate(); } } }
private void updatePrefAlgorithmCmb() { final CyLayoutAlgorithm defLayout = serviceRegistrar.getService(CyLayoutAlgorithmManager.class).getDefaultLayout(); if (defLayout != null && !defLayout.equals(getPrefAlgorithmCmb().getSelectedItem())) getPrefAlgorithmCmb().setSelectedItem(defLayout); }
private void initialize() { initializing = true; try { final Collator collator = Collator.getInstance(Locale.getDefault()); final TreeSet<CyLayoutAlgorithm> allLayouts = new TreeSet<>( new Comparator<CyLayoutAlgorithm>() { @Override public int compare(CyLayoutAlgorithm o1, CyLayoutAlgorithm o2) { return collator.compare(o1.toString(), o2.toString()); } }); allLayouts.addAll( serviceRegistrar.getService(CyLayoutAlgorithmManager.class).getAllLayouts()); // Populate the algorithm selectors getAlgorithmCmb().removeAllItems(); getPrefAlgorithmCmb().removeAllItems(); for (CyLayoutAlgorithm algo : allLayouts) { getAlgorithmCmb().addItem(algo); getPrefAlgorithmCmb().addItem(algo); } } finally { initializing = false; } if (currentLayout != null) getAlgorithmCmb().setSelectedItem(currentLayout); else if (getAlgorithmCmb().getModel().getSize() > 0) getAlgorithmCmb().setSelectedIndex(0); }
private void saveLayoutContexts() { final PanelTaskManager taskMgr = serviceRegistrar.getService(PanelTaskManager.class); for (CyLayoutAlgorithm layout : tunablesToSave) { layoutSettingsMgr.saveLayoutContext(taskMgr, layout); } tunablesToSave.clear(); }
public ResultPanel registerPanel(final Component panel, final String panelTitle) { final ResultPanel resPanel = new ResultPanel(panelTitle); JScrollPane pane = new JScrollPane(panel); // pane.setViewportView(panel); resPanel.setLayout(new BorderLayout()); resPanel.add(pane, BorderLayout.CENTER); registrar.registerAllServices(resPanel, new Properties()); return resPanel; }
public GUICyJobMonitor( CyServiceRegistrar registrar, CyJobManagerImpl jobManager, JobStatusBar statusBar) { this.serviceRegistrar = registrar; this.jobManager = jobManager; this.statusBar = statusBar; jobManager.setJobMonitor(this); logger = Logger.getLogger(CyUserLog.NAME); statusMap = new ConcurrentHashMap<>(); CySwingApplication swingApp = registrar.getService(CySwingApplication.class); dialog = new GUIJobDialog(serviceRegistrar, swingApp, statusMap, jobManager, this); statusBar.setDialog(dialog); }
@Before public void setUp() throws Exception { NetworkTestSupport netSupport = new NetworkTestSupport(); TableTestSupport tableSupport = new TableTestSupport(); CyNetworkFactory cyNetworkFactory = netSupport.getNetworkFactory(); tableFactory = tableSupport.getTableFactory(); tableManager = mock(CyTableManager.class); dag = cyNetworkFactory.createNetwork(); tm = mock(TaskMonitor.class); serviceRegistrar = mock(CyServiceRegistrar.class); when(serviceRegistrar.getService(CyTableFactory.class)).thenReturn(tableFactory); when(serviceRegistrar.getService(CyTableManager.class)).thenReturn(tableManager); }
@Override public void actionPerformed(ActionEvent e) { // Initialize and display if (isVisible()) { requestFocus(); } else { if (!initialized) { initialize(); updatePrefAlgorithmCmb(); setLocationRelativeTo(getOwner()); pack(); } setVisible(true); initialized = true; } setNetworkView(serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView()); }
/** * Code to notify our listeners of some particular event. * * @param notificationType What type of notification to perform. */ private void notifyListeners(int notificationType) { final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class); // determine what event to fire switch (notificationType) { case NOTIFICATION_STATE_CHANGE: eventHelper.fireEvent(new CytoPanelStateChangedEvent(this, this, cytoPanelState)); break; case NOTIFICATION_COMPONENT_SELECTED: int selectedIndex = tabbedPane.getSelectedIndex(); eventHelper.fireEvent(new CytoPanelComponentSelectedEvent(this, this, selectedIndex)); break; case NOTIFICATION_COMPONENT_ADDED: break; case NOTIFICATION_COMPONENT_REMOVED: break; } }
public void removePanel(ResultPanel panel) { if (panel != null) { registrar.unregisterAllServices(panel); } }