Search in sources :

Example 21 with Table

use of org.gephi.graph.api.Table in project gephi by gephi.

the class DataTableTopComponent method prepareColumnManipulatorsButtons.

/**
     * Creates the buttons that call the AttributeColumnManipulators.
     */
private void prepareColumnManipulatorsButtons() {
    Table table;
    Column[] columns;
    if (isShowingNodesTable()) {
        table = graphModel.getNodeTable();
    } else {
        table = graphModel.getEdgeTable();
    }
    columns = getTableAvailableColumnsModel(table).getAvailableColumns();
    DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
    AttributeColumnsManipulator[] manipulators = dlh.getAttributeColumnsManipulators();
    JCommandButtonStrip currentButtonGroup = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);
    currentButtonGroup.setDisplayState(CommandButtonDisplayState.BIG);
    Integer lastManipulatorType = null;
    for (AttributeColumnsManipulator acm : manipulators) {
        if (lastManipulatorType == null) {
            lastManipulatorType = acm.getType();
        }
        if (lastManipulatorType != acm.getType()) {
            columnManipulatorsPanel.add(currentButtonGroup);
            currentButtonGroup = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);
            currentButtonGroup.setDisplayState(CommandButtonDisplayState.BIG);
        }
        lastManipulatorType = acm.getType();
        currentButtonGroup.add(prepareJCommandButton(graphModel, table, columns, acm));
    }
    columnManipulatorsPanel.add(currentButtonGroup);
}
Also used : DataLaboratoryHelper(org.gephi.datalab.api.DataLaboratoryHelper) NodesDataTable(org.gephi.desktop.datalab.tables.NodesDataTable) Table(org.gephi.graph.api.Table) EdgesDataTable(org.gephi.desktop.datalab.tables.EdgesDataTable) Column(org.gephi.graph.api.Column) AttributeColumnsManipulator(org.gephi.datalab.spi.columns.AttributeColumnsManipulator) JCommandButtonStrip(org.pushingpixels.flamingo.api.common.JCommandButtonStrip)

Example 22 with Table

use of org.gephi.graph.api.Table in project gephi by gephi.

the class DataTableTopComponent method exportCurrentTable.

@Override
public void exportCurrentTable(ExportMode exportMode) {
    Table table;
    String fileName = prepareTableExportFileName();
    boolean edgesTable;
    if (isShowingNodesTable()) {
        table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable();
        edgesTable = false;
        fileName += " [Nodes]";
    } else {
        table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getEdgeTable();
        edgesTable = true;
        fileName += " [Edges]";
    }
    fileName += ".csv";
    switch(exportMode) {
        case CSV:
            showCSVExportUI(table, edgesTable, fileName);
            break;
    }
}
Also used : NodesDataTable(org.gephi.desktop.datalab.tables.NodesDataTable) Table(org.gephi.graph.api.Table) EdgesDataTable(org.gephi.desktop.datalab.tables.EdgesDataTable) GraphController(org.gephi.graph.api.GraphController)

Example 23 with Table

use of org.gephi.graph.api.Table in project gephi by gephi.

the class DataLaboratoryPersistenceProvider method readDataTablesModel.

private void readDataTablesModel(XMLStreamReader reader, Workspace workspace) throws XMLStreamException {
    GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
    Table nodesTable = graphModel.getNodeTable();
    Table edgesTable = graphModel.getEdgeTable();
    DataTablesModel dataTablesModel = workspace.getLookup().lookup(DataTablesModel.class);
    if (dataTablesModel == null) {
        workspace.add(dataTablesModel = new DataTablesModel(workspace));
    }
    AvailableColumnsModel nodeColumns = dataTablesModel.getNodeAvailableColumnsModel();
    nodeColumns.removeAllColumns();
    AvailableColumnsModel edgeColumns = dataTablesModel.getEdgeAvailableColumnsModel();
    edgeColumns.removeAllColumns();
    boolean end = false;
    while (reader.hasNext() && !end) {
        Integer eventType = reader.next();
        if (eventType.equals(XMLEvent.START_ELEMENT)) {
            String name = reader.getLocalName();
            if (NODE_COLUMN.equalsIgnoreCase(name)) {
                Integer id = Integer.parseInt(reader.getAttributeValue(null, "id"));
                Column column = nodesTable.getColumn(id);
                if (column != null) {
                    nodeColumns.addAvailableColumn(column);
                }
            } else if (EDGE_COLUMN.equalsIgnoreCase(name)) {
                Integer id = Integer.parseInt(reader.getAttributeValue(null, "id"));
                Column column = edgesTable.getColumn(id);
                if (column != null) {
                    edgeColumns.addAvailableColumn(column);
                }
            }
        } else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
            if (AVAILABLE_COLUMNS.equalsIgnoreCase(reader.getLocalName())) {
                end = true;
            }
        }
    }
}
Also used : Table(org.gephi.graph.api.Table) Column(org.gephi.graph.api.Column) GraphModel(org.gephi.graph.api.GraphModel) DataTablesModel(org.gephi.desktop.datalab.DataTablesModel) AvailableColumnsModel(org.gephi.desktop.datalab.AvailableColumnsModel)

Example 24 with Table

use of org.gephi.graph.api.Table in project gephi by gephi.

the class ClusteringCoefficient method initializeAttributeColunms.

private Column initializeAttributeColunms(GraphModel graphModel) {
    if (graphModel == null) {
        return null;
    }
    Table nodeTable = graphModel.getNodeTable();
    Column clusteringCol = nodeTable.getColumn("clustering");
    if (clusteringCol == null) {
        clusteringCol = nodeTable.addColumn("clustering", "Clustering Coefficient", Double.class, new Double(0));
    }
    return clusteringCol;
}
Also used : Table(org.gephi.graph.api.Table) Column(org.gephi.graph.api.Column)

Example 25 with Table

use of org.gephi.graph.api.Table in project gephi by gephi.

the class SearchReplaceUI method showSearchResult.

private void showSearchResult() {
    if (searchResult != null) {
        Table table;
        Object value;
        if (mode == Mode.NODES_TABLE) {
            Node node = searchResult.getFoundNode();
            dataTablesController.setNodeTableSelection(new Node[] { node });
            if (!dataTablesController.isNodeTableMode()) {
                dataTablesController.selectNodesTable();
            }
            table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable();
            value = node.getAttribute(table.getColumn(searchResult.getFoundColumnIndex()));
        } else {
            Edge edge = searchResult.getFoundEdge();
            dataTablesController.setEdgeTableSelection(new Edge[] { edge });
            if (!dataTablesController.isEdgeTableMode()) {
                dataTablesController.selectEdgesTable();
            }
            table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getEdgeTable();
            value = edge.getAttribute(table.getColumn(searchResult.getFoundColumnIndex()));
        }
        TimeFormat timeFormat = table.getGraph().getModel().getTimeFormat();
        DateTimeZone timeZone = table.getGraph().getModel().getTimeZone();
        String columnName;
        if (mode == Mode.NODES_TABLE) {
            columnName = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable().getColumn(searchResult.getFoundColumnIndex()).getTitle();
        } else {
            columnName = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getEdgeTable().getColumn(searchResult.getFoundColumnIndex()).getTitle();
        }
        StringBuilder sb = new StringBuilder();
        sb.append("<html>");
        sb.append(NbBundle.getMessage(SearchReplaceUI.class, "SearchReplaceUI.column", HTMLEscape.stringToHTMLString(columnName)));
        sb.append("<br>");
        if (value != null) {
            String text = AttributeUtils.print(value, timeFormat, timeZone);
            sb.append(HTMLEscape.stringToHTMLString(text.substring(0, searchResult.getStart())));
            sb.append("<font color='blue'>");
            sb.append(HTMLEscape.stringToHTMLString(text.substring(searchResult.getStart(), searchResult.getEnd())));
            sb.append("</font>");
            sb.append(HTMLEscape.stringToHTMLString(text.substring(searchResult.getEnd())));
        } else {
            sb.append("<font color='blue'>null</font>");
        }
        sb.append("</html>");
        resultText.setText(sb.toString());
    } else {
        JOptionPane.showMessageDialog(null, NbBundle.getMessage(SearchReplaceUI.class, "SearchReplaceUI.not.found", searchText.getText()));
        resultText.setText("");
    }
}
Also used : TimeFormat(org.gephi.graph.api.TimeFormat) Table(org.gephi.graph.api.Table) Node(org.gephi.graph.api.Node) Edge(org.gephi.graph.api.Edge) GraphController(org.gephi.graph.api.GraphController) DateTimeZone(org.joda.time.DateTimeZone)

Aggregations

Table (org.gephi.graph.api.Table)28 Column (org.gephi.graph.api.Column)22 Node (org.gephi.graph.api.Node)10 GraphController (org.gephi.graph.api.GraphController)7 Edge (org.gephi.graph.api.Edge)5 GraphElementsController (org.gephi.datalab.api.GraphElementsController)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 EdgesDataTable (org.gephi.desktop.datalab.tables.EdgesDataTable)3 NodesDataTable (org.gephi.desktop.datalab.tables.NodesDataTable)3 TimeFormat (org.gephi.graph.api.TimeFormat)3 TimeRepresentation (org.gephi.graph.api.TimeRepresentation)3 DateTimeZone (org.joda.time.DateTimeZone)3 CsvReader (com.csvreader.CsvReader)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 AttributeColumnsController (org.gephi.datalab.api.AttributeColumnsController)2 SearchResult (org.gephi.datalab.api.SearchReplaceController.SearchResult)2 DataTablesController (org.gephi.datalab.api.datatables.DataTablesController)2