Search in sources :

Example 56 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class DefaultTablesNetwork method createNodeTables.

private void createNodeTables(long suidx, CyTableFactory tableFactory, boolean pubTables, int num, SharedTableFacade sharedNodeTable) {
    final CyTable defTable = tableFactory.createTable(suidx + " default node", CyIdentifiable.SUID, Long.class, false, /* all local tables are private*/
    false, InitialTableSize.SMALL);
    networkTableManager.setTable(networkRef.get(), CyNode.class, CyNetwork.LOCAL_ATTRS, defTable);
    LocalTableFacade localTable = new LocalTableFacade(defTable, sharedNodeTable, eventHelper);
    // Set the privacy of facade tables based on the given flag
    localTable.setPublic(pubTables);
    networkTableManager.setTable(networkRef.get(), CyNode.class, CyNetwork.DEFAULT_ATTRS, localTable);
    if (eventHelper instanceof TableEventHelperFacade)
        ((TableEventHelperFacade) eventHelper).registerFacade(localTable);
    final CyTable hiddenTable = tableFactory.createTable(suidx + " hidden node", CyIdentifiable.SUID, Long.class, false, false, InitialTableSize.SMALL);
    networkTableManager.setTable(networkRef.get(), CyNode.class, CyNetwork.HIDDEN_ATTRS, hiddenTable);
    defTable.createColumn(CyNetwork.NAME, String.class, true);
    defTable.createColumn(CyNetwork.SELECTED, Boolean.class, true, Boolean.FALSE);
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 57 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class DefaultTablesNetwork method createEdgeTables.

private void createEdgeTables(long suidx, CyTableFactory tableFactory, boolean pubTables, int num, SharedTableFacade sharedEdgeTable) {
    final CyTable defTable = tableFactory.createTable(suidx + " default edge", CyIdentifiable.SUID, Long.class, false, /* all local tables are private*/
    false, InitialTableSize.SMALL);
    networkTableManager.setTable(networkRef.get(), CyEdge.class, CyNetwork.LOCAL_ATTRS, defTable);
    LocalTableFacade localTable = new LocalTableFacade(defTable, sharedEdgeTable, eventHelper);
    // Set the privacy of facade tables based on the given flag
    localTable.setPublic(pubTables);
    networkTableManager.setTable(networkRef.get(), CyEdge.class, CyNetwork.DEFAULT_ATTRS, localTable);
    if (eventHelper instanceof TableEventHelperFacade)
        ((TableEventHelperFacade) eventHelper).registerFacade(localTable);
    final CyTable hiddenTable = tableFactory.createTable(suidx + " hidden edge", CyIdentifiable.SUID, Long.class, false, false, InitialTableSize.SMALL);
    networkTableManager.setTable(networkRef.get(), CyEdge.class, CyNetwork.HIDDEN_ATTRS, hiddenTable);
    defTable.createColumn(CyNetwork.NAME, String.class, true);
    defTable.createColumn(CyNetwork.SELECTED, Boolean.class, true, Boolean.FALSE);
    defTable.createColumn(CyEdge.INTERACTION, String.class, true);
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 58 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class SharedTableFacade method createListColumn.

public <T> void createListColumn(String columnName, Class<T> listElementType, boolean isImmutable, List<T> defaultValue) {
    checkIfAlreadyExists(columnName);
    logger.debug("adding real List column: '" + columnName + "' to table: " + shared.getTitle());
    shared.createListColumn(columnName, listElementType, isImmutable, defaultValue);
    for (CyTable local : localTables()) {
        logger.debug("adding virtual list column: " + columnName + " to local table: " + local.getTitle());
        local.addVirtualColumn(columnName, columnName, shared, CyIdentifiable.SUID, isImmutable);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 59 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class SharedTableFacade method createColumn.

public <T> void createColumn(String columnName, Class<? extends T> type, boolean isImmutable, T defaultValue) {
    checkIfAlreadyExists(columnName);
    logger.debug("adding real column: '" + columnName + "' to table: " + shared.getTitle());
    shared.createColumn(columnName, type, isImmutable, defaultValue);
    for (CyTable local : localTables()) {
        logger.debug("adding virtual column: " + columnName + " to local table: " + local.getTitle());
        local.addVirtualColumn(columnName, columnName, shared, CyIdentifiable.SUID, isImmutable);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 60 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class TableEventHelperFacade method fireEvent.

@Override
public <E extends CyEvent<?>> void fireEvent(final E event) {
    final CyEventHelper eventHelper = getEventHelper();
    // always propagate the actual event
    eventHelper.fireEvent(event);
    // make sure the source is something we care about
    Object source = event.getSource();
    if (!(source instanceof CyTable))
        return;
    Reference<LocalTableFacade> reference;
    synchronized (lock) {
        reference = facadeMap.get((CyTable) source);
    }
    if (reference == null)
        return;
    LocalTableFacade facade = reference.get();
    if (facade == null)
        return;
    // create a new event for the facade table based on the actual event
    CyEvent<?> facadeEvent = null;
    if (event instanceof TableTitleChangedEvent) {
        TableTitleChangedEvent e = (TableTitleChangedEvent) event;
        facadeEvent = new TableTitleChangedEvent(facade, e.getOldTitle());
    } else if (event instanceof TablePrivacyChangedEvent) {
        facadeEvent = new TablePrivacyChangedEvent(facade);
    } else if (event instanceof ColumnNameChangedEvent) {
        ColumnNameChangedEvent e = (ColumnNameChangedEvent) event;
        facadeEvent = new ColumnNameChangedEvent(facade, e.getOldColumnName(), e.getNewColumnName());
    } else if (event instanceof ColumnDeletedEvent) {
        ColumnDeletedEvent e = (ColumnDeletedEvent) event;
        facadeEvent = new ColumnDeletedEvent(facade, e.getColumnName());
    } else if (event instanceof ColumnCreatedEvent) {
        ColumnCreatedEvent e = (ColumnCreatedEvent) event;
        facadeEvent = new ColumnCreatedEvent(facade, e.getColumnName());
    }
    // fire the new facade event
    if (facadeEvent != null)
        eventHelper.fireEvent(facadeEvent);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) CyTable(org.cytoscape.model.CyTable) TableTitleChangedEvent(org.cytoscape.model.events.TableTitleChangedEvent) ColumnNameChangedEvent(org.cytoscape.model.events.ColumnNameChangedEvent) ColumnDeletedEvent(org.cytoscape.model.events.ColumnDeletedEvent) TablePrivacyChangedEvent(org.cytoscape.model.events.TablePrivacyChangedEvent) ColumnCreatedEvent(org.cytoscape.model.events.ColumnCreatedEvent)

Aggregations

CyTable (org.cytoscape.model.CyTable)282 CyNetwork (org.cytoscape.model.CyNetwork)79 CyRow (org.cytoscape.model.CyRow)73 CyColumn (org.cytoscape.model.CyColumn)71 ArrayList (java.util.ArrayList)55 CyNode (org.cytoscape.model.CyNode)43 CyEdge (org.cytoscape.model.CyEdge)35 Test (org.junit.Test)29 List (java.util.List)26 HashMap (java.util.HashMap)24 CyApplicationManager (org.cytoscape.application.CyApplicationManager)19 HashSet (java.util.HashSet)18 CyIdentifiable (org.cytoscape.model.CyIdentifiable)14 CyNetworkView (org.cytoscape.view.model.CyNetworkView)14 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)13 RowSetRecord (org.cytoscape.model.events.RowSetRecord)11 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)11 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)11 CyEventHelper (org.cytoscape.event.CyEventHelper)10 CyTableManager (org.cytoscape.model.CyTableManager)10