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));
}
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();
}
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);
}
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);
}
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);
}
Aggregations