List of usage examples for javax.swing.table DefaultTableCellRenderer setBackground
public void setBackground(Color c)
JComponent.setBackground
to assign the unselected-background color to the specified color. 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 *///w ww .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.// www .j a v a2 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.prom5.analysis.performance.PerformanceAnalysisGUI.java
/** * Calculates and displays values of 'time in between' metrics of two * transitions.//from w ww. j a v a 2s . co 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.prom5.analysis.performance.PerformanceAnalysisGUI.java
/** * Calculates metrics related to activities, such as waiting time, execution * time and throughput time. and displays these on the metricsBottomPanel, * * @param activity ExtendedActivity: the activity involved *///from w ww .ja v a 2 s. c o m 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(); } }