Package org.gephi.graph.api

Examples of org.gephi.graph.api.GraphModel


    public void updateWorld() {
        //System.out.println("update world");
        cacheMarker++;

        GraphModel graphModel = controller.getModel();
        if (graphModel == null) {
            engine.worldUpdated(cacheMarker);
            return;
        }
        if (gm != null && gm != graphModel) {
            reset();
        }
        gm = graphModel;
        HierarchicalGraph graph;
        if (graphModel.isDirected()) {
            undirected = false;
            graph = graphModel.getHierarchicalDirectedGraphVisible();
        } else if (graphModel.isUndirected()) {
            undirected = true;
            graph = graphModel.getHierarchicalUndirectedGraphVisible();
        } else if (graphModel.isMixed()) {
            undirected = false;
            graph = graphModel.getHierarchicalMixedGraphVisible();
        } else {
            undirected = false;
            graph = graphModel.getHierarchicalDirectedGraphVisible();
        }

        if (dynamicModel == null) {
            DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
            dynamicModel = dynamicController.getModel();
View Full Code Here


    }

    public boolean requireUpdate() {
        if (graph == null) {
            //Try to get a graph
            GraphModel graphModel = controller.getModel();
            if (graphModel != null) {
                graph = graphModel.getHierarchicalGraphVisible();
            }
        }
        //Refresh reader if sight changed
        Graph g = graph;
        if (g != null) {
View Full Code Here

        if (container.getSource() != null) {
            pc.setSource(workspace, container.getSource());
        }

        //Architecture
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();

        HierarchicalGraph graph = null;
        switch (container.getEdgeDefault()) {
            case DIRECTED:
                graph = graphModel.getHierarchicalDirectedGraph();
                break;
            case UNDIRECTED:
                graph = graphModel.getHierarchicalUndirectedGraph();
                break;
            case MIXED:
                graph = graphModel.getHierarchicalMixedGraph();
                break;
            default:
                graph = graphModel.getHierarchicalMixedGraph();
                break;
        }
        GraphFactory factory = graphModel.factory();

        //Attributes - Creates columns for properties
        attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
        attributeModel.mergeModel(container.getAttributeModel());
View Full Code Here

    private static final String ELEMENT_TEXTDATA_VISIBLE = "visible";

    public void writeXML(XMLStreamWriter writer, Workspace workspace) {
        try {
            writer.writeStartElement(ELEMENT_TEXTDATA);
            GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
            HierarchicalGraph hierarchicalGraph = graphModel.getHierarchicalGraph();
            for (Node node : hierarchicalGraph.getNodesTree()) {
                TextData nodeTextData = node.getNodeData().getTextData();
                if (nodeTextData != null) {
                    writer.writeStartElement(ELEMENT_NODEDATA_TEXTDATA);
                    writer.writeAttribute("for", String.valueOf(node.getId()));
View Full Code Here

        }
    }

    public void readXML(XMLStreamReader reader, Workspace workspace) {
        try {
            GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
            HierarchicalGraph hierarchicalGraph = graphModel.getHierarchicalGraph();
            boolean end = false;
            while (reader.hasNext() && !end) {
                int type = reader.next();
                switch (type) {
                    case XMLStreamReader.START_ELEMENT:
View Full Code Here

        Workspace currentWorkspace = projectController.getCurrentWorkspace();
        AttributeModel sourceAttributeModel = attributeController.getModel(currentWorkspace);
        AttributeModel destAttributeModel = attributeController.getModel(workspace);
        destAttributeModel.mergeModel(sourceAttributeModel);

        GraphModel sourceModel = graphController.getModel(currentWorkspace);
        GraphModel destModel = graphController.getModel(workspace);
        Graph destGraph = destModel.getHierarchicalGraphVisible();
        Graph sourceGraph = sourceModel.getHierarchicalGraphVisible();

        destModel.pushNodes(sourceGraph, nodes);
    }
View Full Code Here

    private void initEvents() {
        autoMetaEdgeCheckbox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
                boolean sel = autoMetaEdgeCheckbox.isSelected();
                model.settings().putClientProperty(GraphSettings.AUTO_META_EDGES, sel);
                sumRadio.setEnabled(sel);
                avgRadio.setEnabled(sel);
                labelWeight.setEnabled(sel);
            }
        });

        showTreeLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                TopComponent tc = WindowManager.getDefault().findTopComponent("HierarchyTopComponent");
                if (tc != null) {
                    tc.open();
                    tc.requestActive();
                    HierarchyTopComponent hierarchyTopComponent = (HierarchyTopComponent) tc;
                    hierarchyTopComponent.refresh();
                }
            }
        });

        metaEdgeInfoLabel.addMouseListener(new MouseAdapter() {

            RichTooltip richTooltip;

            @Override
            public void mouseEntered(MouseEvent e) {
                String description = NbBundle.getMessage(HierarchyControlPanel.class, "HierarchyControlPanel.info.description");
                String title = NbBundle.getMessage(HierarchyControlPanel.class, "HierarchyControlPanel.info.title");
                richTooltip = new RichTooltip(title, description);
                richTooltip.showTooltip(metaEdgeInfoLabel);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                if (richTooltip != null) {
                    richTooltip.hideTooltip();
                    richTooltip = null;
                }
            }
        });

        metaWeightInfoLabel.addMouseListener(new MouseAdapter() {

            RichTooltip richTooltip;

            @Override
            public void mouseEntered(MouseEvent e) {
                String description = NbBundle.getMessage(HierarchyControlPanel.class, "HierarchyControlPanel.weightinfo.description");
                String title = NbBundle.getMessage(HierarchyControlPanel.class, "HierarchyControlPanel.weightinfo.title");
                richTooltip = new RichTooltip(title, description);
                richTooltip.showTooltip(metaWeightInfoLabel);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                if (richTooltip != null) {
                    richTooltip.hideTooltip();
                    richTooltip = null;
                }
            }
        });

        ActionListener radioListener = new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
                GraphSettings settings = model.settings();
                settings.putClientProperty(GraphSettings.METAEDGE_BUILDER, e.getActionCommand());
            }
        };
        sumRadio.setActionCommand("sum");
        avgRadio.setActionCommand("average");
View Full Code Here

        sumRadio.addActionListener(radioListener);
        avgRadio.addActionListener(radioListener);
    }

    public void setup() {
        GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
        HierarchicalGraph graph = model.getHierarchicalGraphVisible();
        initLevelsLinks(graph);

        //Init status
        GraphSettings settings = model.settings();
        boolean enabled = (Boolean) settings.getClientProperty(GraphSettings.AUTO_META_EDGES);
        autoMetaEdgeCheckbox.setSelected(enabled);

        sumRadio.setEnabled(enabled);
        avgRadio.setEnabled(enabled);
View Full Code Here

            link.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
            final int lvl = i;
            link.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
                    HierarchicalGraph graph = model.getHierarchicalGraphVisible();
                    graph.resetViewToLevel(lvl);
                }
            });
            GridBagConstraints gdc = new GridBagConstraints(0, i, 1, 1, 1, 0, GridBagConstraints.PAGE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 0), 0, 0);
            levelViewPanel.add(link, gdc);
        }

        //Leaves
        JXHyperlink link = new JXHyperlink();
        link.setClickedColor(new java.awt.Color(0, 51, 255));
        link.setText(leavesStr);
        link.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
        link.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
                HierarchicalGraph graph = model.getHierarchicalGraphVisible();
                graph.resetViewToLeaves();
            }
        });
        GridBagConstraints gdc = new GridBagConstraints(0, height + 1, 1, 1, 1, 1, GridBagConstraints.PAGE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 0), 0, 0);
        levelViewPanel.add(link, gdc);
View Full Code Here

            }
        }
    }

    public NodeRanking getDegreeRanking() {
        GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
        Graph graph = model.getGraphVisible();
        NodeRanking degreeRanking = RankingFactory.getNodeDegreeRanking(graph);
        if (degreeRanking.getMinimumValue() != null && degreeRanking.getMaximumValue() != null && !degreeRanking.getMinimumValue().equals(degreeRanking.getMaximumValue())) {
            return degreeRanking;
        }
        return null;
View Full Code Here

TOP

Related Classes of org.gephi.graph.api.GraphModel

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.