Search in sources :

Example 1 with TransformerPanel

use of org.cytoscape.filter.internal.view.TransformerPanel in project cytoscape-impl by cytoscape.

the class CompositeTransformerPanel method createViewModel.

private TransformerElementViewModel<TransformerPanel> createViewModel(Transformer<CyNetwork, CyIdentifiable> transformer) {
    JComponent component = transformerPanelController.createView(parent, transformer, 0);
    TransformerElementViewModel<TransformerPanel> viewModel = new TransformerElementViewModel<>(component, transformerPanelController, parent);
    if (transformer instanceof ValidatableTransformer) {
        transformerPanelController.getValidationManager().register((ValidatableTransformer<CyNetwork, CyIdentifiable>) transformer, viewModel);
    }
    return viewModel;
}
Also used : TransformerPanel(org.cytoscape.filter.internal.view.TransformerPanel) JComponent(javax.swing.JComponent) TransformerElementViewModel(org.cytoscape.filter.internal.view.TransformerElementViewModel) CyNetwork(org.cytoscape.model.CyNetwork) ValidatableTransformer(org.cytoscape.filter.model.ValidatableTransformer) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 2 with TransformerPanel

use of org.cytoscape.filter.internal.view.TransformerPanel in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    TransformerManagerImpl transformerManager = new TransformerManagerImpl();
    registerService(bc, transformerManager, TransformerManager.class, new Properties());
    registerServiceListener(bc, transformerManager::registerTransformerSource, transformerManager::unregisterTransformerSource, TransformerSource.class);
    registerServiceListener(bc, transformerManager::registerFilterFactory, transformerManager::unregisterFilterFactory, FilterFactory.class);
    registerServiceListener(bc, transformerManager::registerElementTransformerFactory, transformerManager::unregisterElementTransformerFactory, ElementTransformerFactory.class);
    registerServiceListener(bc, transformerManager::registerHolisticTransformerFactory, transformerManager::unregisterHolisticTransformerFactory, HolisticTransformerFactory.class);
    TransformerViewManager transformerViewManager = new TransformerViewManager(transformerManager);
    registerServiceListener(bc, transformerViewManager::registerTransformerViewFactory, transformerViewManager::unregisterTransformerViewFactory, TransformerViewFactory.class);
    registerService(bc, new CyNetworkSource(), TransformerSource.class, new Properties());
    // Filters
    registerService(bc, new DegreeFilterFactory(), FilterFactory.class, new Properties());
    registerService(bc, new ColumnFilterFactory(), FilterFactory.class, new Properties());
    registerService(bc, new TopologyFilterFactory(), FilterFactory.class, new Properties());
    registerService(bc, new CompositeFilterFactory<CyNetwork, CyIdentifiable>(CyNetwork.class, CyIdentifiable.class), FilterFactory.class, new Properties());
    // Transformers
    registerService(bc, new InteractionTransformerFactory(), ElementTransformerFactory.class, new Properties());
    registerService(bc, new AdjacencyTransformerFactory(), ElementTransformerFactory.class, new Properties());
    ModelMonitor modelMonitor = new ModelMonitor();
    registerAllServices(bc, modelMonitor, new Properties());
    ValidationManager validationManager = new ValidationManager();
    registerAllServices(bc, validationManager, new Properties());
    FilterPanelStyle style = new FlatStyle();
    registerService(bc, new DegreeFilterViewFactory(style, modelMonitor), TransformerViewFactory.class, new Properties());
    registerService(bc, new ColumnFilterViewFactory(style, modelMonitor, serviceRegistrar), TransformerViewFactory.class, new Properties());
    registerService(bc, new TopologyFilterViewFactory(style), TransformerViewFactory.class, TopologyFilterViewFactory.getServiceProperties());
    registerService(bc, new InteractionTransformerViewFactory(style), TransformerViewFactory.class, new Properties());
    registerService(bc, new AdjacencyTransformerViewFactory(style, serviceRegistrar), TransformerViewFactory.class, AdjacencyTransformerViewFactory.getServiceProperties());
    LazyWorkQueue queue = new LazyWorkQueue();
    FilterIO filterIo = new FilterIO(serviceRegistrar);
    FilterWorker filterWorker = new FilterWorker(queue, serviceRegistrar);
    FilterPanelController filterPanelController = new FilterPanelController(transformerManager, transformerViewManager, validationManager, filterWorker, modelMonitor, filterIo, style, serviceRegistrar);
    FilterPanel filterPanel = new FilterPanel(filterPanelController, filterWorker, serviceRegistrar);
    TransformerWorker transformerWorker = new TransformerWorker(queue, transformerManager, serviceRegistrar);
    TransformerPanelController transformerPanelController = new TransformerPanelController(transformerManager, transformerViewManager, validationManager, filterPanelController, transformerWorker, filterIo, style, serviceRegistrar);
    TransformerPanel transformerPanel = new TransformerPanel(transformerPanelController, transformerWorker, serviceRegistrar);
    CytoPanelComponent selectPanel = new FilterCytoPanelComponent(transformerViewManager, modelMonitor, filterPanel, transformerPanel);
    registerService(bc, selectPanel, CytoPanelComponent.class, new Properties());
    FilterSettingsManager settingsManager = new FilterSettingsManager(filterPanel, transformerPanel, filterIo);
    registerService(bc, settingsManager, SessionAboutToBeSavedListener.class, new Properties());
    registerService(bc, settingsManager, SessionAboutToBeLoadedListener.class, new Properties());
    registerService(bc, settingsManager, SessionLoadedListener.class, new Properties());
    // new TransformerPanelManager API
    {
        Properties props = new Properties();
        props.setProperty("service.type", "manager");
        props.setProperty("container.type", "filter");
        registerService(bc, filterPanel, TransformerContainer.class, props);
    }
    {
        Properties props = new Properties();
        props.setProperty("service.type", "manager");
        props.setProperty("container.type", "chain");
        registerService(bc, transformerPanel, TransformerContainer.class, props);
    }
    // commands
    {
        Properties props = new Properties();
        props.setProperty(COMMAND, "import");
        props.setProperty(COMMAND_NAMESPACE, "filter");
        props.setProperty(COMMAND_DESCRIPTION, "Import filter JSON from a file.");
        props.setProperty(COMMAND_LONG_DESCRIPTION, "Import filter JSON from a file.");
        registerService(bc, new ImportNamedTransformersTaskFactory(filterIo, filterPanel), TaskFactory.class, props);
    }
    {
        Properties props = new Properties();
        props.setProperty(COMMAND, "export");
        props.setProperty(COMMAND_NAMESPACE, "filter");
        props.setProperty(COMMAND_DESCRIPTION, "Export filter JSON to a file.");
        props.setProperty(COMMAND_LONG_DESCRIPTION, "Export filter JSON to a file.");
        registerService(bc, new ExportNamedTransformersTaskFactory(filterIo, filterPanelController), TaskFactory.class, props);
    }
}
Also used : TransformerViewManager(org.cytoscape.filter.internal.view.TransformerViewManager) InteractionTransformerFactory(org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerFactory) CyNetwork(org.cytoscape.model.CyNetwork) ServiceProperties(org.cytoscape.work.ServiceProperties) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) FilterPanel(org.cytoscape.filter.internal.view.FilterPanel) FilterPanelStyle(org.cytoscape.filter.internal.view.look.FilterPanelStyle) ExportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ExportNamedTransformersTaskFactory) AdjacencyTransformerFactory(org.cytoscape.filter.internal.transformers.adjacency.AdjacencyTransformerFactory) LazyWorkQueue(org.cytoscape.filter.internal.work.LazyWorkQueue) TransformerManagerImpl(org.cytoscape.filter.internal.work.TransformerManagerImpl) ColumnFilterFactory(org.cytoscape.filter.internal.filters.column.ColumnFilterFactory) CyIdentifiable(org.cytoscape.model.CyIdentifiable) ValidationManager(org.cytoscape.filter.internal.work.ValidationManager) AdjacencyTransformerViewFactory(org.cytoscape.filter.internal.transformers.adjacency.AdjacencyTransformerViewFactory) ColumnFilterViewFactory(org.cytoscape.filter.internal.filters.column.ColumnFilterViewFactory) ImportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ImportNamedTransformersTaskFactory) TopologyFilterFactory(org.cytoscape.filter.internal.filters.topology.TopologyFilterFactory) InteractionTransformerViewFactory(org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerViewFactory) DegreeFilterFactory(org.cytoscape.filter.internal.filters.degree.DegreeFilterFactory) TopologyFilterViewFactory(org.cytoscape.filter.internal.filters.topology.TopologyFilterViewFactory) TransformerPanelController(org.cytoscape.filter.internal.view.TransformerPanelController) TransformerContainer(org.cytoscape.filter.TransformerContainer) TransformerPanel(org.cytoscape.filter.internal.view.TransformerPanel) FlatStyle(org.cytoscape.filter.internal.view.look.FlatStyle) FilterWorker(org.cytoscape.filter.internal.work.FilterWorker) DegreeFilterViewFactory(org.cytoscape.filter.internal.filters.degree.DegreeFilterViewFactory) TaskFactory(org.cytoscape.work.TaskFactory) ExportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ExportNamedTransformersTaskFactory) ImportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ImportNamedTransformersTaskFactory) FilterPanelController(org.cytoscape.filter.internal.view.FilterPanelController) TransformerWorker(org.cytoscape.filter.internal.work.TransformerWorker) CytoPanelComponent(org.cytoscape.application.swing.CytoPanelComponent)

Example 3 with TransformerPanel

use of org.cytoscape.filter.internal.view.TransformerPanel in project cytoscape-impl by cytoscape.

the class CompositeTransformerPanel method updateLayout.

@Override
public void updateLayout() {
    removeAll();
    final ParallelGroup checkBoxGroup = layout.createParallelGroup(Alignment.LEADING);
    final ParallelGroup viewGroup = layout.createParallelGroup(Alignment.LEADING);
    final Group columns = layout.createParallelGroup(Alignment.LEADING, true).addGroup(layout.createSequentialGroup().addGap(4).addGroup(checkBoxGroup).addGap(4).addGroup(viewGroup));
    final Group rows = layout.createSequentialGroup();
    int separatorHeight = 5;
    viewGroup.addComponent(separator);
    rows.addComponent(separator, separatorHeight, separatorHeight, separatorHeight);
    for (Transformer<CyNetwork, CyIdentifiable> transformer : model) {
        final TransformerElementViewModel<TransformerPanel> viewModel = viewModels.get(transformer);
        if (viewModel.view instanceof CompositeFilterPanel) {
            CompositeFilterPanel<?> panel = (CompositeFilterPanel<?>) viewModel.view;
            panel.updateLayout();
        }
        checkBoxGroup.addGroup(layout.createParallelGroup().addGroup(layout.createSequentialGroup().addComponent(viewModel.deleteButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE).addGap(4).addComponent(viewModel.handle, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE)).addGap(4).addComponent(viewModel.warnIcon, Alignment.CENTER));
        viewGroup.addComponent(viewModel.view, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE).addComponent(viewModel.separator);
        rows.addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(ViewUtil.INTERNAL_VERTICAL_PADDING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup().addComponent(viewModel.deleteButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE).addComponent(viewModel.handle, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)).addGap(4).addComponent(viewModel.warnIcon))).addComponent(viewModel.view, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
        rows.addComponent(viewModel.separator, separatorHeight, separatorHeight, separatorHeight);
    }
    columns.addComponent(addButton);
    rows.addGap(ViewUtil.INTERNAL_VERTICAL_PADDING).addComponent(addButton);
    layout.setHorizontalGroup(columns);
    layout.setVerticalGroup(rows);
}
Also used : ParallelGroup(javax.swing.GroupLayout.ParallelGroup) ParallelGroup(javax.swing.GroupLayout.ParallelGroup) Group(javax.swing.GroupLayout.Group) TransformerPanel(org.cytoscape.filter.internal.view.TransformerPanel) CyNetwork(org.cytoscape.model.CyNetwork) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 4 with TransformerPanel

use of org.cytoscape.filter.internal.view.TransformerPanel in project cytoscape-impl by cytoscape.

the class UiScaffold method start.

void start() {
    MockitoAnnotations.initMocks(this);
    Random random = new Random(0);
    NetworkTestSupport networkTestSupport = new NetworkTestSupport();
    CyNetwork network = networkTestSupport.getNetwork();
    CyTable nodeTable = network.getDefaultNodeTable();
    nodeTable.createColumn("Score", Double.class, false);
    nodeTable.createColumn("IsSpecial", Boolean.class, false);
    for (int i = 0; i < TOTAL_NODES; i++) {
        CyNode node = network.addNode();
        network.getRow(node).set("Score", random.nextGaussian());
        network.getRow(node).set("IsSpecial", i % 2 == 0);
    }
    List<CyNode> nodes = network.getNodeList();
    for (int i = 0; i < TOTAL_EDGES; i++) {
        CyNode source = nodes.get(random.nextInt(nodes.size()));
        CyNode target = nodes.get(random.nextInt(nodes.size()));
        network.addEdge(source, target, false);
    }
    when(applicationManager.getCurrentNetworkView()).thenReturn(networkView);
    when(applicationManager.getCurrentNetwork()).thenReturn(network);
    when(networkView.getModel()).thenReturn(network);
    when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(applicationManager);
    when(serviceRegistrar.getService(TaskManager.class)).thenReturn(taskManager);
    when(serviceRegistrar.getService(IconManager.class)).thenReturn(iconManager);
    JFrame frame = new JFrame();
    frame.setTitle("Select");
    Map<String, String> properties = Collections.emptyMap();
    TransformerManagerImpl transformerManager = new TransformerManagerImpl();
    transformerManager.registerFilterFactory(new ColumnFilterFactory(), properties);
    transformerManager.registerFilterFactory(new DegreeFilterFactory(), properties);
    transformerManager.registerFilterFactory(new TopologyFilterFactory(), properties);
    transformerManager.registerElementTransformerFactory(new InteractionTransformerFactory(), properties);
    ModelMonitor modelMonitor = new ModelMonitor();
    modelMonitor.handleEvent(new SetCurrentNetworkEvent(applicationManager, network));
    ValidationManager validationManager = new ValidationManager();
    FilterPanelStyle style = new StandardStyle();
    TransformerViewManager transformerViewManager = new TransformerViewManager(transformerManager);
    // transformerViewManager.registerTransformerViewFactory(new ColumnFilterViewFactory(style, modelMonitor), properties);
    transformerViewManager.registerTransformerViewFactory(new DegreeFilterViewFactory(style, modelMonitor), properties);
    transformerViewManager.registerTransformerViewFactory(new TopologyFilterViewFactory(style), properties);
    transformerViewManager.registerTransformerViewFactory(new InteractionTransformerViewFactory(style), properties);
    LazyWorkQueue queue = new LazyWorkQueue();
    FilterWorker filterWorker = new FilterWorker(queue, serviceRegistrar);
    FilterIO filterIo = null;
    FilterPanelController filterPanelController = new FilterPanelController(transformerManager, transformerViewManager, validationManager, filterWorker, modelMonitor, filterIo, style, serviceRegistrar);
    FilterPanel filterPanel = new FilterPanel(filterPanelController, filterWorker, serviceRegistrar);
    TransformerWorker transformerWorker = new TransformerWorker(queue, transformerManager, serviceRegistrar);
    TransformerPanelController transformerPanelController = new TransformerPanelController(transformerManager, transformerViewManager, validationManager, filterPanelController, transformerWorker, filterIo, style, serviceRegistrar);
    TransformerPanel transformerPanel = new TransformerPanel(transformerPanelController, transformerWorker, serviceRegistrar);
    SelectPanel selectPanel = new SelectPanel(filterPanel, transformerPanel);
    JRootPane root = frame.getRootPane();
    root.setLayout(new GridBagLayout());
    root.add(selectPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    frame.setSize(450, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
Also used : TransformerViewManager(org.cytoscape.filter.internal.view.TransformerViewManager) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) InteractionTransformerFactory(org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerFactory) CyNetwork(org.cytoscape.model.CyNetwork) FilterPanel(org.cytoscape.filter.internal.view.FilterPanel) FilterPanelStyle(org.cytoscape.filter.internal.view.look.FilterPanelStyle) CyTable(org.cytoscape.model.CyTable) Random(java.util.Random) JFrame(javax.swing.JFrame) CyNode(org.cytoscape.model.CyNode) LazyWorkQueue(org.cytoscape.filter.internal.work.LazyWorkQueue) SetCurrentNetworkEvent(org.cytoscape.application.events.SetCurrentNetworkEvent) TransformerManagerImpl(org.cytoscape.filter.internal.work.TransformerManagerImpl) ColumnFilterFactory(org.cytoscape.filter.internal.filters.column.ColumnFilterFactory) ValidationManager(org.cytoscape.filter.internal.work.ValidationManager) StandardStyle(org.cytoscape.filter.internal.view.look.StandardStyle) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) TopologyFilterFactory(org.cytoscape.filter.internal.filters.topology.TopologyFilterFactory) InteractionTransformerViewFactory(org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerViewFactory) DegreeFilterFactory(org.cytoscape.filter.internal.filters.degree.DegreeFilterFactory) SelectPanel(org.cytoscape.filter.internal.view.SelectPanel) TopologyFilterViewFactory(org.cytoscape.filter.internal.filters.topology.TopologyFilterViewFactory) TransformerPanelController(org.cytoscape.filter.internal.view.TransformerPanelController) TransformerPanel(org.cytoscape.filter.internal.view.TransformerPanel) FilterWorker(org.cytoscape.filter.internal.work.FilterWorker) DegreeFilterViewFactory(org.cytoscape.filter.internal.filters.degree.DegreeFilterViewFactory) FilterPanelController(org.cytoscape.filter.internal.view.FilterPanelController) JRootPane(javax.swing.JRootPane) TransformerWorker(org.cytoscape.filter.internal.work.TransformerWorker)

Aggregations

TransformerPanel (org.cytoscape.filter.internal.view.TransformerPanel)4 CyNetwork (org.cytoscape.model.CyNetwork)4 CyIdentifiable (org.cytoscape.model.CyIdentifiable)3 ColumnFilterFactory (org.cytoscape.filter.internal.filters.column.ColumnFilterFactory)2 DegreeFilterFactory (org.cytoscape.filter.internal.filters.degree.DegreeFilterFactory)2 DegreeFilterViewFactory (org.cytoscape.filter.internal.filters.degree.DegreeFilterViewFactory)2 TopologyFilterFactory (org.cytoscape.filter.internal.filters.topology.TopologyFilterFactory)2 TopologyFilterViewFactory (org.cytoscape.filter.internal.filters.topology.TopologyFilterViewFactory)2 InteractionTransformerFactory (org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerFactory)2 InteractionTransformerViewFactory (org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerViewFactory)2 FilterPanel (org.cytoscape.filter.internal.view.FilterPanel)2 FilterPanelController (org.cytoscape.filter.internal.view.FilterPanelController)2 TransformerPanelController (org.cytoscape.filter.internal.view.TransformerPanelController)2 TransformerViewManager (org.cytoscape.filter.internal.view.TransformerViewManager)2 FilterPanelStyle (org.cytoscape.filter.internal.view.look.FilterPanelStyle)2 FilterWorker (org.cytoscape.filter.internal.work.FilterWorker)2 LazyWorkQueue (org.cytoscape.filter.internal.work.LazyWorkQueue)2 TransformerManagerImpl (org.cytoscape.filter.internal.work.TransformerManagerImpl)2 TransformerWorker (org.cytoscape.filter.internal.work.TransformerWorker)2 ValidationManager (org.cytoscape.filter.internal.work.ValidationManager)2