Search in sources :

Example 6 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class CloneNetworkTaskFactoryTest method testObserver.

@Test
public void testObserver() throws Exception {
    NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
    NetworkTestSupport networkSupport = new NetworkTestSupport();
    CyNetworkManager networkMgr = Mockito.mock(CyNetworkManager.class);
    CyNetworkViewManager networkViewMgr = Mockito.mock(CyNetworkViewManager.class);
    VisualMappingManager vmm = Mockito.mock(VisualMappingManager.class);
    CyNetworkFactory netFactory = networkSupport.getNetworkFactory();
    CyNetworkViewFactory netViewFactory = viewSupport.getNetworkViewFactory();
    CyNetworkNaming naming = Mockito.mock(CyNetworkNaming.class);
    CyApplicationManager appMgr = Mockito.mock(CyApplicationManager.class);
    CyNetworkTableManager netTableMgr = Mockito.mock(CyNetworkTableManager.class);
    CyRootNetworkManager rootNetMgr = new CyRootNetworkManagerImpl();
    CyGroupManager groupMgr = Mockito.mock(CyGroupManager.class);
    CyGroupFactory groupFactory = Mockito.mock(CyGroupFactory.class);
    RenderingEngineManager renderingEngineMgr = Mockito.mock(RenderingEngineManager.class);
    CyNetworkViewFactory nullNetworkViewFactory = new NullCyNetworkViewFactory();
    CyServiceRegistrar serviceRegistrar = Mockito.mock(CyServiceRegistrar.class);
    CloneNetworkTaskFactoryImpl factory = new CloneNetworkTaskFactoryImpl(networkMgr, networkViewMgr, vmm, netFactory, netViewFactory, naming, appMgr, netTableMgr, rootNetMgr, groupMgr, groupFactory, renderingEngineMgr, nullNetworkViewFactory, serviceRegistrar);
    CyNetwork network = netFactory.createNetwork();
    TaskObserver observer = Mockito.mock(TaskObserver.class);
    TaskIterator iterator = factory.createTaskIterator(network);
    TaskMonitor taskMonitor = Mockito.mock(TaskMonitor.class);
    while (iterator.hasNext()) {
        Task t = iterator.next();
        t.run(taskMonitor);
        if (t instanceof ObservableTask)
            observer.taskFinished((ObservableTask) t);
    }
    Mockito.verify(observer, Mockito.times(1)).taskFinished(Mockito.any(ObservableTask.class));
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) CyNetwork(org.cytoscape.model.CyNetwork) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) CyNetworkManager(org.cytoscape.model.CyNetworkManager) TaskIterator(org.cytoscape.work.TaskIterator) NullCyNetworkViewFactory(org.cytoscape.view.model.internal.NullCyNetworkViewFactory) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) NullCyNetworkViewFactory(org.cytoscape.view.model.internal.NullCyNetworkViewFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyGroupFactory(org.cytoscape.group.CyGroupFactory) CyGroupManager(org.cytoscape.group.CyGroupManager) Test(org.junit.Test)

Example 7 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class ControlPanel method handleEvent.

@Override
public void handleEvent(RowsSetEvent e) {
    if (loadingSession)
        return;
    final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    final CyNetworkView currentView = appMgr.getCurrentNetworkView();
    if (currentView == null)
        return;
    final CyTable tbl = e.getSource();
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    final CyNetwork net = netTblMgr.getNetworkForTable(tbl);
    if (net == null || !net.equals(currentView.getModel()) || !tbl.equals(net.getDefaultNodeTable()))
        return;
    final Collection<RowSetRecord> selectedRecords = e.getColumnRecords(CyNetwork.SELECTED);
    if (!selectedRecords.isEmpty())
        updatePanels();
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 8 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class C2CEditor method setValue.

@Override
@SuppressWarnings("unchecked")
public void setValue(final Object value) {
    if (value instanceof ContinuousMapping == false)
        throw new IllegalArgumentException("Value should be ContinuousMapping: this is " + value);
    final CyApplicationManager appMgr = servicesUtil.get(CyApplicationManager.class);
    final CyNetwork currentNetwork = appMgr.getCurrentNetwork();
    if (currentNetwork == null)
        return;
    mapping = (ContinuousMapping<K, V>) value;
    Class<? extends CyIdentifiable> type = (Class<? extends CyIdentifiable>) mapping.getVisualProperty().getTargetDataType();
    final CyNetworkTableManager netTblMgr = servicesUtil.get(CyNetworkTableManager.class);
    final CyTable attr = netTblMgr.getTable(appMgr.getCurrentNetwork(), type, CyNetwork.DEFAULT_ATTRS);
    final VisualMappingManager vmMgr = servicesUtil.get(VisualMappingManager.class);
    editorPanel = new C2CMappingEditorPanel<K, V>(vmMgr.getCurrentVisualStyle(), mapping, attr, servicesUtil);
}
Also used : ContinuousMapping(org.cytoscape.view.vizmap.mappings.ContinuousMapping) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 9 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class GradientEditor method setValue.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setValue(final Object value) {
    if (value instanceof ContinuousMapping == false)
        throw new IllegalArgumentException("Value should be ContinuousMapping: this is " + value);
    final CyApplicationManager appMgr = servicesUtil.get(CyApplicationManager.class);
    final CyNetwork currentNetwork = appMgr.getCurrentNetwork();
    if (currentNetwork == null)
        return;
    ContinuousMapping<?, ?> mTest = (ContinuousMapping<?, ?>) value;
    // TODO: error chekcing
    mapping = (ContinuousMapping<Double, Color>) value;
    Class<? extends CyIdentifiable> type = (Class<? extends CyIdentifiable>) mapping.getVisualProperty().getTargetDataType();
    final CyNetworkTableManager netTblMgr = servicesUtil.get(CyNetworkTableManager.class);
    final CyTable attr = netTblMgr.getTable(appMgr.getCurrentNetwork(), type, CyNetwork.DEFAULT_ATTRS);
    final VisualMappingManager vmMgr = servicesUtil.get(VisualMappingManager.class);
    editorPanel = new GradientEditorPanel(vmMgr.getCurrentVisualStyle(), mapping, attr, editorManager.getValueEditor(Paint.class), servicesUtil);
}
Also used : ContinuousMapping(org.cytoscape.view.vizmap.mappings.ContinuousMapping) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) Color(java.awt.Color) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 10 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class AttributeSetProxy method handleEvent.

@Override
public void handleEvent(final NetworkAddedEvent e) {
    final CyNetwork network = e.getNetwork();
    final Map<Class<? extends CyIdentifiable>, Set<CyTable>> object2tableMap = new HashMap<Class<? extends CyIdentifiable>, Set<CyTable>>();
    final Map<Class<? extends CyIdentifiable>, AttributeSet> attrSetMap = new HashMap<Class<? extends CyIdentifiable>, AttributeSet>();
    final CyNetworkTableManager netTblMgr = servicesUtil.get(CyNetworkTableManager.class);
    for (final Class<? extends CyIdentifiable> objectType : graphObjects) {
        final Map<String, CyTable> tableMap = netTblMgr.getTables(network, objectType);
        final Collection<CyTable> tables = tableMap.values();
        object2tableMap.put(objectType, new HashSet<CyTable>(tables));
        final AttributeSet attrSet = new AttributeSet(objectType);
        for (CyTable table : tables) {
            final Collection<CyColumn> columns = table.getColumns();
            for (final CyColumn column : columns) {
                final Class<?> type = column.getType();
                attrSet.getAttrMap().put(column.getName(), type);
            }
        }
        attrSetMap.put(objectType, attrSet);
    }
    attrSets.put(network, attrSetMap);
    tableSets.put(network, object2tableMap);
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) CyColumn(org.cytoscape.model.CyColumn) CyNetwork(org.cytoscape.model.CyNetwork) CyTable(org.cytoscape.model.CyTable) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Aggregations

CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)19 CyNetwork (org.cytoscape.model.CyNetwork)15 CyTable (org.cytoscape.model.CyTable)13 CyApplicationManager (org.cytoscape.application.CyApplicationManager)8 HashSet (java.util.HashSet)7 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)6 CyIdentifiable (org.cytoscape.model.CyIdentifiable)5 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)4 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)4 ContinuousMapping (org.cytoscape.view.vizmap.mappings.ContinuousMapping)4 RowSetRecord (org.cytoscape.model.events.RowSetRecord)3 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)3 CyNetworkView (org.cytoscape.view.model.CyNetworkView)3 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 WeakHashMap (java.util.WeakHashMap)2 CyGroupFactory (org.cytoscape.group.CyGroupFactory)2 CyGroupManager (org.cytoscape.group.CyGroupManager)2 CyColumn (org.cytoscape.model.CyColumn)2