Package org.gephi.ranking.api

Examples of org.gephi.ranking.api.Ranking


        return rankingModelImpl;
    }

    public void transform(Transformer transformer) {
        AbstractTransformer abstractTransformer = (AbstractTransformer) transformer;
        Ranking ranking = abstractTransformer.getRanking();

        RankingResultImpl rankingResult = new RankingResultImpl();
        rankingResult.transformer = transformer;
        rankingResult.ranking = ranking;

        Graph graph = Lookup.getDefault().lookup(GraphController.class).getModel().getGraphVisible();
        DynamicModel dynamicModel = rankingModelImpl.getDynamicModel();
        boolean refreshed = RankingFactory.refreshRanking((AbstractRanking) ranking, graph, dynamicModel != null ? dynamicModel.getVisibleInterval() : null);

        if (ranking instanceof NodeRanking) {
            ((AbstractRanking) ranking).setGraph(graph);
            for (Node node : graph.getNodes().toArray()) {
                Object rank = ranking.getValue(node);
                Object result = null;
                if (rank != null) {
                    float normalizedValue = ranking.normalize(rank);
                    if (transformer.isInBounds(normalizedValue)) {
                        result = transformer.transform(node, normalizedValue);
                    }
                }
                rankingResult.addResult(node, rank, result);
            }
        } else {
            ((AbstractRanking) ranking).setGraph(graph);
            for (Edge edge : graph.getEdges().toArray()) {
                Object rank = ranking.getValue(edge);
                Object result = null;
                if (rank != null) {
                    float normalizedValue = ranking.normalize(rank);
                    if (transformer.isInBounds(normalizedValue)) {
                        result = transformer.transform(edge, normalizedValue);
                    }
                }
                rankingResult.addResult(edge, rank, result);
View Full Code Here


        splineButton.setVisible(false);

        if (model != null) {

            //Ranking
            Ranking selectedRanking = refreshCombo();

            if (selectedRanking != null) {
                refreshTransformerPanel(selectedRanking);
            }
        }
View Full Code Here

        if (pce.getPropertyName().equals(RankingUIModel.CURRENT_ELEMENT_TYPE)) {
            refreshModel();
        } else if (pce.getPropertyName().equals(RankingUIModel.CURRENT_RANKING)
                || pce.getPropertyName().equals(RankingUIModel.CURRENT_TRANSFORMER)) {

            final Ranking selectedRanking = model.getCurrentRanking();
            //CenterPanel
            if (centerPanel != null) {
                remove(centerPanel);
            }
            applyButton.setVisible(false);
View Full Code Here

        enableAutoButton.setVisible(true);
    }

    private Ranking refreshCombo() {
        //Ranking
        Ranking selectedRanking = model.getCurrentRanking();
        rankingComboBox.removeItemListener(rankingItemListener);
        final DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
        comboBoxModel.addElement(NO_SELECTION);
        comboBoxModel.setSelectedItem(NO_SELECTION);
        Ranking[] rankings = model.getRankings();
        Arrays.sort(rankings, new Comparator() {

            @Override
            public int compare(Object o1, Object o2) {
                return ((Ranking) o1).getDisplayName().compareTo(((Ranking) o2).getDisplayName());
            }
        });
        for (Ranking r : rankings) {
            comboBoxModel.addElement(r);
            if (selectedRanking != null && selectedRanking.getName().equals(r.getName())) {
                comboBoxModel.setSelectedItem(r);
            }
        }
        selectedRanking = model.getCurrentRanking();    //May have been refresh by the model
        rankingComboBox.addItemListener(rankingItemListener);
View Full Code Here

        rankingUiModelListener = null;
        model = null;
    }

    private void refreshTable() {
        Ranking ranking = model.getCurrentRanking();
        Transformer transformer = model.getCurrentTransformer();

        if (model.isListVisible()) {
            fetchTable(ranking, transformer);
        } else {
View Full Code Here

    public void setCurrentRanking(Ranking ranking) {
        if ((currentRanking.get(currentElementType) == null && ranking == null)
                || (currentRanking.get(currentElementType) != null && currentRanking.get(currentElementType) == ranking)) {
            return;
        }
        Ranking oldValue = currentRanking.get(currentElementType);
        currentRanking.put(currentElementType, ranking);
        firePropertyChangeEvent(CURRENT_RANKING, oldValue, ranking);

        //If selected ranking is dynamic we might want to enable local scale
        setLocalScaleEnabled(shouldLocalScaleEnabled(null));
View Full Code Here

        return listVisible;
    }

    public Ranking[] getRankings(String elmType) {
        Ranking[] rankings = model.getRankings(elmType);
        Ranking current = getCurrentRanking();
        if (current != null) {
            //Update selectedRanking with latest version
            for (Ranking r : rankings) {
                if (r.getName().equals(current.getName())) {
                    currentRanking.put(elmType, r);
                    break;
                }
            }
        }
View Full Code Here

        model.fireRankingListener(new RankingEventImpl(RankingEvent.EventType.START_AUTO_TRANSFORM, model, ranking, transformer));
    }

    @Override
    public void stopAutoTransform(Transformer transformer) {
        Ranking ranking = model.getAutoTransformerRanking(transformer);
        model.removeAutoRanking(transformer);

        //Send Event
        model.fireRankingListener(new RankingEventImpl(RankingEvent.EventType.STOP_AUTO_TRANSFORM, model, ranking, transformer));
    }
View Full Code Here

TOP

Related Classes of org.gephi.ranking.api.Ranking

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.