Example usage for javax.swing.table DefaultTableCellRenderer DefaultTableCellRenderer

List of usage examples for javax.swing.table DefaultTableCellRenderer DefaultTableCellRenderer

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableCellRenderer DefaultTableCellRenderer.

Prototype

public DefaultTableCellRenderer() 

Source Link

Document

Creates a default table cell renderer.

Usage

From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java

private TableCellRenderer getCellRenderer(final SwingTreeCol col) {

    return new DefaultTableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {

            ColumnType colType = col.getColumnType();
            if (colType == ColumnType.DYNAMIC) {
                colType = ColumnType.valueOf(extractDynamicColType(elements.toArray()[row], column));
            }// w w w  .j a v a2s  . c om

            final XulTreeCell cell = getRootChildren().getItem(row).getRow().getCell(column);
            switch (colType) {
            case CHECKBOX:
                JCheckBox checkbox = new JCheckBox();
                if (value instanceof String) {
                    checkbox.setSelected(((String) value).equalsIgnoreCase("true")); //$NON-NLS-1$
                } else if (value instanceof Boolean) {
                    checkbox.setSelected((Boolean) value);
                } else if (value == null) {
                    checkbox.setSelected(false);
                }
                if (isSelected) {
                    checkbox.setBackground(Color.LIGHT_GRAY);
                }
                checkbox.setEnabled(!cell.isDisabled());
                return checkbox;
            case COMBOBOX:
            case EDITABLECOMBOBOX:
                Vector data;

                final JComboBox comboBox = new JComboBox();
                if (cell == null) {
                } else {
                    data = (cell.getValue() != null) ? (Vector) cell.getValue() : new Vector();

                    if (data == null) {
                        logger.debug("SwingTreeCell combobox data is null, passed in value: " + value); //$NON-NLS-1$
                        if (value instanceof Vector) {
                            data = (Vector) value;
                        }
                    }
                    if (data != null) {
                        comboBox.setModel(new DefaultComboBoxModel(data));
                        try {
                            comboBox.setSelectedIndex(cell.getSelectedIndex());
                        } catch (Exception e) {
                            logger.error("error setting selected index on the combobox editor"); //$NON-NLS-1$
                        }
                    }
                }

                if (colType == ColumnType.EDITABLECOMBOBOX) {
                    comboBox.setEditable(true);
                    ((JTextComponent) comboBox.getEditor().getEditorComponent()).setText(cell.getLabel());
                }

                if (isSelected) {
                    comboBox.setBackground(Color.LIGHT_GRAY);
                }
                comboBox.setEnabled(!cell.isDisabled());
                return comboBox;
            case CUSTOM:
                return new CustomCellEditorWrapper(cell, customEditors.get(col.getType()));
            default:
                JLabel label = new JLabel((String) value);

                if (isSelected) {
                    label.setOpaque(true);
                    label.setBackground(Color.LIGHT_GRAY);
                }
                return label;
            }

        }
    };

}

From source file:org.processmining.analysis.performance.dottedchart.ui.MetricsPanel.java

/**
 * Displays the performance metrics of each pattern on the east side of the
 * plug-in window./*from  w  ww  . j  av  a  2s .c o  m*/
 * 
 * @param sortedArray
 *            int[]
 */

public void displayPerformanceMetrics() {
    String type = dcPanel.getTimeOption();
    ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics();
    ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles();

    ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList();

    this.removeAll();
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // add time option menu
    this.add(Box.createRigidArea(new Dimension(5, 10)));
    JPanel menuPanel = new JPanel(new BorderLayout());
    menuPanel.setPreferredSize(new Dimension(160, 45));
    menuPanel.setMaximumSize(new Dimension(180, 45));
    timeSortLabel.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(timeSortLabel, BorderLayout.NORTH);
    timeBox.setMaximumSize(new Dimension(160, 20));
    timeBox.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    menuPanel.add(timeBox, BorderLayout.CENTER);
    this.add(menuPanel);
    this.add(Box.createRigidArea(new Dimension(5, 10)));

    // for each frequency get the set of patterns that have that frequency
    // (run from high frequency to low)
    int size = 0;
    for (int i = 0; i < aList.size(); i++) {
        try {
            String key;
            DescriptiveStatistics currentDS = null;
            if (i != 0)
                key = sortedTitleList.get(i - 1);
            else {
                key = aTitles.get(0);
                currentDS = aList.get(i);
            }

            if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST)
                    && !dcModel.getInstanceTypeToKeep().contains(key))
                continue;
            size++;

            if (i > 0) {
                for (int j = 1; j < aTitles.size(); j++) {
                    if (aTitles.get(j).equals(key))
                        currentDS = aList.get(j);
                }
            }
            AbstractTableModel otm;
            // create labels that contains information about the pattern
            if (i == 0)
                otm = new OverallMetricTableModel();
            else
                otm = new OneMetricTableModel();
            DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
            dtcr.setBackground(new Color(235, 235, 235));
            JTable table = new JTable(otm);
            table.setPreferredSize(new Dimension(200, 55));
            table.setMaximumSize(new Dimension(200, 55));
            table.getColumnModel().getColumn(0).setPreferredWidth(70);
            table.getColumnModel().getColumn(0).setMaxWidth(100);
            table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12));
            table.getColumnModel().getColumn(0).setCellRenderer(dtcr);
            table.setBorder(BorderFactory.createEtchedBorder());

            // place throughput times in table
            if (type.equals(DottedChartPanel.TIME_ACTUAL)) {
                if (i == 0) {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0,
                            1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1,
                            1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) {
                if (i == 0) {
                    table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) {
                if (i == 0) {
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_LOGICAL)
                    || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) {
                if (i == 0) {
                    table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1);
                    table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1);
                } else {
                    table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1);
                    table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1);
            }

            JPanel tempPanel = new JPanel(new BorderLayout());
            table.setAlignmentX(CENTER_ALIGNMENT);
            tempPanel.setPreferredSize(new Dimension(160, 98));
            tempPanel.setMaximumSize(new Dimension(180, 98));
            tempPanel.add(table.getTableHeader(), BorderLayout.NORTH);
            tempPanel.add(table, BorderLayout.CENTER);
            JPanel tempPanel2 = new JPanel(new BorderLayout());
            JLabel patternLabel = new JLabel("Component " + key + ":");
            patternLabel.setAlignmentX(LEFT_ALIGNMENT);

            JLabel frequencyLabel = null;
            if (i == 0)
                frequencyLabel = new JLabel("# of components: " + currentDS.getN());
            else
                frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key));

            frequencyLabel.setAlignmentX(LEFT_ALIGNMENT);
            frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
            tempPanel2.add(patternLabel, BorderLayout.NORTH);
            tempPanel2.add(frequencyLabel, BorderLayout.CENTER);
            tempPanel2.add(tempPanel, BorderLayout.SOUTH);
            this.add(tempPanel2);
            this.add(Box.createRigidArea(new Dimension(5, 10)));
        } catch (NullPointerException ex) {
            // can occur when patternMap does not contain a pattern with
            // this frequency
            size--;
        }
    }
    // make sure the pattern performance information is displayed properly
    this.setPreferredSize(new Dimension(200, 140 * (size + 1)));
    this.revalidate();
    this.repaint();

}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Retrieves the values of process-related metrics, based on the process
 * instances in piList and displays these on the UI.
 * //from w w  w  .j  a  v a  2  s  . c om
 * @param piList
 *            ArrayList: Process instances
 */
private void displayProcessMetrics(ArrayList piList) {
    try {
        // calculate the process metrics, based on the selected instances,
        // using the advancedSettings on how to deal with fitting.
        replayResult.calculateMetrics(piList, advancedSettings[0]);
        // initialize the processTable
        OneMetricTableModel ptm = new OneMetricTableModel();
        ptm.setHeadings("", "Throughput time (" + timeSort + ")");
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
        dtcr.setBackground(new Color(235, 235, 235));
        processTable.setModel(ptm);
        processTable.setPreferredSize(new Dimension(240, 112));
        processTable.getColumnModel().getColumn(0).setPreferredWidth(50);
        processTable.getColumnModel().getColumn(0).setMaxWidth(150);
        processTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        processTable.getColumnModel().getColumn(0).setCellRenderer(dtcr);
        processTable.setBorder(BorderFactory.createEtchedBorder());
        // initialize labels
        arrivalProcessLabel.setText("Arrival rate:");
        rateProcessLabel.setText(formatString(replayResult.getArrivalRate() * timeDivider, decimalPlaces)
                + " cases per " + timeSort.substring(0, timeSort.length() - 1));
        casesProcessLabel.setText(piList.size() + " cases");
        completedLabel.setText(replayResult.getProperFrequency() + " cases");

        // fill the first column of the process table
        processTable.setValueAt("avg", 0, 0);
        processTable.setValueAt("min", 1, 0);
        processTable.setValueAt("max", 2, 0);
        processTable.setValueAt("stdev", 3, 0);
        DecimalFormat df = new DecimalFormat("0.00");
        int[] sizes = replayResult.getSizes(fastestProcessPercentage, slowestProcessPercentage);
        processTable.setValueAt("fast " + df.format(fastestProcessPercentage) + "% (" + sizes[0] + ")", 4, 0);
        processTable.setValueAt("slow " + df.format(slowestProcessPercentage) + "%(" + sizes[1] + ")", 5, 0);
        processTable.setValueAt("normal " + df.format(100 - fastestProcessPercentage - slowestProcessPercentage)
                + "%(" + sizes[2] + ")", 6, 0);

        // place calculated values in the table
        processTable.setValueAt(formatString(replayResult.getMeanThroughputTime() / timeDivider, decimalPlaces),
                0, 1);
        processTable.setValueAt(
                formatString((replayResult.getMinThroughputTime() * 1.0) / timeDivider, decimalPlaces), 1, 1);
        processTable.setValueAt(
                formatString((replayResult.getMaxThroughputTime() * 1.0) / timeDivider, decimalPlaces), 2, 1);
        processTable.setValueAt(
                formatString(replayResult.getStdevThroughputTime() / timeDivider, decimalPlaces), 3, 1);
        double[] avgTimes = replayResult.getAverageTimes(fastestProcessPercentage, slowestProcessPercentage);
        processTable.setValueAt(formatString(avgTimes[0] / timeDivider, decimalPlaces), 4, 1);
        processTable.setValueAt(formatString(avgTimes[1] / timeDivider, decimalPlaces), 5, 1);
        processTable.setValueAt(formatString(avgTimes[2] / timeDivider, decimalPlaces), 6, 1);
        processTable.revalidate();
    } catch (Exception ex) {
        Message.add("Program exception while calculating process metrics.\n" + ex.toString(), 2);
        ex.printStackTrace();
    }
}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Calculates the metrics belonging to a place and displays the results.
 * /* w  ww.  ja  va 2 s. c  o m*/
 * @param place
 *            ExtendedPlace: the place of which the values of metrics are
 *            calculated.
 */
private void displayPlaceMetrics(ExtendedPlace place) {
    ArrayList instanceIDList = getSelectedInstanceIDs();
    tablePanel.removeAll();
    tablePanel.add(placeTable.getTableHeader(), BorderLayout.PAGE_START);
    tablePanel.add(placeTable, BorderLayout.CENTER);
    try {
        // calculate place metrics
        place.calculateMetrics(instanceIDList, advancedSettings[1], failedInstances);
        // initialize the placeTable
        ThreeMetricsTableModel ptm = new ThreeMetricsTableModel();
        ptm.setHeadings("", "Waiting time (" + timeSort + ")", "Synchronization time (" + timeSort + ")",
                "Sojourn time (" + timeSort + ")");
        placeTable.setModel(ptm);
        placeTable.setBorder(BorderFactory.createEtchedBorder());
        placeTable.setPreferredSize(new Dimension(480, 112));
        placeTable.setMinimumSize(new Dimension(480, 112));
        placeTable.getColumnModel().getColumn(0).setPreferredWidth(60);
        placeTable.getColumnModel().getColumn(0).setMaxWidth(150);
        placeTable.getColumnModel().getColumn(2).setPreferredWidth(100);
        placeTable.setRowSelectionAllowed(false);
        placeTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
        dtcr.setBackground(new Color(235, 235, 235));
        dtcr.setFont(new Font("SansSerif", Font.BOLD, 12));
        placeTable.getColumnModel().getColumn(0).setCellRenderer(dtcr);

        // place time metrics in the table
        placeTable.setValueAt(formatString(place.getMeanWaitingTime() / timeDivider, decimalPlaces), 0, 1);
        placeTable.setValueAt(formatString(place.getMeanSynchronizationTime() / timeDivider, decimalPlaces), 0,
                2);
        placeTable.setValueAt(formatString(place.getMeanSojournTime() / timeDivider, decimalPlaces), 0, 3);
        placeTable.setValueAt(formatString((place.getMinWaitingTime() * 1.0) / timeDivider, decimalPlaces), 1,
                1);
        placeTable.setValueAt(
                formatString((place.getMinSynchronizationTime() * 1.0) / timeDivider, decimalPlaces), 1, 2);
        placeTable.setValueAt(formatString((place.getMinSojournTime() * 1.0) / timeDivider, decimalPlaces), 1,
                3);
        placeTable.setValueAt(formatString((place.getMaxWaitingTime() * 1.0) / timeDivider, decimalPlaces), 2,
                1);
        placeTable.setValueAt(
                formatString((place.getMaxSynchronizationTime() * 1.0) / timeDivider, decimalPlaces), 2, 2);
        placeTable.setValueAt(formatString((place.getMaxSojournTime() * 1.0) / timeDivider, decimalPlaces), 2,
                3);
        placeTable.setValueAt(formatString(place.getStdevWaitingTime() / timeDivider, decimalPlaces), 3, 1);
        placeTable.setValueAt(formatString(place.getStdevSynchronizationTime() / timeDivider, decimalPlaces), 3,
                2);
        placeTable.setValueAt(formatString(place.getStdevSojournTime() / timeDivider, decimalPlaces), 3, 3);
        double[] avgTimes = place.getAvgTimes(fastestPlacePercentage, slowestPlacePercentage);
        placeTable.setValueAt(formatString(avgTimes[0] / timeDivider, decimalPlaces), 4, 1);
        placeTable.setValueAt(formatString(avgTimes[1] / timeDivider, decimalPlaces), 4, 2);
        placeTable.setValueAt(formatString(avgTimes[2] / timeDivider, decimalPlaces), 4, 3);
        placeTable.setValueAt(formatString(avgTimes[3] / timeDivider, decimalPlaces), 5, 1);
        placeTable.setValueAt(formatString(avgTimes[4] / timeDivider, decimalPlaces), 5, 2);
        placeTable.setValueAt(formatString(avgTimes[5] / timeDivider, decimalPlaces), 5, 3);
        placeTable.setValueAt(formatString(avgTimes[6] / timeDivider, decimalPlaces), 6, 1);
        placeTable.setValueAt(formatString(avgTimes[7] / timeDivider, decimalPlaces), 6, 2);
        placeTable.setValueAt(formatString(avgTimes[8] / timeDivider, decimalPlaces), 6, 3);
        DecimalFormat df = new DecimalFormat("0.00");
        int[] sizes = place.getSizes(fastestPlacePercentage, slowestPlacePercentage);
        placeTable.setValueAt("fast " + df.format(fastestPlacePercentage) + "%(" + sizes[0] + ")", 4, 0);
        placeTable.setValueAt("slow " + df.format(slowestPlacePercentage) + "%(" + sizes[1] + ")", 5, 0);
        placeTable.setValueAt("normal " + df.format(100 - fastestPlacePercentage - slowestPlacePercentage)
                + "%(" + sizes[2] + ")", 6, 0);
        titleLabel.setText("Performance information of the selected place:");
        // display frequency of visits
        freqObjectLabel.setText(place.getFrequency() + " visits");
        // display the arrival rate
        ratePlaceLabel.setText(formatString(place.getArrivalRate() * timeDivider, decimalPlaces)
                + " visits per " + timeSort.substring(0, timeSort.length() - 1));
        placeTable.getTableHeader().setVisible(true);
        titleLabel.setVisible(true);
        numberObjectLabel.setVisible(true);
        freqObjectLabel.setVisible(true);
        arrivalPlaceLabel.setVisible(true);
        ratePlaceLabel.setVisible(true);
        changePercentagesButton.setVisible(true);
        changePercentagesButton.setPreferredSize(new Dimension(170, 25));
        exportButton.setVisible(true);
        placeTable.repaint();
        metricsBottomPanel.revalidate();
    } catch (Exception ex) {
        Message.add("An internal error occured while calculating " + "place metrics.\n" + ex.toString(), 2);
        ex.printStackTrace();
    }
}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Calculates and displays values of 'time in between' metrics of two
 * transitions.//w  w  w .jav a 2  s . c  o m
 * 
 * @param lastTransition
 *            ExtendedTransition: one of the two transitions
 * @param otherTransition
 *            ExtendedTransition: one of the two transitions
 */
private void displayTransitionMetrics(ExtendedTransition lastTransition, ExtendedTransition otherTransition) {
    // clear the table Panel
    tablePanel.removeAll();
    // create a transition analysis object
    TransitionAnalysis ta = new TransitionAnalysis(lastTransition, otherTransition);
    try {
        // calculate the time-metrics
        ta.calculateMetrics(getSelectedInstanceIDs(), advancedSettings[2], failedInstances);
        // initialize the transition time-metrics table
        OneMetricTableModel ttm = new OneMetricTableModel();
        ttm.setHeadings("", "Time in between (" + timeSort + ")");
        transitionTable = new JTable(ttm);
        transitionTable.setBorder(BorderFactory.createEtchedBorder());
        transitionTable.setPreferredSize(new Dimension(300, 112));
        transitionTable.setMinimumSize(new Dimension(280, 112));
        transitionTable.getColumnModel().getColumn(0).setPreferredWidth(80);
        transitionTable.getColumnModel().getColumn(0).setMaxWidth(150);
        transitionTable.setRowSelectionAllowed(false);
        transitionTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
        dtcr.setBackground(new Color(235, 235, 235));
        dtcr.setFont(new Font("SansSerif", Font.BOLD, 12));
        transitionTable.getColumnModel().getColumn(0).setCellRenderer(dtcr);
        // add the table to the tablePanel
        tablePanel.add(transitionTable.getTableHeader(), BorderLayout.PAGE_START);
        tablePanel.add(transitionTable, BorderLayout.CENTER);

        // frequency of process instances in which both transitions occur
        freqObjectLabel.setText(ta.getFrequency() + "" + " cases");
        // fill table with 'in-between-times'
        transitionTable.setValueAt(formatString(ta.getMeanTime() / timeDivider, decimalPlaces), 0, 1);
        transitionTable.setValueAt(formatString((ta.getMinTime() * 1.0) / timeDivider, decimalPlaces), 1, 1);
        transitionTable.setValueAt(formatString((ta.getMaxTime() * 1.0) / timeDivider, decimalPlaces), 2, 1);
        transitionTable.setValueAt(formatString(ta.getStdevTimeInBetween() / timeDivider, decimalPlaces), 3, 1);
        // place average of fastest traces in the table
        DecimalFormat df = new DecimalFormat("0.00");
        int[] sizes = ta.getSizes(fastestBetweenPercentage, slowestBetweenPercentage);
        transitionTable.setValueAt("fast " + df.format(fastestBetweenPercentage) + "%(" + sizes[0] + ")", 4, 0);
        transitionTable.setValueAt("slow " + df.format(slowestBetweenPercentage) + "%(" + sizes[1] + ")", 5, 0);
        transitionTable.setValueAt("normal "
                + df.format(100 - fastestBetweenPercentage - slowestBetweenPercentage) + "%(" + sizes[2] + ")",
                6, 0);
        double[] avgTimes = ta.getAverageTimes(fastestBetweenPercentage, slowestBetweenPercentage);
        transitionTable.setValueAt(formatString(avgTimes[0] / timeDivider, decimalPlaces), 4, 1);
        // place average of slowest traces in the table
        transitionTable.setValueAt(formatString(avgTimes[1] / timeDivider, decimalPlaces), 5, 1);
        // place average of other traces in the table
        transitionTable.setValueAt(formatString(avgTimes[2] / timeDivider, decimalPlaces), 6, 1);

        // make metrics visible
        changePercentagesButton.setVisible(true);
        exportButton.setVisible(true);
        titleLabel.setVisible(true);
        titleLabel.setText("Performance information of the selected transitions:");
        numberObjectLabel.setVisible(true);
        freqObjectLabel.setVisible(true);
        transitionTable.repaint();
        metricsBottomPanel.revalidate();
    } catch (Exception ex) {
        Message.add(
                "An internal error occured while calculating" + " time in between metrics.\n" + ex.toString(),
                2);
        ex.printStackTrace();
    }
}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Calculates metrics related to activities, such as waiting time, execution
 * time and throughput time. and displays these on the metricsBottomPanel,
 * //  ww  w  .  j  a v  a 2s . c  o  m
 * @param activity
 *            ExtendedActivity: the activity involved
 */
private void displayActivityMetrics(ExtendedActivity activity) {
    tablePanel.removeAll();
    try {
        // calculate time-metrics of the activity based on the selected
        // instances
        activity.calculateMetrics(getSelectedInstanceIDs(), advancedSettings[3], failedInstances);
        activity.checkWhichMetricsToUse();
        // initialize the activityTable
        ThreeMetricsRowExtraTableModel atm = new ThreeMetricsRowExtraTableModel();
        atm.setHeadings("", "Waiting time (" + timeSort + ")", "Execution" + " time (" + timeSort + ")",
                "Sojourn time (" + timeSort + ")");
        activityTable.setModel(atm);
        activityTable.setBorder(BorderFactory.createEtchedBorder());
        activityTable.setPreferredSize(new Dimension(480, 128));
        activityTable.setMinimumSize(new Dimension(480, 128));
        activityTable.getColumnModel().getColumn(0).setPreferredWidth(60);
        activityTable.getColumnModel().getColumn(0).setMaxWidth(150);
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
        dtcr.setBackground(new Color(235, 235, 235));
        activityTable.getColumnModel().getColumn(0).setCellRenderer(dtcr);
        activityTable.setRowSelectionAllowed(false);
        activityTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));

        /*
         * Iterator entries = mapping.entrySet().iterator(); while
         * (entries.hasNext()) { Map.Entry entr = (Map.Entry)
         * entries.next(); if (entr.getKey() instanceof ExtendedTransition)
         * { ExtendedTransition transition = (ExtendedTransition)
         * entr.getKey(); ExtendedActivity act =
         * transition.getAssociatedActivity(); if (act != null) {
         * act.calculateMetrics(getSelectedInstanceIDs(),
         * advancedSettings[3], failedInstances);
         * act.checkWhichMetricsToUse(); act.getArrivalRate(); } } }
         */
        // fill table with the calculated activity time-metrics
        TableCellRenderer renderer = new CustomTableCellRenderer(activity.getBoundWaitingUsed(),
                activity.getBoundExecutionUsed(), activity.getBoundSojournUsed());
        activityTable.setDefaultRenderer(Class.forName("java.lang.String"), renderer);
        activityTable.setValueAt(formatString(activity.getMeanWaitTime() / timeDivider, decimalPlaces), 0, 1);
        activityTable.setValueAt(formatString(activity.getMeanExecutionTime() / timeDivider, decimalPlaces), 0,
                2);
        activityTable.setValueAt(formatString(activity.getMeanSojournTime() / timeDivider, decimalPlaces), 0,
                3);
        activityTable.setValueAt(formatString(activity.getMinWaitTime() / timeDivider, decimalPlaces), 1, 1);
        activityTable.setValueAt(formatString(activity.getMinExecutionTime() / timeDivider, decimalPlaces), 1,
                2);
        activityTable.setValueAt(formatString(activity.getMinSojournTime() / timeDivider, decimalPlaces), 1, 3);
        activityTable.setValueAt(formatString(activity.getMaxWaitTime() / timeDivider, decimalPlaces), 2, 1);
        activityTable.setValueAt(formatString(activity.getMaxExecutionTime() / timeDivider, decimalPlaces), 2,
                2);
        activityTable.setValueAt(formatString(activity.getMaxSojournTime() / timeDivider, decimalPlaces), 2, 3);
        activityTable.setValueAt(formatString(activity.getStdevWaitTime() / timeDivider, decimalPlaces), 3, 1);
        activityTable.setValueAt(formatString(activity.getStdevExecutionTime() / timeDivider, decimalPlaces), 3,
                2);
        activityTable.setValueAt(formatString(activity.getStdevSojournTime() / timeDivider, decimalPlaces), 3,
                3);
        double[] avgWaitTimes = activity.getAvgWaitTimes(fastestActivityPercentage, slowestActivityPercentage);
        double[] avgExecutionTimes = activity.getAvgExecutionTimes(fastestActivityPercentage,
                slowestActivityPercentage);
        double[] avgThroughputTimes = activity.getAvgSojournTimes(fastestActivityPercentage,
                slowestActivityPercentage);
        activityTable.setValueAt(formatString(avgWaitTimes[0] / timeDivider, decimalPlaces), 4, 1);
        activityTable.setValueAt(formatString(avgExecutionTimes[0] / timeDivider, decimalPlaces), 4, 2);
        activityTable.setValueAt(formatString(avgThroughputTimes[0] / timeDivider, decimalPlaces), 4, 3);
        activityTable.setValueAt(formatString(avgWaitTimes[1] / timeDivider, decimalPlaces), 5, 1);
        activityTable.setValueAt(formatString(avgExecutionTimes[1] / timeDivider, decimalPlaces), 5, 2);
        activityTable.setValueAt(formatString(avgThroughputTimes[1] / timeDivider, decimalPlaces), 5, 3);
        activityTable.setValueAt(formatString(avgWaitTimes[2] / timeDivider, decimalPlaces), 6, 1);
        activityTable.setValueAt(formatString(avgExecutionTimes[2] / timeDivider, decimalPlaces), 6, 2);
        activityTable.setValueAt(formatString(avgThroughputTimes[2] / timeDivider, decimalPlaces), 6, 3);
        activityTable.setValueAt(activity.getFrequencyWait() + "", 7, 1);
        activityTable.setValueAt(activity.getFrequencyExecution() + "", 7, 2);
        activityTable.setValueAt(activity.getFrequencySojourn() + "", 7, 3);

        DecimalFormat df = new DecimalFormat("0.00");
        activityTable.setValueAt("fast " + df.format(fastestActivityPercentage) + "%", 4, 0);
        activityTable.setValueAt("slow " + df.format(slowestActivityPercentage) + "%", 5, 0);
        activityTable.setValueAt(
                "normal " + df.format(100 - fastestActivityPercentage - slowestActivityPercentage) + "%", 6, 0);
        ratePlaceLabel.setText(formatString(activity.getArrivalRate() * timeDivider, decimalPlaces)
                + " visits per " + timeSort.substring(0, timeSort.length() - 1));
        // add the table to the tablePanel
        tablePanel.add(activityTable.getTableHeader(), BorderLayout.PAGE_START);
        tablePanel.add(activityTable, BorderLayout.CENTER);
        // display the title
        titleLabel.setText("Performance information of activity " + activity.getName() + ":");
        titleLabel.setVisible(true);
        arrivalPlaceLabel.setVisible(true);
        ratePlaceLabel.setVisible(true);
        changePercentagesButton.setVisible(true);
        exportButton.setVisible(true);
        activityTable.repaint();
        metricsBottomPanel.revalidate();
    } catch (Exception ex) {
        Message.add("An internal error occured while calculating " + " activity metrics.\n" + ex.toString(), 2);
        ex.printStackTrace();
    }
}

From source file:org.prom5.analysis.performance.dottedchart.ui.MetricsPanel.java

/**
 * Displays the performance metrics of each pattern on the east side of the
 * plug-in window./*w w w  . ja va2 s.c  o  m*/
 * @param sortedArray int[]
 */

public void displayPerformanceMetrics() {
    String type = dcPanel.getTimeOption();
    ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics();
    ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles();

    ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList();

    this.removeAll();
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    //add time option menu
    this.add(Box.createRigidArea(new Dimension(5, 10)));
    JPanel menuPanel = new JPanel(new BorderLayout());
    menuPanel.setPreferredSize(new Dimension(160, 45));
    menuPanel.setMaximumSize(new Dimension(180, 45));
    timeSortLabel.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(timeSortLabel, BorderLayout.NORTH);
    timeBox.setMaximumSize(new Dimension(160, 20));
    timeBox.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    menuPanel.add(timeBox, BorderLayout.CENTER);
    this.add(menuPanel);
    this.add(Box.createRigidArea(new Dimension(5, 10)));

    //for each frequency get the set of patterns that have that frequency
    //(run from high frequency to low)
    int size = 0;
    for (int i = 0; i < aList.size(); i++) {
        try {
            String key;
            DescriptiveStatistics currentDS = null;
            if (i != 0)
                key = sortedTitleList.get(i - 1);
            else {
                key = aTitles.get(0);
                currentDS = aList.get(i);
            }

            if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST)
                    && !dcModel.getInstanceTypeToKeep().contains(key))
                continue;
            size++;

            if (i > 0) {
                for (int j = 1; j < aTitles.size(); j++) {
                    if (aTitles.get(j).equals(key))
                        currentDS = aList.get(j);
                }
            }
            AbstractTableModel otm;
            //create labels that contains information about the pattern
            if (i == 0)
                otm = new OverallMetricTableModel();
            else
                otm = new OneMetricTableModel();
            DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
            dtcr.setBackground(new Color(235, 235, 235));
            JTable table = new JTable(otm);
            table.setPreferredSize(new Dimension(200, 55));
            table.setMaximumSize(new Dimension(200, 55));
            table.getColumnModel().getColumn(0).setPreferredWidth(70);
            table.getColumnModel().getColumn(0).setMaxWidth(100);
            table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12));
            table.getColumnModel().getColumn(0).setCellRenderer(dtcr);
            table.setBorder(BorderFactory.createEtchedBorder());

            //place throughput times in table
            if (type.equals(DottedChartPanel.TIME_ACTUAL)) {
                if (i == 0) {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0,
                            1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1,
                            1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) {
                if (i == 0) {
                    table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) {
                if (i == 0) {
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_LOGICAL)
                    || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) {
                if (i == 0) {
                    table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1);
                    table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1);
                } else {
                    table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1);
                    table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1);
            }

            JPanel tempPanel = new JPanel(new BorderLayout());
            table.setAlignmentX(CENTER_ALIGNMENT);
            tempPanel.setPreferredSize(new Dimension(160, 98));
            tempPanel.setMaximumSize(new Dimension(180, 98));
            tempPanel.add(table.getTableHeader(), BorderLayout.NORTH);
            tempPanel.add(table, BorderLayout.CENTER);
            JPanel tempPanel2 = new JPanel(new BorderLayout());
            JLabel patternLabel = new JLabel("Component " + key + ":");
            patternLabel.setAlignmentX(LEFT_ALIGNMENT);

            JLabel frequencyLabel = null;
            if (i == 0)
                frequencyLabel = new JLabel("# of components: " + currentDS.getN());
            else
                frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key));

            frequencyLabel.setAlignmentX(LEFT_ALIGNMENT);
            frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
            tempPanel2.add(patternLabel, BorderLayout.NORTH);
            tempPanel2.add(frequencyLabel, BorderLayout.CENTER);
            tempPanel2.add(tempPanel, BorderLayout.SOUTH);
            this.add(tempPanel2);
            this.add(Box.createRigidArea(new Dimension(5, 10)));
        } catch (NullPointerException ex) {
            //can occur when patternMap does not contain a pattern with this frequency
            size--;
        }
    }
    //make sure the pattern performance information is displayed properly
    this.setPreferredSize(new Dimension(200, 140 * (size + 1)));
    this.revalidate();
    this.repaint();

}

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Retrieves the values of process-related metrics, based on the process
 * instances in piList and displays these on the UI.
 * @param piList ArrayList: Process instances
 *//* ww w.  ja va 2  s  .co m*/
private void displayProcessMetrics(ArrayList piList) {
    try {
        //calculate the process metrics, based on the selected instances,
        //using the advancedSettings on how to deal with fitting.
        replayResult.calculateMetrics(piList, advancedSettings[0]);
        //initialize the processTable
        OneMetricTableModel ptm = new OneMetricTableModel();
        ptm.setHeadings("", "Throughput time (" + timeSort + ")");
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
        dtcr.setBackground(new Color(235, 235, 235));
        processTable.setModel(ptm);
        processTable.setPreferredSize(new Dimension(240, 112));
        processTable.getColumnModel().getColumn(0).setPreferredWidth(50);
        processTable.getColumnModel().getColumn(0).setMaxWidth(150);
        processTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        processTable.getColumnModel().getColumn(0).setCellRenderer(dtcr);
        processTable.setBorder(BorderFactory.createEtchedBorder());
        //initialize labels
        arrivalProcessLabel.setText("Arrival rate:");
        rateProcessLabel.setText(formatString(replayResult.getArrivalRate() * timeDivider, decimalPlaces)
                + " cases per " + timeSort.substring(0, timeSort.length() - 1));
        casesProcessLabel.setText(piList.size() + " cases");
        completedLabel.setText(replayResult.getProperFrequency() + " cases");

        //fill the first column of the process table
        processTable.setValueAt("avg", 0, 0);
        processTable.setValueAt("min", 1, 0);
        processTable.setValueAt("max", 2, 0);
        processTable.setValueAt("stdev", 3, 0);
        DecimalFormat df = new DecimalFormat("0.00");
        int[] sizes = replayResult.getSizes(fastestProcessPercentage, slowestProcessPercentage);
        processTable.setValueAt("fast " + df.format(fastestProcessPercentage) + "% (" + sizes[0] + ")", 4, 0);
        processTable.setValueAt("slow " + df.format(slowestProcessPercentage) + "%(" + sizes[1] + ")", 5, 0);
        processTable.setValueAt("normal " + df.format(100 - fastestProcessPercentage - slowestProcessPercentage)
                + "%(" + sizes[2] + ")", 6, 0);

        //place calculated values in the table
        processTable.setValueAt(formatString(replayResult.getMeanThroughputTime() / timeDivider, decimalPlaces),
                0, 1);
        processTable.setValueAt(
                formatString((replayResult.getMinThroughputTime() * 1.0) / timeDivider, decimalPlaces), 1, 1);
        processTable.setValueAt(
                formatString((replayResult.getMaxThroughputTime() * 1.0) / timeDivider, decimalPlaces), 2, 1);
        processTable.setValueAt(
                formatString(replayResult.getStdevThroughputTime() / timeDivider, decimalPlaces), 3, 1);
        double[] avgTimes = replayResult.getAverageTimes(fastestProcessPercentage, slowestProcessPercentage);
        processTable.setValueAt(formatString(avgTimes[0] / timeDivider, decimalPlaces), 4, 1);
        processTable.setValueAt(formatString(avgTimes[1] / timeDivider, decimalPlaces), 5, 1);
        processTable.setValueAt(formatString(avgTimes[2] / timeDivider, decimalPlaces), 6, 1);
        processTable.revalidate();
    } catch (Exception ex) {
        Message.add("Program exception while calculating process metrics.\n" + ex.toString(), 2);
        ex.printStackTrace();
    }
}

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Calculates the metrics belonging to a place and displays the
 * results.// ww  w . j  a  v  a2s.  c o m
 * @param place ExtendedPlace: the place of which the values of metrics are
 * calculated.
 */
private void displayPlaceMetrics(ExtendedPlace place) {
    ArrayList instanceIDList = getSelectedInstanceIDs();
    tablePanel.removeAll();
    tablePanel.add(placeTable.getTableHeader(), BorderLayout.PAGE_START);
    tablePanel.add(placeTable, BorderLayout.CENTER);
    try {
        //calculate place metrics
        place.calculateMetrics(instanceIDList, advancedSettings[1], failedInstances);
        //initialize the placeTable
        ThreeMetricsTableModel ptm = new ThreeMetricsTableModel();
        ptm.setHeadings("", "Waiting time (" + timeSort + ")", "Synchronization time (" + timeSort + ")",
                "Sojourn time (" + timeSort + ")");
        placeTable.setModel(ptm);
        placeTable.setBorder(BorderFactory.createEtchedBorder());
        placeTable.setPreferredSize(new Dimension(480, 112));
        placeTable.setMinimumSize(new Dimension(480, 112));
        placeTable.getColumnModel().getColumn(0).setPreferredWidth(60);
        placeTable.getColumnModel().getColumn(0).setMaxWidth(150);
        placeTable.getColumnModel().getColumn(2).setPreferredWidth(100);
        placeTable.setRowSelectionAllowed(false);
        placeTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
        dtcr.setBackground(new Color(235, 235, 235));
        dtcr.setFont(new Font("SansSerif", Font.BOLD, 12));
        placeTable.getColumnModel().getColumn(0).setCellRenderer(dtcr);

        //place time metrics in the table
        placeTable.setValueAt(formatString(place.getMeanWaitingTime() / timeDivider, decimalPlaces), 0, 1);
        placeTable.setValueAt(formatString(place.getMeanSynchronizationTime() / timeDivider, decimalPlaces), 0,
                2);
        placeTable.setValueAt(formatString(place.getMeanSojournTime() / timeDivider, decimalPlaces), 0, 3);
        placeTable.setValueAt(formatString((place.getMinWaitingTime() * 1.0) / timeDivider, decimalPlaces), 1,
                1);
        placeTable.setValueAt(
                formatString((place.getMinSynchronizationTime() * 1.0) / timeDivider, decimalPlaces), 1, 2);
        placeTable.setValueAt(formatString((place.getMinSojournTime() * 1.0) / timeDivider, decimalPlaces), 1,
                3);
        placeTable.setValueAt(formatString((place.getMaxWaitingTime() * 1.0) / timeDivider, decimalPlaces), 2,
                1);
        placeTable.setValueAt(
                formatString((place.getMaxSynchronizationTime() * 1.0) / timeDivider, decimalPlaces), 2, 2);
        placeTable.setValueAt(formatString((place.getMaxSojournTime() * 1.0) / timeDivider, decimalPlaces), 2,
                3);
        placeTable.setValueAt(formatString(place.getStdevWaitingTime() / timeDivider, decimalPlaces), 3, 1);
        placeTable.setValueAt(formatString(place.getStdevSynchronizationTime() / timeDivider, decimalPlaces), 3,
                2);
        placeTable.setValueAt(formatString(place.getStdevSojournTime() / timeDivider, decimalPlaces), 3, 3);
        double[] avgTimes = place.getAvgTimes(fastestPlacePercentage, slowestPlacePercentage);
        placeTable.setValueAt(formatString(avgTimes[0] / timeDivider, decimalPlaces), 4, 1);
        placeTable.setValueAt(formatString(avgTimes[1] / timeDivider, decimalPlaces), 4, 2);
        placeTable.setValueAt(formatString(avgTimes[2] / timeDivider, decimalPlaces), 4, 3);
        placeTable.setValueAt(formatString(avgTimes[3] / timeDivider, decimalPlaces), 5, 1);
        placeTable.setValueAt(formatString(avgTimes[4] / timeDivider, decimalPlaces), 5, 2);
        placeTable.setValueAt(formatString(avgTimes[5] / timeDivider, decimalPlaces), 5, 3);
        placeTable.setValueAt(formatString(avgTimes[6] / timeDivider, decimalPlaces), 6, 1);
        placeTable.setValueAt(formatString(avgTimes[7] / timeDivider, decimalPlaces), 6, 2);
        placeTable.setValueAt(formatString(avgTimes[8] / timeDivider, decimalPlaces), 6, 3);
        DecimalFormat df = new DecimalFormat("0.00");
        int[] sizes = place.getSizes(fastestPlacePercentage, slowestPlacePercentage);
        placeTable.setValueAt("fast " + df.format(fastestPlacePercentage) + "%(" + sizes[0] + ")", 4, 0);
        placeTable.setValueAt("slow " + df.format(slowestPlacePercentage) + "%(" + sizes[1] + ")", 5, 0);
        placeTable.setValueAt("normal " + df.format(100 - fastestPlacePercentage - slowestPlacePercentage)
                + "%(" + sizes[2] + ")", 6, 0);
        titleLabel.setText("Performance information of the selected place:");
        //display frequency of visits
        freqObjectLabel.setText(place.getFrequency() + " visits");
        //display the arrival rate
        ratePlaceLabel.setText(formatString(place.getArrivalRate() * timeDivider, decimalPlaces)
                + " visits per " + timeSort.substring(0, timeSort.length() - 1));
        placeTable.getTableHeader().setVisible(true);
        titleLabel.setVisible(true);
        numberObjectLabel.setVisible(true);
        freqObjectLabel.setVisible(true);
        arrivalPlaceLabel.setVisible(true);
        ratePlaceLabel.setVisible(true);
        changePercentagesButton.setVisible(true);
        changePercentagesButton.setPreferredSize(new Dimension(170, 25));
        exportButton.setVisible(true);
        placeTable.repaint();
        metricsBottomPanel.revalidate();
    } catch (Exception ex) {
        Message.add("An internal error occured while calculating " + "place metrics.\n" + ex.toString(), 2);
        ex.printStackTrace();
    }
}

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Calculates and displays values of 'time in between' metrics of two
 * transitions./*from  w w  w.java2s  .c  o  m*/
 * @param lastTransition ExtendedTransition: one of the two transitions
 * @param otherTransition ExtendedTransition: one of the two transitions
 */
private void displayTransitionMetrics(ExtendedTransition lastTransition, ExtendedTransition otherTransition) {
    //clear the table Panel
    tablePanel.removeAll();
    //create a transition analysis object
    TransitionAnalysis ta = new TransitionAnalysis(lastTransition, otherTransition);
    try {
        //calculate the time-metrics
        ta.calculateMetrics(getSelectedInstanceIDs(), advancedSettings[2], failedInstances);
        //initialize the transition time-metrics table
        OneMetricTableModel ttm = new OneMetricTableModel();
        ttm.setHeadings("", "Time in between (" + timeSort + ")");
        transitionTable = new JTable(ttm);
        transitionTable.setBorder(BorderFactory.createEtchedBorder());
        transitionTable.setPreferredSize(new Dimension(300, 112));
        transitionTable.setMinimumSize(new Dimension(280, 112));
        transitionTable.getColumnModel().getColumn(0).setPreferredWidth(80);
        transitionTable.getColumnModel().getColumn(0).setMaxWidth(150);
        transitionTable.setRowSelectionAllowed(false);
        transitionTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
        dtcr.setBackground(new Color(235, 235, 235));
        dtcr.setFont(new Font("SansSerif", Font.BOLD, 12));
        transitionTable.getColumnModel().getColumn(0).setCellRenderer(dtcr);
        //add the table to the tablePanel
        tablePanel.add(transitionTable.getTableHeader(), BorderLayout.PAGE_START);
        tablePanel.add(transitionTable, BorderLayout.CENTER);

        //frequency of process instances in which both transitions occur
        freqObjectLabel.setText(ta.getFrequency() + "" + " cases");
        //fill table with 'in-between-times'
        transitionTable.setValueAt(formatString(ta.getMeanTime() / timeDivider, decimalPlaces), 0, 1);
        transitionTable.setValueAt(formatString((ta.getMinTime() * 1.0) / timeDivider, decimalPlaces), 1, 1);
        transitionTable.setValueAt(formatString((ta.getMaxTime() * 1.0) / timeDivider, decimalPlaces), 2, 1);
        transitionTable.setValueAt(formatString(ta.getStdevTimeInBetween() / timeDivider, decimalPlaces), 3, 1);
        //place average of fastest traces in the table
        DecimalFormat df = new DecimalFormat("0.00");
        int[] sizes = ta.getSizes(fastestBetweenPercentage, slowestBetweenPercentage);
        transitionTable.setValueAt("fast " + df.format(fastestBetweenPercentage) + "%(" + sizes[0] + ")", 4, 0);
        transitionTable.setValueAt("slow " + df.format(slowestBetweenPercentage) + "%(" + sizes[1] + ")", 5, 0);
        transitionTable.setValueAt("normal "
                + df.format(100 - fastestBetweenPercentage - slowestBetweenPercentage) + "%(" + sizes[2] + ")",
                6, 0);
        double[] avgTimes = ta.getAverageTimes(fastestBetweenPercentage, slowestBetweenPercentage);
        transitionTable.setValueAt(formatString(avgTimes[0] / timeDivider, decimalPlaces), 4, 1);
        //place average of slowest traces in the table
        transitionTable.setValueAt(formatString(avgTimes[1] / timeDivider, decimalPlaces), 5, 1);
        //place average of other traces in the table
        transitionTable.setValueAt(formatString(avgTimes[2] / timeDivider, decimalPlaces), 6, 1);

        //make metrics visible
        changePercentagesButton.setVisible(true);
        exportButton.setVisible(true);
        titleLabel.setVisible(true);
        titleLabel.setText("Performance information of the selected transitions:");
        numberObjectLabel.setVisible(true);
        freqObjectLabel.setVisible(true);
        transitionTable.repaint();
        metricsBottomPanel.revalidate();
    } catch (Exception ex) {
        Message.add(
                "An internal error occured while calculating" + " time in between metrics.\n" + ex.toString(),
                2);
        ex.printStackTrace();
    }
}