Search in sources :

Example 26 with RowSetRecord

use of org.cytoscape.model.events.RowSetRecord in project cytoscape-impl by cytoscape.

the class ModelMonitor method handleEvent.

@Override
public void handleEvent(RowsSetEvent event) {
    CyTable table = event.getSource();
    synchronized (lock) {
        if (!enabled) {
            return;
        }
        if (network == null || table != network.getDefaultNodeTable() && table != network.getDefaultEdgeTable()) {
            return;
        }
        Map<String, double[]> ranges;
        // We may not be the first writer, so check again.
        if (table == network.getDefaultNodeTable()) {
            ranges = nodeColumnRanges;
        } else if (table == network.getDefaultEdgeTable()) {
            ranges = edgeColumnRanges;
        } else {
            return;
        }
        boolean changed = false;
        for (RowSetRecord record : event.getPayloadCollection()) {
            String name = record.getColumn();
            double[] range = ranges.get(name);
            if (range == null) {
                continue;
            }
            Object value = record.getValue();
            if (value == null) {
                continue;
            }
            CyColumn column = table.getColumn(name);
            Class<?> type = column.getType();
            if (List.class.equals(type) && Number.class.isAssignableFrom(column.getListElementType())) {
                updateRange(range, (List<?>) value);
            } else if (Number.class.isAssignableFrom(type)) {
                updateRange(range, (Number) value);
            }
            changed = true;
        }
        if (changed) {
            updateColumnSliders();
        }
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyColumn(org.cytoscape.model.CyColumn) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

RowSetRecord (org.cytoscape.model.events.RowSetRecord)26 CyTable (org.cytoscape.model.CyTable)11 CyNetwork (org.cytoscape.model.CyNetwork)8 ArrayList (java.util.ArrayList)6 CyRow (org.cytoscape.model.CyRow)6 RowsSetEvent (org.cytoscape.model.events.RowsSetEvent)6 Test (org.junit.Test)6 CyNode (org.cytoscape.model.CyNode)5 CyNetworkView (org.cytoscape.view.model.CyNetworkView)5 CyColumn (org.cytoscape.model.CyColumn)4 CyIdentifiable (org.cytoscape.model.CyIdentifiable)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Equation (org.cytoscape.equations.Equation)3 CyEdge (org.cytoscape.model.CyEdge)3 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)3 ColumnData (org.cytoscape.model.internal.column.ColumnData)3 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)3 List (java.util.List)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)2