Package org.gephi.data.attributes.api

Examples of org.gephi.data.attributes.api.AttributeController


*/
@ServiceProvider(service = WorkspaceDuplicateProvider.class, position = 10)
public class AttributeModelDuplicateProvider implements WorkspaceDuplicateProvider {

    public void duplicate(Workspace source, Workspace destination) {
        AttributeController controller = Lookup.getDefault().lookup(AttributeController.class);
        AttributeModel sourceModel = controller.getModel(source);
        AttributeModel destModel = controller.getModel(destination);
        if (sourceModel != null && destModel != null) {
            destModel.mergeModel(sourceModel);
        }
    }
View Full Code Here


    public AttributeColumn[] getNodeTextColumns() {
        return nodeTextColumns;
    }

    public void readXML(XMLStreamReader reader, Workspace workspace) throws XMLStreamException {
        AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);
        AttributeModel attributeModel = attributeController != null ? attributeController.getModel(workspace) : null;
        List<AttributeColumn> nodeCols = new ArrayList<AttributeColumn>();
        List<AttributeColumn> edgeCols = new ArrayList<AttributeColumn>();

        boolean nodeColumn = false;
        boolean edgeColumn = false;
View Full Code Here

    public SearchResult findNext(SearchResult result) {
        return findNext(result.getSearchOptions());
    }

    public boolean canReplace(SearchResult result) {
        AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
        AttributeTable table;
        AttributeColumn column;
        if (result.getFoundNode() != null) {
            table = ac.getModel().getNodeTable();
            column = table.getColumn(result.getFoundColumnIndex());
        } else {
            table = ac.getModel().getEdgeTable();
            column = table.getColumn(result.getFoundColumnIndex());
        }
        return Lookup.getDefault().lookup(AttributeColumnsController.class).canChangeColumnData(column);
    }
View Full Code Here

        }
        if (!canReplace(result)) {
            //Data has changed and the replacement can't be done, continue finding.
            return findNext(result);//Go to next search result
        }
        AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
        Object value;
        String str;
        Attributes attributes;
        AttributeColumn column;

        if (!result.getSearchOptions().isUseRegexReplaceMode()) {
            replacement = Matcher.quoteReplacement(replacement);//Avoid using groups and other regex aspects in the replacement
        }

        try {
            //Get value to re-match and replace:
            if (result.getFoundNode() != null) {
                attributes = result.getFoundNode().getNodeData().getAttributes();
                column = ac.getModel().getNodeTable().getColumn(result.getFoundColumnIndex());
            } else {
                attributes = result.getFoundEdge().getEdgeData().getAttributes();
                column = ac.getModel().getEdgeTable().getColumn(result.getFoundColumnIndex());
            }
            value = attributes.getValue(result.getFoundColumnIndex());
            str = value != null ? value.toString() : "";
            StringBuffer sb = new StringBuffer();
View Full Code Here

                if (evt.getPropertyName().equals("init")) {
                    TextManager.this.model = VizController.getInstance().getVizModel().getTextModel();

                    //Initialize columns if needed
                    if (model.getNodeTextColumns() == null || model.getNodeTextColumns().length == 0) {
                        AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);
                        if (attributeController != null && attributeController.getModel() != null) {
                            AttributeModel attributeModel = attributeController.getModel();
                            AttributeColumn[] nodeCols = new AttributeColumn[]{attributeModel.getNodeTable().getColumn(PropertiesColumn.NODE_LABEL.getIndex())};
                            AttributeColumn[] edgeCols = new AttributeColumn[]{attributeModel.getEdgeTable().getColumn(PropertiesColumn.EDGE_LABEL.getIndex())};
                            model.setTextColumns(nodeCols, edgeCols);
                        }
                    }
View Full Code Here

    /**
     * Setup the mode of column creation: nodes table or edges table.
     * @param mode Mode
     */
    public void setup(Mode mode) {
        AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
        //Set description text for the mode of column creation:
        switch (mode) {
            case NODES_TABLE:
                descriptionLabel.setText(NbBundle.getMessage(AddColumnUI.class, "AddColumnUI.descriptionLabel.text.nodes"));
                table = ac.getModel().getNodeTable();
                break;
            case EDGES_TABLE:
                descriptionLabel.setText(NbBundle.getMessage(AddColumnUI.class, "AddColumnUI.descriptionLabel.text.edges"));
                table = ac.getModel().getEdgeTable();
                break;
        }

        for (AttributeType type : AttributeType.values()) {
            typeComboBox.addItem(type);
View Full Code Here

            return Lookup.getDefault().lookup(GraphElementsController.class).getEdgesCount();
        }
    }

    public boolean isNodeTable(AttributeTable table) {
        AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
        return table == ac.getModel().getNodeTable();
    }
View Full Code Here

        AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
        return table == ac.getModel().getNodeTable();
    }

    public boolean isEdgeTable(AttributeTable table) {
        AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
        return table == ac.getModel().getEdgeTable();
    }
View Full Code Here

        this.textModel = model;
        refresh();
    }

    private void refresh() {
        AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);

        List<AttributeColumn> availableColumns = new ArrayList<AttributeColumn>();
        List<AttributeColumn> selectedColumns = new ArrayList<AttributeColumn>();
        AttributesCheckBox[] target;
        if (elementButtonGroup.getSelection() == nodesToggleButton.getModel()) {
            for (AttributeColumn c : attributeController.getModel().getNodeTable().getColumns()) {
                if (showProperties || c.getOrigin().equals(AttributeOrigin.DATA)) {
                    availableColumns.add(c);
                }
            }

            if (textModel.getNodeTextColumns() != null) {
                selectedColumns = Arrays.asList(textModel.getNodeTextColumns());
            }
            nodeCheckBoxs = new AttributesCheckBox[availableColumns.size()];
            target = nodeCheckBoxs;
        } else {
            for (AttributeColumn c : attributeController.getModel().getEdgeTable().getColumns()) {
                if (showProperties || c.getOrigin().equals(AttributeOrigin.DATA)) {
                    availableColumns.add(c);
                }
            }
View Full Code Here

        }
    }

    public void selectTable(AttributeTable table) {
        if (listener != null) {
            AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
            if (ac.getModel().getNodeTable() == table) {
                selectNodesTable();
            } else {
                selectEdgesTable();
            }
        }
View Full Code Here

TOP

Related Classes of org.gephi.data.attributes.api.AttributeController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.