All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fge.grappa.debugger.csvtrace.tabs.matches.MatchesTabDisplay Maven / Gradle / Ivy

The newest version!
package com.github.fge.grappa.debugger.csvtrace.tabs.matches;

import com.github.fge.grappa.debugger.javafx.CallGraphTableCell;
import com.github.fge.grappa.debugger.javafx.JavafxDisplay;
import com.github.fge.grappa.debugger.model.db.MatchStatistics;
import com.github.fge.grappa.matchers.MatcherType;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.text.Text;

import java.util.function.Function;

import static com.github.fge.grappa.debugger.javafx.JavafxUtils.setColumnValue;

public class MatchesTabDisplay
    extends JavafxDisplay
{
    /*
     * General stats
     */
    @FXML
    protected Label nrMatches;

    @FXML
    protected Text successRate;

    @FXML
    protected Text topRulePct;

    @FXML
    protected Text topFiveRulePct;

    @FXML
    protected Text topTenRulePct;

    /*
     * Invocation chart
     */
    @FXML
    protected PieChart invocationsChart;

    protected final PieChart.Data failedPie = new PieChart.Data("", 0.0);
    protected final PieChart.Data emptyPie = new PieChart.Data("", 0.0);
    protected final PieChart.Data nonEmptyPie = new PieChart.Data("", 0.0);

    /*
     * Invocation table
     */
    @FXML
    protected TableView matchesTable;

    @FXML
    protected TableColumn ruleName;

    @FXML
    protected TableColumn ruleClass;

    @FXML
    protected TableColumn ruleType;

    @FXML
    protected TableColumn nrCalls;

    @FXML
    protected TableColumn callDetail;

    @FXML
    protected TableColumn
        callGraph;


    @Override
    public void init()
    {
        /*
         * Rules table
         */
        setColumnValue(ruleName, r -> r.getRuleInfo().getName());
        setColumnValue(ruleClass, r -> r.getRuleInfo().getClassName());
        setColumnValue(ruleType, r -> r.getRuleInfo().getType());
        setColumnValue(nrCalls, r -> r.getEmptyMatches() + r.getFailedMatches()
            + r.getNonEmptyMatches());
        //noinspection AutoBoxing
        setColumnValue(callDetail, r -> String.format("%d / %d / %d",
            r.getNonEmptyMatches(), r.getEmptyMatches(), r.getFailedMatches()));
        setColumnValue(callGraph, Function.identity());
        callGraph.setCellFactory(CallGraphTableCell::new);

        final ObservableList list
            = FXCollections.observableArrayList();

        list.addAll(failedPie, emptyPie, nonEmptyPie);

        invocationsChart.setData(list);

        matchesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy