Search in sources :

Example 1 with ListSingleSelection

use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.

the class MapTableToNetworkTablesTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(CyTable globalTable, boolean selectedNetworksOnly, List<CyNetwork> networksList, Class<? extends CyIdentifiable> type) {
    TableType tableType = getTableType(type);
    if (tableType == null)
        throw new IllegalArgumentException("The specified type " + type + " is not acceptable.");
    ListSingleSelection<TableType> tableTypes = new ListSingleSelection<TableType>(tableType);
    tableTypes.setSelectedValue(tableType);
    List<String> networkNames = new ArrayList<String>();
    for (CyNetwork net : networksList) {
        networkNames.add(net.getRow(net).get(CyNetwork.NAME, String.class));
    }
    ListMultipleSelection<String> networksListTunable = new ListMultipleSelection<String>(networkNames);
    networksListTunable.setSelectedValues(networkNames);
    final Map<String, Object> m = new HashMap<String, Object>();
    m.put("dataTypeOptions", tableTypes);
    m.put("selectedNetworksOnly", selectedNetworksOnly);
    m.put("networkList", networksListTunable);
    return tunableSetter.createTaskIterator(createTaskIterator(globalTable), m);
}
Also used : TableType(org.cytoscape.task.internal.table.MapTableToNetworkTablesTask.TableType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) CyNetwork(org.cytoscape.model.CyNetwork) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection)

Example 2 with ListSingleSelection

use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.

the class HelpGenerator method getTypeString.

private String getTypeString(String namespace, String command, String arg) {
    Class<?> clazz = availableCommands.getArgType(namespace, command, arg);
    Object object = availableCommands.getArgValue(namespace, command, arg);
    String keywords = keyword("all") + "|" + keyword("selected") + "|" + keyword("unselected");
    // Special handling for various types
    if (clazz.equals(NodeList.class)) {
        String args = "[" + variable("nodeColumn:value") + "|" + variable("node name") + keyword(",") + "...]|" + keywords;
        return fixedSpan(args);
    } else if (clazz.equals(EdgeList.class)) {
        String args = "[" + variable("edgeColumn:value") + "|" + variable("edge name") + keyword(",") + "...]|" + keywords;
        return fixedSpan(args);
    } else if (clazz.equals(CyNetwork.class)) {
        return fixedSpan(keyword("current") + "|[" + variable("column:value") + "|" + variable("network name") + "]");
    } else if (clazz.equals(CyTable.class)) {
        String args = keyword("Node:") + variable("network name") + "|" + keyword("Edge:") + variable("network name") + "|" + keyword("Network:") + variable("network name") + "|" + variable("table name");
        return fixedSpan(args);
    } else if (clazz.equals(boolean.class) || clazz.equals(Boolean.class)) {
        return fixedSpan(keyword("true") + "|" + keyword("false"));
    } else if (clazz.equals(ListSingleSelection.class)) {
        if (object != null) {
            ListSingleSelection lss = (ListSingleSelection) object;
            String str = "&lt;" + classString(clazz.getSimpleName()) + "&nbsp(";
            List<Object> list = lss.getPossibleValues();
            for (int index = 0; index < list.size() - 1; index++) {
                str += keyword(list.get(index).toString()) + "|";
            }
            if (!list.isEmpty())
                str += keyword(list.get(list.size() - 1).toString());
            str += ")&gt;";
            return fixedSpan(str);
        }
    } else if (clazz.equals(ListMultipleSelection.class)) {
        if (object != null) {
            ListMultipleSelection lss = (ListMultipleSelection) object;
            String str = "&lt;" + classString(clazz.getSimpleName()) + "&nbsp[";
            List<Object> list = lss.getPossibleValues();
            for (int index = 0; index < list.size() - 1; index++) {
                str += keyword(list.get(index).toString()) + ",";
            }
            if (!list.isEmpty())
                str += keyword(list.get(list.size() - 1).toString());
            str += "]&gt;";
            return fixedSpan(str);
        }
    } else if (clazz.equals(BoundedDouble.class) || clazz.equals(BoundedFloat.class) || clazz.equals(BoundedInteger.class) || clazz.equals(BoundedLong.class)) {
        if (object != null)
            return boundedTypeString(clazz, object);
    }
    return fixedSpan("&lt;" + classString(clazz.getSimpleName()) + "&gt;");
}
Also used : CyTable(org.cytoscape.model.CyTable) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection) BoundedInteger(org.cytoscape.work.util.BoundedInteger) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) NodeList(org.cytoscape.command.util.NodeList) List(java.util.List) EdgeList(org.cytoscape.command.util.EdgeList) EdgeList(org.cytoscape.command.util.EdgeList)

Example 3 with ListSingleSelection

use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.

the class CombineReaderAndMappingTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    this.taskMonitor = taskMonitor;
    // Pass the tunable values from this task to the helper task
    final String rootNetName = getRootNetworkList().getSelectedValue();
    final String targetColumn = getTargetColumnList().getSelectedValue();
    final NetworkViewRenderer renderer = getNetworkViewRendererList().getSelectedValue();
    if (rootNetName != null) {
        ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(rootNetName));
        ls.setSelectedValue(rootNetName);
        collectionHelper.setRootNetworkList(ls);
    } else {
        collectionHelper.setRootNetworkList(new ListSingleSelection<>(Collections.emptyList()));
        collectionHelper.setTargetColumnList(new ListSingleSelection<>(Collections.emptyList()));
    }
    if (targetColumn != null) {
        ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(targetColumn));
        ls.setSelectedValue(targetColumn);
        collectionHelper.setTargetColumnList(ls);
    }
    if (renderer != null) {
        ListSingleSelection<NetworkViewRenderer> ls = new ListSingleSelection<>(Collections.singletonList(renderer));
        ls.setSelectedValue(renderer);
        collectionHelper.setNetworkViewRendererList(ls);
    }
    // Run the helper task
    collectionHelper.run(taskMonitor);
    // Run the Import task
    importTask.setNodeMap(collectionHelper.getNodeMap());
    importTask.setRootNetwork(collectionHelper.getRootNetwork());
    importTask.setNetworkViewFactory(collectionHelper.getNetworkViewFactory());
    importTask.run(taskMonitor);
}
Also used : ListSingleSelection(org.cytoscape.work.util.ListSingleSelection) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 4 with ListSingleSelection

use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.

the class LoadMultipleNetworksTask method getTargetColumns.

private final ListSingleSelection<String> getTargetColumns(final CyNetwork network) {
    final CyTable selectedTable = network.getTable(CyNode.class, CyRootNetwork.SHARED_ATTRS);
    final List<String> colNames = new ArrayList<>();
    for (CyColumn col : selectedTable.getColumns()) {
        // Exclude SUID from the mapping key list
        if (!col.getName().equalsIgnoreCase(CyIdentifiable.SUID) && !col.getName().endsWith(".SUID") && (col.getType() == String.class || col.getType() == Integer.class || col.getType() == Long.class))
            colNames.add(col.getName());
    }
    if (colNames.isEmpty() || (colNames.size() == 1 && colNames.contains(CyRootNetwork.SHARED_NAME)))
        return new ListSingleSelection<>();
    sort(colNames);
    return new ListSingleSelection<>(colNames);
}
Also used : CyTable(org.cytoscape.model.CyTable) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection) ArrayList(java.util.ArrayList) CyColumn(org.cytoscape.model.CyColumn)

Example 5 with ListSingleSelection

use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.

the class LayoutSettingsDialog method setNetworkView.

void setNetworkView(final CyNetworkView view) {
    getApplyBtn().setEnabled(view != null);
    if (layoutAttrPnl == null)
        return;
    boolean haveNodeAttribute = (currentLayout.getSupportedNodeAttributeTypes() != null && currentLayout.getSupportedNodeAttributeTypes().size() > 0);
    boolean haveEdgeAttribute = (currentLayout.getSupportedEdgeAttributeTypes() != null && currentLayout.getSupportedEdgeAttributeTypes().size() > 0);
    layoutAttrPnl.removeAll();
    if (currentLayout.getSupportedEdgeAttributeTypes() != null && currentLayout.getSupportedEdgeAttributeTypes().size() > 0)
        layoutEdgeAttrTunable = new LayoutEdgeAttributeTunable();
    else if (currentLayout.getSupportedNodeAttributeTypes() != null && currentLayout.getSupportedNodeAttributeTypes().size() > 0)
        layoutNodeAttrTunable = new LayoutNodeAttributeTunable();
    if (view != null) {
        List<String> attributeList = getAttributeList(view.getModel(), currentLayout.getSupportedNodeAttributeTypes(), currentLayout.getSupportedEdgeAttributeTypes());
        if (attributeList.size() > 0) {
            final PanelTaskManager taskMgr = serviceRegistrar.getService(PanelTaskManager.class);
            JPanel panel = null;
            if (haveEdgeAttribute) {
                layoutEdgeAttrTunable = new LayoutEdgeAttributeTunable();
                layoutEdgeAttrTunable.layoutAttribute = new ListSingleSelection<String>(attributeList);
                layoutEdgeAttrTunable.layoutAttribute.setSelectedValue(attributeList.get(0));
                panel = taskMgr.getConfiguration(null, layoutEdgeAttrTunable);
            } else if (haveNodeAttribute) {
                layoutNodeAttrTunable = new LayoutNodeAttributeTunable();
                layoutNodeAttrTunable.layoutAttribute = new ListSingleSelection<String>(attributeList);
                layoutNodeAttrTunable.layoutAttribute.setSelectedValue(attributeList.get(0));
                panel = taskMgr.getConfiguration(null, layoutNodeAttrTunable);
            }
            setPanelsTransparent(panel);
            layoutAttrPnl.add(panel);
            panel.invalidate();
        }
    }
}
Also used : PanelTaskManager(org.cytoscape.work.swing.PanelTaskManager) JPanel(javax.swing.JPanel) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection)

Aggregations

ListSingleSelection (org.cytoscape.work.util.ListSingleSelection)24 ArrayList (java.util.ArrayList)14 CyTable (org.cytoscape.model.CyTable)8 CyColumn (org.cytoscape.model.CyColumn)7 CyNetwork (org.cytoscape.model.CyNetwork)7 ListMultipleSelection (org.cytoscape.work.util.ListMultipleSelection)6 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)5 HashMap (java.util.HashMap)4 TableType (org.cytoscape.task.internal.table.MapTableToNetworkTablesTask.TableType)3 List (java.util.List)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)2 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)2 HashSet (java.util.HashSet)1 JPanel (javax.swing.JPanel)1 EdgeList (org.cytoscape.command.util.EdgeList)1 NodeList (org.cytoscape.command.util.NodeList)1 NoneAggregator (org.cytoscape.group.internal.data.aggregators.NoneAggregator)1 AbstractCyNetworkReader (org.cytoscape.io.read.AbstractCyNetworkReader)1 CyNetworkReader (org.cytoscape.io.read.CyNetworkReader)1 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)1