Search in sources :

Example 1 with VizMapperMainPanel

use of org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel in project cytoscape-impl by cytoscape.

the class EditSelectedDiscreteValuesAction method actionPerformed.

// ==[ PUBLIC METHODS ]=============================================================================================
/**
 * Edit all selected cells at once. This is for Discrete Mapping only.
 */
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void actionPerformed(final ActionEvent e) {
    final VizMapperMainPanel vizMapperMainPanel = getVizMapperMainPanel();
    if (vizMapperMainPanel == null)
        return;
    final VisualPropertySheet vpSheet = vizMapperMainPanel.getSelectedVisualPropertySheet();
    if (vpSheet == null)
        return;
    for (final VisualPropertySheetItem<?> vpSheetItem : vpSheet.getSelectedItems()) {
        final VisualPropertySheetItemModel<?> model = vpSheetItem.getModel();
        final PropertySheetTable table = vpSheetItem.getPropSheetPnl().getTable();
        final int[] selected = table.getSelectedRows();
        if (selected == null || selected.length == 0 || !(model.getVisualMappingFunction() instanceof DiscreteMapping))
            continue;
        // Test with the first selected item
        final DiscreteMapping dm = (DiscreteMapping) model.getVisualMappingFunction();
        final VisualProperty vp = dm.getVisualProperty();
        Object newValue = null;
        try {
            // Get new value
            newValue = editorManager.showVisualPropertyValueEditor(vizMapperMainPanel, vp, vp.getDefault());
        } catch (Exception ex) {
            logger.error("Could not edit value.", ex);
        }
        if (newValue == null)
            continue;
        final Map<Object, Object> newValues = new HashMap<Object, Object>();
        final Map<Object, Object> previousValues = new HashMap<Object, Object>();
        for (int i = 0; i < selected.length; i++) {
            final Item item = ((Item) table.getValueAt(selected[i], 0));
            if (item != null && item.getProperty() instanceof VizMapperProperty) {
                final VizMapperProperty<?, ?, ?> prop = (VizMapperProperty<?, ?, ?>) item.getProperty();
                if (prop.getCellType() == CellType.DISCRETE) {
                    // Save the current value for undo
                    previousValues.put(prop.getKey(), prop.getValue());
                    // New value
                    newValues.put(prop.getKey(), newValue);
                }
            }
        }
        // Save the mapping->old_values for undo
        if (!previousValues.isEmpty())
            previousMappingValues.put(dm, previousValues);
        // Save the mapping->new_values for redo
        if (!newValues.isEmpty())
            newMappingValues.put(dm, newValues);
        // Update the visual mapping
        dm.putAll(newValues);
    }
    // Undo support
    if (!previousMappingValues.isEmpty()) {
        final UndoSupport undo = servicesUtil.get(UndoSupport.class);
        undo.postEdit(new EditSelectedDiscreteValuesEdit());
    }
}
Also used : VisualPropertySheet(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet) HashMap(java.util.HashMap) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) UndoSupport(org.cytoscape.work.undo.UndoSupport) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty) VisualPropertySheetItem(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem) Item(com.l2fprod.common.propertysheet.PropertySheetTableModel.Item) PropertySheetTable(com.l2fprod.common.propertysheet.PropertySheetTable) VizMapperMainPanel(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel) VisualProperty(org.cytoscape.view.model.VisualProperty)

Example 2 with VizMapperMainPanel

use of org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel in project cytoscape-impl by cytoscape.

the class EditSelectedDiscreteValuesAction method updateEnableState.

@Override
public void updateEnableState() {
    boolean enabled = false;
    final VizMapperMainPanel vizMapperMainPanel = getVizMapperMainPanel();
    VisualPropertySheet vpSheet = null;
    if (vizMapperMainPanel != null)
        vpSheet = vizMapperMainPanel.getSelectedVisualPropertySheet();
    if (vpSheet != null) {
        for (final VisualPropertySheetItem<?> vpSheetItem : vpSheet.getSelectedItems()) {
            final VisualPropertySheetItemModel<?> model = vpSheetItem.getModel();
            final PropertySheetTable table = vpSheetItem.getPropSheetPnl().getTable();
            final int[] selected = table.getSelectedRows();
            if (selected != null && model.getVisualMappingFunction() instanceof DiscreteMapping) {
                // Make sure the selected rows have at least one Discrete Mapping entry
                for (int i = 0; i < selected.length; i++) {
                    final Item item = (Item) table.getValueAt(selected[i], 0);
                    if (item != null && item.getProperty() instanceof VizMapperProperty) {
                        final VizMapperProperty<?, ?, ?> prop = (VizMapperProperty<?, ?, ?>) item.getProperty();
                        if (prop.getCellType() == CellType.DISCRETE) {
                            enabled = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    setEnabled(enabled);
}
Also used : VisualPropertySheetItem(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem) Item(com.l2fprod.common.propertysheet.PropertySheetTableModel.Item) VisualPropertySheet(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet) PropertySheetTable(com.l2fprod.common.propertysheet.PropertySheetTable) VizMapperMainPanel(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty)

Example 3 with VizMapperMainPanel

use of org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(final BundleContext bc) {
    final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    final ServicesUtil servicesUtil = new ServicesUtil(serviceRegistrar, ApplicationFacade.NAME);
    final AttributeSetProxy attributeSetProxy = new AttributeSetProxy(servicesUtil);
    final MappingFunctionFactoryProxy mappingFactoryProxy = new MappingFunctionFactoryProxy(servicesUtil);
    final EditorManagerImpl editorManager = new EditorManagerImpl(attributeSetProxy, mappingFactoryProxy, servicesUtil);
    // These listeners must be registered before the ValueEditors and VisualPropertyEditors:
    registerServiceListener(bc, editorManager::addValueEditor, editorManager::removeValueEditor, ValueEditor.class);
    registerServiceListener(bc, editorManager::addVisualPropertyValueEditor, editorManager::removeVisualPropertyValueEditor, VisualPropertyValueEditor.class);
    registerServiceListener(bc, editorManager::addVisualPropertyEditor, editorManager::removeVisualPropertyEditor, VisualPropertyEditor.class);
    registerServiceListener(bc, editorManager::addRenderingEngineFactory, editorManager::removeRenderingEngineFactory, RenderingEngineFactory.class);
    registerAllServices(bc, editorManager);
    final MappingFunctionFactoryManagerImpl mappingFunctionFactoryManager = new MappingFunctionFactoryManagerImpl();
    registerServiceListener(bc, mappingFunctionFactoryManager::addFactory, mappingFunctionFactoryManager::removeFactory, VisualMappingFunctionFactory.class);
    registerAllServices(bc, mappingFunctionFactoryManager);
    final NumericValueEditor<Double> doubleValueEditor = new NumericValueEditor<>(Double.class);
    final NumericValueEditor<Integer> integerValueEditor = new NumericValueEditor<>(Integer.class);
    final NumericValueEditor<Float> floatValueEditor = new NumericValueEditor<>(Float.class);
    final StringValueEditor stringValueEditor = new StringValueEditor();
    final BooleanValueEditor booleanValueEditor = new BooleanValueEditor();
    final FontValueEditor fontValueEditor = new FontValueEditor(servicesUtil);
    final CyColorChooser colorChooser = new CyColorChooser();
    final CyColorPropertyEditor cyColorPropertyEditor = new CyColorPropertyEditor(colorChooser, servicesUtil);
    final CyFontPropertyEditor cyFontPropertyEditor = new CyFontPropertyEditor();
    final ContinuousMappingCellRendererFactory cmCellRendererFactory = getService(bc, ContinuousMappingCellRendererFactory.class);
    final ColorVisualPropertyEditor colorPropertyEditor = new ColorVisualPropertyEditor(Paint.class, editorManager, cyColorPropertyEditor, cmCellRendererFactory);
    final NumberVisualPropertyEditor<Double> doublePropertyEditor = new NumberVisualPropertyEditor<>(Double.class, cmCellRendererFactory);
    final NumberVisualPropertyEditor<Integer> integerPropertyEditor = new NumberVisualPropertyEditor<>(Integer.class, cmCellRendererFactory);
    final NumberVisualPropertyEditor<Float> floatPropertyEditor = new NumberVisualPropertyEditor<>(Float.class, cmCellRendererFactory);
    final FontVisualPropertyEditor fontVisualPropertyEditor = new FontVisualPropertyEditor(Font.class, cyFontPropertyEditor, cmCellRendererFactory);
    final StringVisualPropertyEditor stringPropertyEditor = new StringVisualPropertyEditor(cmCellRendererFactory);
    final CyComboBoxPropertyEditor booleanEditor = new CyComboBoxPropertyEditor();
    booleanEditor.setAvailableValues(new Boolean[] { true, false });
    final BooleanVisualPropertyEditor booleanVisualPropertyEditor = new BooleanVisualPropertyEditor(booleanEditor, cmCellRendererFactory);
    // Context menu for edge bend
    final Properties clearAllBendsForThisEdgeProps = new Properties();
    clearAllBendsForThisEdgeProps.put(ServiceProperties.PREFERRED_MENU, ServiceProperties.EDGE_EDIT_MENU);
    clearAllBendsForThisEdgeProps.put(ServiceProperties.TITLE, "Clear All Bends For This Edge");
    clearAllBendsForThisEdgeProps.put(ServiceProperties.MENU_GRAVITY, "5.0");
    clearAllBendsForThisEdgeProps.put(ServiceProperties.INSERT_SEPARATOR_BEFORE, "true");
    final ClearAllBendsForThisEdgeTaskFactory clearAllBendsForThisEdgeTaskFactory = new ClearAllBendsForThisEdgeTaskFactory(servicesUtil);
    registerService(bc, clearAllBendsForThisEdgeTaskFactory, EdgeViewTaskFactory.class, clearAllBendsForThisEdgeProps);
    // Register ValueEditors and VisualPropertyEditors
    // -------------------------------------------------------------------------------------------------------------
    registerAllServices(bc, attributeSetProxy);
    registerAllServices(bc, editorManager.getNodeEditor());
    registerAllServices(bc, editorManager.getEdgeEditor());
    registerAllServices(bc, editorManager.getNetworkEditor());
    registerAllServices(bc, colorChooser);
    registerAllServices(bc, doubleValueEditor);
    registerAllServices(bc, integerValueEditor);
    registerAllServices(bc, floatValueEditor);
    registerAllServices(bc, stringValueEditor);
    registerAllServices(bc, booleanValueEditor);
    registerAllServices(bc, fontValueEditor);
    registerAllServices(bc, colorPropertyEditor);
    registerAllServices(bc, doublePropertyEditor);
    registerAllServices(bc, floatPropertyEditor);
    registerAllServices(bc, integerPropertyEditor);
    registerAllServices(bc, fontVisualPropertyEditor);
    registerAllServices(bc, stringPropertyEditor);
    registerAllServices(bc, booleanVisualPropertyEditor);
    // Tasks
    // -------------------------------------------------------------------------------------------------------------
    final CreateNewVisualStyleTaskFactory createNewVisualStyleTaskFactory = new CreateNewVisualStyleTaskFactory(servicesUtil);
    final Properties createNewVisualStyleTaskFactoryProps = new Properties();
    createNewVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    createNewVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.TITLE, CreateNewVisualStyleTask.TITLE + "...");
    createNewVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.MENU_ID, ServicePropertiesUtil.MAIN_MENU);
    createNewVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.GRAVITY, "1.0");
    registerAllServices(bc, createNewVisualStyleTaskFactory, createNewVisualStyleTaskFactoryProps);
    final CopyVisualStyleTaskFactory copyVisualStyleTaskFactory = new CopyVisualStyleTaskFactory(servicesUtil);
    final Properties copyVisualStyleTaskFactoryProps = new Properties();
    copyVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    copyVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.TITLE, CopyVisualStyleTask.TITLE + "...");
    copyVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.MENU_ID, ServicePropertiesUtil.MAIN_MENU);
    copyVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.GRAVITY, "2.0");
    registerAllServices(bc, copyVisualStyleTaskFactory, copyVisualStyleTaskFactoryProps);
    final RenameVisualStyleTaskFactory renameVisualStyleTaskFactory = new RenameVisualStyleTaskFactory(servicesUtil);
    final Properties renameVisualStyleTaskFactoryProps = new Properties();
    renameVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    renameVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.TITLE, RenameVisualStyleTask.TITLE + "...");
    renameVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.MENU_ID, ServicePropertiesUtil.MAIN_MENU);
    renameVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.GRAVITY, "3.0");
    registerAllServices(bc, renameVisualStyleTaskFactory, renameVisualStyleTaskFactoryProps);
    final RemoveVisualStyleTaskFactory removeVisualStyleTaskFactory = new RemoveVisualStyleTaskFactory(servicesUtil);
    final Properties removeVisualStyleTaskFactoryProps = new Properties();
    removeVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    removeVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.TITLE, RemoveVisualStyleTask.TITLE);
    removeVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.MENU_ID, ServicePropertiesUtil.MAIN_MENU);
    removeVisualStyleTaskFactoryProps.setProperty(ServicePropertiesUtil.GRAVITY, "4.0");
    registerAllServices(bc, removeVisualStyleTaskFactory, removeVisualStyleTaskFactoryProps);
    final MakeVisualStylesDefaultTaskFactory makeVisualStylesDefaultTaskFactory = new MakeVisualStylesDefaultTaskFactory(servicesUtil);
    final Properties makeVisualStylesDefaultTaskFactoryProps = new Properties();
    makeVisualStylesDefaultTaskFactoryProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    makeVisualStylesDefaultTaskFactoryProps.setProperty(ServicePropertiesUtil.TITLE, MakeVisualStylesDefaultTask.TITLE);
    makeVisualStylesDefaultTaskFactoryProps.setProperty(ServicePropertiesUtil.MENU_ID, ServicePropertiesUtil.MAIN_MENU);
    makeVisualStylesDefaultTaskFactoryProps.setProperty(ServicePropertiesUtil.GRAVITY, "5.0");
    makeVisualStylesDefaultTaskFactoryProps.setProperty(ServicePropertiesUtil.INSERT_SEPARATOR_BEFORE, "true");
    registerAllServices(bc, makeVisualStylesDefaultTaskFactory, makeVisualStylesDefaultTaskFactoryProps);
    final CreateLegendTaskFactory createLegendTaskFactory = new CreateLegendTaskFactory(servicesUtil);
    final Properties createLegendTaskFactoryProps = new Properties();
    createLegendTaskFactoryProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    createLegendTaskFactoryProps.setProperty(ServicePropertiesUtil.TITLE, CreateLegendTask.TITLE + "...");
    createLegendTaskFactoryProps.setProperty(ServicePropertiesUtil.MENU_ID, ServicePropertiesUtil.MAIN_MENU);
    createLegendTaskFactoryProps.setProperty(ServicePropertiesUtil.GRAVITY, "6.0");
    createLegendTaskFactoryProps.setProperty(ServicePropertiesUtil.INSERT_SEPARATOR_BEFORE, "true");
    registerAllServices(bc, createLegendTaskFactory, createLegendTaskFactoryProps);
    // Visual Styles Panel Context Menu
    // -------------------------------------------------------------------------------------------------------------
    // Edit sub-menu
    final EditSelectedDiscreteValuesAction editAction = new EditSelectedDiscreteValuesAction(servicesUtil, editorManager);
    final Properties editSelectedProps = new Properties();
    editSelectedProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    editSelectedProps.setProperty(ServicePropertiesUtil.TITLE, EditSelectedDiscreteValuesAction.NAME);
    editSelectedProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    editSelectedProps.setProperty(ServicePropertiesUtil.GRAVITY, "1.0");
    registerService(bc, editAction, CyAction.class, editSelectedProps);
    final RemoveSelectedDiscreteValuesAction removeAction = new RemoveSelectedDiscreteValuesAction(servicesUtil);
    final Properties removeSelectedProps = new Properties();
    removeSelectedProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    removeSelectedProps.setProperty(ServicePropertiesUtil.TITLE, RemoveSelectedDiscreteValuesAction.NAME);
    removeSelectedProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    removeSelectedProps.setProperty(ServicePropertiesUtil.GRAVITY, "2.0");
    registerService(bc, removeAction, CyAction.class, removeSelectedProps);
    final RemoveVisualMappingsTaskFactory removeVisualMappingsTaskFactory = new RemoveVisualMappingsTaskFactory(servicesUtil);
    final Properties removeVisualMappingTaskFactoryProps = new Properties();
    removeVisualMappingTaskFactoryProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    removeVisualMappingTaskFactoryProps.setProperty(ServicePropertiesUtil.TITLE, "Remove Mappings from Selected Visual Properties");
    removeVisualMappingTaskFactoryProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    removeVisualMappingTaskFactoryProps.setProperty(ServicePropertiesUtil.GRAVITY, "3.0");
    removeVisualMappingTaskFactoryProps.setProperty(ServicePropertiesUtil.INSERT_SEPARATOR_BEFORE, "true");
    registerAllServices(bc, removeVisualMappingsTaskFactory, removeVisualMappingTaskFactoryProps);
    // Discrete value generators:
    final RainbowColorMappingGenerator rainbowGenerator = new RainbowColorMappingGenerator(Color.class);
    final Properties rainbowGeneratorProps = new Properties();
    rainbowGeneratorProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI");
    rainbowGeneratorProps.setProperty(ServicePropertiesUtil.TITLE, "Rainbow");
    rainbowGeneratorProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    registerService(bc, rainbowGenerator, DiscreteMappingGenerator.class, rainbowGeneratorProps);
    final RainbowOscColorMappingGenerator rainbowOscGenerator = new RainbowOscColorMappingGenerator(Color.class);
    final Properties rainbowOscGeneratorProps = new Properties();
    rainbowOscGeneratorProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI.contextMenu");
    rainbowOscGeneratorProps.setProperty(ServicePropertiesUtil.TITLE, "Rainbow OSC");
    rainbowOscGeneratorProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    registerService(bc, rainbowOscGenerator, DiscreteMappingGenerator.class, rainbowOscGeneratorProps);
    final RandomColorMappingGenerator randomColorGenerator = new RandomColorMappingGenerator(Color.class);
    final Properties randomColorGeneratorProps = new Properties();
    randomColorGeneratorProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI.contextMenu");
    randomColorGeneratorProps.setProperty(ServicePropertiesUtil.TITLE, "Random Color");
    randomColorGeneratorProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    registerService(bc, randomColorGenerator, DiscreteMappingGenerator.class, randomColorGeneratorProps);
    final NumberSeriesMappingGenerator<Number> seriesGenerator = new NumberSeriesMappingGenerator<Number>(Number.class);
    final Properties numberSeriesGeneratorProps = new Properties();
    numberSeriesGeneratorProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI.contextMenu");
    numberSeriesGeneratorProps.setProperty(ServicePropertiesUtil.TITLE, "Number Series");
    numberSeriesGeneratorProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    registerService(bc, seriesGenerator, DiscreteMappingGenerator.class, numberSeriesGeneratorProps);
    final RandomNumberMappingGenerator randomNumberGenerator = new RandomNumberMappingGenerator();
    final Properties randomNumberGeneratorProps = new Properties();
    randomNumberGeneratorProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI.contextMenu");
    randomNumberGeneratorProps.setProperty(ServicePropertiesUtil.TITLE, "Random Numbers");
    randomNumberGeneratorProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    registerService(bc, randomNumberGenerator, DiscreteMappingGenerator.class, randomNumberGeneratorProps);
    final FitLabelMappingGenerator<Double> fitLabelMappingGenerator = new FitLabelMappingGenerator<Double>(Double.class, servicesUtil);
    final Properties fitLabelGeneratorProps = new Properties();
    fitLabelGeneratorProps.setProperty(ServicePropertiesUtil.SERVICE_TYPE, "vizmapUI.contextMenu");
    fitLabelGeneratorProps.setProperty(ServicePropertiesUtil.TITLE, "Fit label width (only works with 'name' column to node size or width)");
    fitLabelGeneratorProps.setProperty(ServicePropertiesUtil.MENU_ID, "context");
    registerService(bc, fitLabelMappingGenerator, DiscreteMappingGenerator.class, fitLabelGeneratorProps);
    // Create the main GUI component
    // -------------------------------------------------------------------------------------------------------------
    final VizMapperMainPanel vizMapperMainPanel = new VizMapperMainPanel(servicesUtil);
    // Start the PureMVC components
    // -------------------------------------------------------------------------------------------------------------
    final VizMapperProxy vizMapperProxy = new VizMapperProxy(servicesUtil);
    final PropsProxy propsProxy = new PropsProxy(servicesUtil);
    final VizMapPropertyBuilder vizMapPropertyBuilder = new VizMapPropertyBuilder(editorManager, mappingFunctionFactoryManager, servicesUtil);
    final VizMapperMediator vizMapperMediator = new VizMapperMediator(vizMapperMainPanel, servicesUtil, vizMapPropertyBuilder);
    final VizMapperMenuMediator vizMapperMenuMediator = new VizMapperMenuMediator(vizMapperMainPanel, servicesUtil);
    final StartupCommand startupCommand = new StartupCommand(vizMapperProxy, attributeSetProxy, mappingFactoryProxy, propsProxy, vizMapperMediator, vizMapperMenuMediator, servicesUtil);
    registerAllServices(bc, vizMapperProxy);
    registerAllServices(bc, mappingFactoryProxy);
    registerAllServices(bc, propsProxy);
    registerAllServices(bc, vizMapperMediator);
    registerServiceListener(bc, vizMapperMediator::onCyActionRegistered, vizMapperMediator::onCyActionUnregistered, CyAction.class);
    registerServiceListener(bc, vizMapperMediator::onTaskFactoryRegistered, vizMapperMediator::onTaskFactoryUnregistered, TaskFactory.class);
    registerServiceListener(bc, vizMapperMediator::onMappingGeneratorRegistered, vizMapperMediator::onMappingGeneratorUnregistered, DiscreteMappingGenerator.class);
    registerServiceListener(bc, vizMapperMenuMediator::onRenderingEngineFactoryRegistered, vizMapperMenuMediator::onRenderingEngineFactoryUnregistered, RenderingEngineFactory.class);
    final VizMapEventHandlerManagerImpl vizMapEventHandlerManager = new VizMapEventHandlerManagerImpl(editorManager, attributeSetProxy, servicesUtil, vizMapPropertyBuilder, vizMapperMediator);
    registerServiceListener(bc, vizMapEventHandlerManager::registerPCL, vizMapEventHandlerManager::unregisterPCL, RenderingEngineFactory.class);
    // Startup the framework
    new ApplicationFacade(startupCommand).startup();
}
Also used : CyFontPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.propertyeditor.CyFontPropertyEditor) NumberVisualPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.NumberVisualPropertyEditor) VizMapperMediator(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMediator) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) NumberSeriesMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.NumberSeriesMappingGenerator) AttributeSetProxy(org.cytoscape.view.vizmap.gui.internal.model.AttributeSetProxy) CyColorChooser(org.cytoscape.view.vizmap.gui.internal.view.editor.valueeditor.CyColorChooser) CyColorPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.propertyeditor.CyColorPropertyEditor) StringValueEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.valueeditor.StringValueEditor) RandomNumberMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RandomNumberMappingGenerator) ClearAllBendsForThisEdgeTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.ClearAllBendsForThisEdgeTaskFactory) MappingFunctionFactoryProxy(org.cytoscape.view.vizmap.gui.internal.model.MappingFunctionFactoryProxy) RemoveSelectedDiscreteValuesAction(org.cytoscape.view.vizmap.gui.internal.action.RemoveSelectedDiscreteValuesAction) MakeVisualStylesDefaultTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.MakeVisualStylesDefaultTaskFactory) RandomColorMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RandomColorMappingGenerator) RemoveVisualMappingsTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.RemoveVisualMappingsTaskFactory) NumericValueEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.valueeditor.NumericValueEditor) VizMapperMenuMediator(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMenuMediator) BooleanVisualPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.BooleanVisualPropertyEditor) RainbowOscColorMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RainbowOscColorMappingGenerator) EditorManagerImpl(org.cytoscape.view.vizmap.gui.internal.view.editor.EditorManagerImpl) StringVisualPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.StringVisualPropertyEditor) ServiceProperties(org.cytoscape.work.ServiceProperties) Properties(java.util.Properties) CopyVisualStyleTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.CopyVisualStyleTaskFactory) ContinuousMappingCellRendererFactory(org.cytoscape.view.vizmap.gui.editor.ContinuousMappingCellRendererFactory) VizMapPropertyBuilder(org.cytoscape.view.vizmap.gui.internal.view.VizMapPropertyBuilder) VizMapperProxy(org.cytoscape.view.vizmap.gui.internal.model.VizMapperProxy) BooleanValueEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.valueeditor.BooleanValueEditor) VizMapperMainPanel(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel) RainbowColorMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RainbowColorMappingGenerator) RemoveVisualStyleTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.RemoveVisualStyleTaskFactory) PropsProxy(org.cytoscape.view.vizmap.gui.internal.model.PropsProxy) EditSelectedDiscreteValuesAction(org.cytoscape.view.vizmap.gui.internal.action.EditSelectedDiscreteValuesAction) CreateNewVisualStyleTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.CreateNewVisualStyleTaskFactory) FontVisualPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.FontVisualPropertyEditor) VizMapEventHandlerManagerImpl(org.cytoscape.view.vizmap.gui.internal.event.VizMapEventHandlerManagerImpl) FontValueEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.valueeditor.FontValueEditor) FitLabelMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.FitLabelMappingGenerator) ServicesUtil(org.cytoscape.view.vizmap.gui.internal.util.ServicesUtil) StartupCommand(org.cytoscape.view.vizmap.gui.internal.controller.StartupCommand) ColorVisualPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.ColorVisualPropertyEditor) CyComboBoxPropertyEditor(org.cytoscape.view.vizmap.gui.internal.view.editor.propertyeditor.CyComboBoxPropertyEditor) CreateLegendTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.CreateLegendTaskFactory) RenameVisualStyleTaskFactory(org.cytoscape.view.vizmap.gui.internal.task.RenameVisualStyleTaskFactory)

Example 4 with VizMapperMainPanel

use of org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel in project cytoscape-impl by cytoscape.

the class RemoveVisualMappingsTaskFactory method createTaskIterator.

@Override
public TaskIterator createTaskIterator() {
    final VisualStyle style = servicesUtil.get(VisualMappingManager.class).getCurrentVisualStyle();
    final Set<VisualMappingFunction<?, ?>> mappings = new HashSet<VisualMappingFunction<?, ?>>();
    final VizMapGUI gui = servicesUtil.get(VizMapGUI.class);
    if (gui instanceof VizMapperMainPanel) {
        final VisualPropertySheet vpSheet = ((VizMapperMainPanel) gui).getSelectedVisualPropertySheet();
        final Set<VisualPropertySheetItem<?>> selectedItems = vpSheet.getSelectedItems();
        for (VisualPropertySheetItem<?> item : selectedItems) {
            if (item.getModel().getVisualMappingFunction() != null)
                mappings.add(item.getModel().getVisualMappingFunction());
        }
    }
    return new TaskIterator(new RemoveVisualMappingsTask(mappings, style, servicesUtil));
}
Also used : VisualMappingFunction(org.cytoscape.view.vizmap.VisualMappingFunction) VisualPropertySheet(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet) VizMapGUI(org.cytoscape.view.vizmap.gui.VizMapGUI) TaskIterator(org.cytoscape.work.TaskIterator) VizMapperMainPanel(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualPropertySheetItem(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem) HashSet(java.util.HashSet)

Example 5 with VizMapperMainPanel

use of org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel in project cytoscape-impl by cytoscape.

the class RemoveSelectedDiscreteValuesAction method updateEnableState.

@Override
public void updateEnableState() {
    boolean enabled = false;
    final VizMapperMainPanel vizMapperMainPanel = getVizMapperMainPanel();
    VisualPropertySheet vpSheet = null;
    if (vizMapperMainPanel != null)
        vpSheet = vizMapperMainPanel.getSelectedVisualPropertySheet();
    if (vpSheet != null) {
        for (final VisualPropertySheetItem<?> vpSheetItem : vpSheet.getSelectedItems()) {
            final VisualPropertySheetItemModel<?> model = vpSheetItem.getModel();
            final PropertySheetTable table = vpSheetItem.getPropSheetPnl().getTable();
            final int[] selected = table.getSelectedRows();
            if (selected != null && model.getVisualMappingFunction() instanceof DiscreteMapping) {
                // Make sure the selected rows have at least one Discrete Mapping entry with non-null value
                for (int i = 0; i < selected.length; i++) {
                    final Item item = (Item) table.getValueAt(selected[i], 0);
                    if (item != null && item.getProperty() instanceof VizMapperProperty) {
                        final VizMapperProperty<?, ?, ?> prop = (VizMapperProperty<?, ?, ?>) item.getProperty();
                        if (prop.getCellType() == CellType.DISCRETE && prop.getValue() != null) {
                            enabled = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    setEnabled(enabled);
}
Also used : VisualPropertySheetItem(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem) Item(com.l2fprod.common.propertysheet.PropertySheetTableModel.Item) VisualPropertySheet(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet) PropertySheetTable(com.l2fprod.common.propertysheet.PropertySheetTable) VizMapperMainPanel(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty)

Aggregations

VizMapperMainPanel (org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel)6 VisualPropertySheet (org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet)5 VisualPropertySheetItem (org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem)5 PropertySheetTable (com.l2fprod.common.propertysheet.PropertySheetTable)4 Item (com.l2fprod.common.propertysheet.PropertySheetTableModel.Item)4 VizMapperProperty (org.cytoscape.view.vizmap.gui.internal.VizMapperProperty)4 DiscreteMapping (org.cytoscape.view.vizmap.mappings.DiscreteMapping)4 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)1 VisualProperty (org.cytoscape.view.model.VisualProperty)1 VisualMappingFunction (org.cytoscape.view.vizmap.VisualMappingFunction)1 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1 VizMapGUI (org.cytoscape.view.vizmap.gui.VizMapGUI)1 ContinuousMappingCellRendererFactory (org.cytoscape.view.vizmap.gui.editor.ContinuousMappingCellRendererFactory)1 EditSelectedDiscreteValuesAction (org.cytoscape.view.vizmap.gui.internal.action.EditSelectedDiscreteValuesAction)1 RemoveSelectedDiscreteValuesAction (org.cytoscape.view.vizmap.gui.internal.action.RemoveSelectedDiscreteValuesAction)1 StartupCommand (org.cytoscape.view.vizmap.gui.internal.controller.StartupCommand)1