Example usage for javax.swing.table DefaultTableCellRenderer setBackground

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

Introduction

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

Prototype

public void setBackground(Color c) 

Source Link

Document

Overrides JComponent.setBackground to assign the unselected-background color to the specified color.

Usage

From source file:Main.java

/**
 * Setups the given table for usage as row-header. This method setups the background color to
 * the same one than the column headers.
 *
 * {@note In a previous version, we were assigning to the row headers the same cell renderer than
 *        the one created by <cite>Swing</cite> for the column headers. But it produced strange
 *        effects when the L&F uses a vertical grandiant instead than a uniform color.}
 *
 * @param  table The table to setup as row headers.
 * @return The renderer which has been assigned to the table.
 *//*from   w  w  w  .ja va 2 s. co m*/
public static TableCellRenderer setupAsRowHeader(final JTable table) {
    final JTableHeader header = table.getTableHeader();
    Color background = header.getBackground();
    Color foreground = header.getForeground();
    if (background == null || background.equals(table.getBackground())) {
        if (!SystemColor.control.equals(background)) {
            background = SystemColor.control;
            foreground = SystemColor.controlText;
        } else {
            final Locale locale = table.getLocale();
            background = UIManager.getColor("Label.background", locale);
            foreground = UIManager.getColor("Label.foreground", locale);
        }
    }
    final DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setBackground(background);
    renderer.setForeground(foreground);
    renderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
    final TableColumn column = table.getColumnModel().getColumn(0);
    column.setCellRenderer(renderer);
    column.setPreferredWidth(60);
    table.setPreferredScrollableViewportSize(table.getPreferredSize());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setCellSelectionEnabled(false);
    return renderer;
}

From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java

private void initCustumComponents() {
    logoLabel = new javax.swing.JLabel();
    icon = new ImageIcon(getCLub());
    logoLabel.setIcon(icon); // NOI18N
    logoLabel.setBounds(this.getWidth() - icon.getIconWidth(), this.getHeight() - icon.getIconHeight(),
            icon.getIconWidth(), icon.getIconHeight());
    LayerdPane.add(logoLabel, JLayeredPane.PALETTE_LAYER);
    clockLabel = new javax.swing.JLabel();
    clockLabel.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N
    clockLabel.setText("");
    clockLabel.setForeground(Color.YELLOW);
    LayerdPane.add(clockLabel, JLayeredPane.PALETTE_LAYER);
    jTable1.setRowSelectionAllowed(false);
    jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "Plaats", "Atleet", "Tijd" }) {
        Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.String.class };
        boolean[] canEdit = new boolean[] { false, false, false };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }/*from  ww  w.  ja va 2  s. co  m*/

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });

    jScrollPane1.getViewport().setBackground(Color.black);
    this.setBackground(Color.black);
    JTableHeader header = jTable1.getTableHeader();
    header.setOpaque(false);
    jPanel1.setBackground(Color.black);
    header.setBackground(Color.black);
    header.setForeground(Color.YELLOW);
    DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer();
    headerRenderer.setBackground(Color.BLACK);

    for (int i = 0; i < jTable1.getModel().getColumnCount(); i++) {
        if (jTable1.getModel().getColumnCount() > 0) {
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer);
        }
    }
    DefaultTableCellRenderer LEFTRenderer = new DefaultTableCellRenderer();
    LEFTRenderer.setHorizontalAlignment(JLabel.LEFT);
    jTable1.getColumnModel().getColumn(0).setCellRenderer(LEFTRenderer);
    ChangeFont(fontSize);
}

From source file:Clavis.Windows.WShedule.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./* www. j a va  2s .  c  o m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jPanelInicial = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new org.jdesktop.swingx.JXTable();
    ;
    jButtonSair = new javax.swing.JButton();
    jXDatePickerInicio = new org.jdesktop.swingx.JXDatePicker();
    jXDatePickerFim = new org.jdesktop.swingx.JXDatePicker();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jButtonImprimir = new javax.swing.JButton();
    jComboBoxEstado = new javax.swing.JComboBox<>();
    jLabel3 = new javax.swing.JLabel();
    jButtonExportar = new javax.swing.JButton();

    setMinimumSize(new java.awt.Dimension(900, 600));
    setSize(new java.awt.Dimension(900, 600));

    jPanelInicial.setBorder(javax.swing.BorderFactory.createCompoundBorder(
            javax.swing.BorderFactory.createLineBorder(painelcor, 4),
            javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));
    jPanelInicial.setMinimumSize(new java.awt.Dimension(900, 500));
    jPanelInicial.setPreferredSize(new java.awt.Dimension(900, 500));

    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder1 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder1.setCornerSize(6);
    dropShadowBorder1.setShadowSize(3);
    dropShadowBorder1.setShowLeftShadow(true);
    jScrollPane1.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder1,
            javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));

    jTable1.setBorder(null);
    if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
                new String[] { lingua.translate("Utilizador"), lingua.translate("Horrio"),
                        lingua.translate("Data"), lingua.translate("Atividade"),
                        lingua.translate("Disciplina") }));
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(250);
        jTable1.getColumnModel().getColumn(1).setMinWidth(90);
        jTable1.getColumnModel().getColumn(2).setMinWidth(90);
        jTable1.getColumnModel().getColumn(3).setMinWidth(150);
        jTable1.getColumnModel().getColumn(4).setMinWidth(150);
    } else {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
                new String[] { lingua.translate("Utilizador"), lingua.translate("Data inicial"),
                        lingua.translate("Data final"), lingua.translate("Atividade") }));
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(250);
        jTable1.getColumnModel().getColumn(1).setMinWidth(90);
        jTable1.getColumnModel().getColumn(2).setMinWidth(90);
        jTable1.getColumnModel().getColumn(3).setMinWidth(150);
    }
    jScrollPane1.setViewportView(jTable1);
    Border border = BorderFactory.createEmptyBorder(5, 5, 0, 0);
    UIManager.put("Table.focusCellHighlightBorder", border);
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(javax.swing.JLabel.CENTER);
    renderer.setFocusable(false);
    javax.swing.JLabel lo = new javax.swing.JLabel();
    lo.setBackground(new Color(100, 100, 100));
    lo.setOpaque(true);
    jScrollPane1.setCorner(javax.swing.JScrollPane.UPPER_TRAILING_CORNER, lo);
    jTable1.setRowHeight(30);
    jTable1.setEditable(false);
    jTable1.setSelectionBackground(Color.DARK_GRAY);
    jTable1.getColumnModel().getColumn(1).setCellRenderer(renderer);
    jTable1.getColumnModel().getColumn(2).setCellRenderer(renderer);
    jTable1.getColumnModel().getColumn(3).setCellRenderer(renderer);
    if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) {
        jTable1.getColumnModel().getColumn(4).setCellRenderer(renderer);
    }
    DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 2L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setFont(new Font("Cantarell", Font.PLAIN, 14));
            this.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, new Color(1, 1, 1)));
            return this;
        }
    };
    DefaultTableCellRenderer headerRenderer2 = new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 3L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setFont(new Font("Cantarell", Font.PLAIN, 14));
            this.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(1, 1, 1)),
                    BorderFactory.createEmptyBorder(0, 20, 0, 0)));
            this.setBackground(new Color(100, 100, 100));
            setForeground(Color.WHITE);
            setPreferredSize(new Dimension(100, 40));
            return this;
        }
    };

    headerRenderer.setBackground(new Color(100, 100, 100));
    headerRenderer.setForeground(Color.WHITE);
    headerRenderer.setPreferredSize(new Dimension(100, 40));
    headerRenderer.setHorizontalAlignment(javax.swing.JLabel.CENTER);
    for (int i = 0; i < jTable1.getColumnCount(); i++) {
        if (i == 0) {
            headerRenderer2.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer2);
        } else {
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer);
        }
    }

    jButtonSair.setBackground(new java.awt.Color(1, 1, 1));
    jButtonSair.setToolTipText("");
    jButtonSair.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonSair.setFocusPainted(false);
    jButtonSair.setMaximumSize(new java.awt.Dimension(90, 40));
    jButtonSair.setMinimumSize(new java.awt.Dimension(90, 40));
    jButtonSair.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonSair.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonSairActionPerformed(evt);
        }
    });

    jXDatePickerInicio.setBackground(new java.awt.Color(254, 254, 254));
    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder2 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder2.setCornerSize(6);
    dropShadowBorder2.setShadowSize(3);
    dropShadowBorder2.setShowLeftShadow(true);
    jXDatePickerInicio.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder2,
            javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0))));
    jXDatePickerInicio.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jXDatePickerInicio.setMaximumSize(new java.awt.Dimension(1155551, 26));
    jXDatePickerInicio.setMinimumSize(new java.awt.Dimension(66, 26));
    jXDatePickerInicio.setPreferredSize(new java.awt.Dimension(131, 26));
    jXDatePickerInicio.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jXDatePickerInicioActionPerformed(evt);
        }
    });

    jXDatePickerFim.setBackground(new java.awt.Color(254, 254, 254));
    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder3 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder3.setCornerSize(6);
    dropShadowBorder3.setShadowSize(3);
    dropShadowBorder3.setShowLeftShadow(true);
    jXDatePickerFim.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder3,
            javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0))));
    jXDatePickerFim.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jXDatePickerFim.setMaximumSize(new java.awt.Dimension(1155551, 26));
    jXDatePickerFim.setMinimumSize(new java.awt.Dimension(66, 26));
    jXDatePickerFim.setPreferredSize(new java.awt.Dimension(121, 26));

    jLabel1.setBackground(new java.awt.Color(100, 100, 100));
    jLabel1.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(254, 254, 254));
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("Incio");
    jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    jLabel1.setMaximumSize(new java.awt.Dimension(3343446, 96));
    jLabel1.setMinimumSize(new java.awt.Dimension(36, 26));
    jLabel1.setOpaque(true);
    jLabel1.setPreferredSize(new java.awt.Dimension(100, 20));

    jLabel2.setBackground(new java.awt.Color(100, 100, 100));
    jLabel2.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel2.setForeground(new java.awt.Color(254, 254, 254));
    jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel2.setText("Fim");
    jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel2.setMaximumSize(new java.awt.Dimension(355557, 96));
    jLabel2.setMinimumSize(new java.awt.Dimension(37, 26));
    jLabel2.setOpaque(true);
    jLabel2.setPreferredSize(new java.awt.Dimension(100, 20));

    jButtonImprimir.setBackground(new java.awt.Color(51, 102, 153));
    jButtonImprimir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonImprimir.setFocusPainted(false);
    jButtonImprimir.setMaximumSize(new java.awt.Dimension(5345, 40));
    jButtonImprimir.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonImprimir.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonImprimirActionPerformed(evt);
        }
    });

    jComboBoxEstado.setBackground(new java.awt.Color(213, 213, 213));
    jComboBoxEstado.setBorder(null);
    jComboBoxEstado.setFocusable(false);
    jComboBoxEstado.setMinimumSize(new java.awt.Dimension(35, 22));
    jComboBoxEstado.setPreferredSize(new java.awt.Dimension(125, 28));
    jComboBoxEstado.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBoxEstadoActionPerformed(evt);
        }
    });

    jLabel3.setBackground(new java.awt.Color(100, 100, 100));
    jLabel3.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel3.setForeground(new java.awt.Color(254, 254, 254));
    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("Estado");
    jLabel3.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel3.setMaximumSize(new java.awt.Dimension(355557, 96));
    jLabel3.setMinimumSize(new java.awt.Dimension(37, 26));
    jLabel3.setOpaque(true);
    jLabel3.setPreferredSize(new java.awt.Dimension(100, 20));

    jButtonExportar.setBackground(new java.awt.Color(51, 102, 153));
    jButtonExportar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonExportar.setFocusPainted(false);
    jButtonExportar.setMaximumSize(new java.awt.Dimension(5345, 40));
    jButtonExportar.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonExportar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonExportarActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanelInicialLayout = new javax.swing.GroupLayout(jPanelInicial);
    jPanelInicial.setLayout(jPanelInicialLayout);
    jPanelInicialLayout.setHorizontalGroup(jPanelInicialLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(42, 42, 42)
                    .addGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelInicialLayout.createSequentialGroup().addComponent(jScrollPane1)
                                    .addGap(42, 42, 42))
                            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(29, 29, 29)
                                    .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(71, 71, 71))))
            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(71, 71, 71)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.DEFAULT_SIZE, 152,
                                    Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .addComponent(jXDatePickerFim, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboBoxEstado, 0, 241, Short.MAX_VALUE))
                    .addGap(71, 71, 71)));
    jPanelInicialLayout
            .setVerticalGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(16, 16, 16)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 0, 0)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jXDatePickerFim, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBoxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 465,
                                    Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(16, 16, 16)));

    try {
        if (Clavis.KeyQuest.class.getResource("Images/exit26x24.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exit26x24.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonSair.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonSair.setToolTipText(lingua.translate("Voltar"));
    javax.swing.JPanel pan2 = new javax.swing.JPanel(null);
    String compoe = lingua.translate("Hoje  dia") + ": " + new TimeDate.Date().toString();
    javax.swing.JLabel fil2 = new javax.swing.JLabel(compoe);
    fil2.setBounds(0, 0, 300, 26);
    fil2.setHorizontalAlignment(SwingConstants.CENTER);
    pan2.setPreferredSize(new Dimension(300, 30));
    pan2.setBounds(0, 0, 300, 30);
    pan2.add(fil2);
    jXDatePickerInicio.setLinkPanel(pan2);

    jXDatePickerInicio.setLocale(lingua.systemlocale);
    jXDatePickerInicio.getEditor().setSelectionColor(Color.DARK_GRAY);
    jXDatePickerInicio.getEditor().setBorder(BorderFactory.createEmptyBorder());
    jXDatePickerInicio.getEditor().setHorizontalAlignment(SwingConstants.CENTER);
    javax.swing.JButton bbt2 = (javax.swing.JButton) jXDatePickerInicio.getComponent(1);
    bbt2.setBackground(Color.WHITE);

    jXDatePickerInicio.addActionListener(actionJXDatePicker());
    jXDatePickerInicio.setFormats("dd/MM/yyyy");
    javax.swing.JPanel pan = new javax.swing.JPanel(null);
    String compoe0 = lingua.translate("Hoje  dia") + ": " + new TimeDate.Date().toString();
    javax.swing.JLabel fil = new javax.swing.JLabel(compoe);
    fil.setBounds(0, 0, 300, 26);
    fil.setHorizontalAlignment(SwingConstants.CENTER);
    pan.setPreferredSize(new Dimension(300, 30));
    pan.setBounds(0, 0, 300, 30);
    pan.add(fil);
    jXDatePickerFim.setLinkPanel(pan);

    Component[] t = jXDatePickerFim.getLinkPanel().getComponents();

    jXDatePickerFim.setLocale(lingua.systemlocale);
    jXDatePickerFim.getEditor().setSelectionColor(Color.DARK_GRAY);
    jXDatePickerFim.getEditor().setBorder(BorderFactory.createEmptyBorder());
    jXDatePickerFim.getEditor().setHorizontalAlignment(SwingConstants.CENTER);
    javax.swing.JButton bbt = (javax.swing.JButton) jXDatePickerFim.getComponent(1);
    bbt.setBackground(Color.WHITE);
    jXDatePickerFim.addActionListener(actionJXDatePicker());
    jXDatePickerFim.setFormats("dd/MM/yyyy");
    jLabel1.setText(lingua.translate("Incio"));
    jLabel2.setText(lingua.translate("Fim"));
    try {
        if (Clavis.KeyQuest.class.getResource("Images/print.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/print.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonImprimir.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonImprimir.setToolTipText(lingua.translate("Imprimir"));
    jComboBoxEstado.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { lingua.translate("todos"), lingua.translate("terminado"),
                    lingua.translate("no realizado"), lingua.translate("por realizar") }));
    Clavis.KeyQuest.addVisualComboBox(jComboBoxEstado);
    ((javax.swing.JLabel) jComboBoxEstado.getRenderer()).setHorizontalAlignment(javax.swing.JLabel.CENTER);
    jLabel3.setText(lingua.translate("Estado"));
    try {
        if (Clavis.KeyQuest.class.getResource("Images/exportar.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exportar.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonExportar.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonExportar.setToolTipText(lingua.translate("Exportar para excel"));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addComponent(jPanelInicial,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(0, 0, 0)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE));
}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

/**
 * Create detail frames shown after calculation
 *//* w w w . j a v a2  s  .  co  m*/
private void buildDetailedStatistics(HashMap<Village, String> attackMappings,
        List<Village> pNotAssignedVillages) {
    // <editor-fold defaultstate="collapsed" desc="Build not assigned source table">
    Collections.sort(pNotAssignedVillages);
    DefaultTableModel sourcesModel = new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "Spieler", "Dorf" }) {

        private Class[] cTypes = new Class[] { Tribe.class, Village.class };

        @Override
        public Class getColumnClass(int columnIndex) {
            return cTypes[columnIndex];
        }
    };
    for (Village notAssigned : pNotAssignedVillages) {
        Tribe t = notAssigned.getTribe();
        if (t == null) {
            sourcesModel.addRow(new Object[] { Barbarians.getSingleton(), notAssigned });
        } else {
            sourcesModel.addRow(new Object[] { t, notAssigned });
        }
    }
    jNotAssignedSourcesTable.setModel(sourcesModel);
    TableRowSorter<TableModel> sourcesSorter = new TableRowSorter<TableModel>(sourcesModel);
    jNotAssignedSourcesTable.setRowSorter(sourcesSorter);
    DefaultTableCellRenderer headerRenderer = new SortableTableHeaderRenderer();
    for (int i = 0; i < jNotAssignedSourcesTable.getColumnCount(); i++) {
        jNotAssignedSourcesTable.getColumn(jNotAssignedSourcesTable.getColumnName(i))
                .setHeaderRenderer(headerRenderer);
    }
    jNotAssignedSourcesTable.revalidate();
    //</editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Build attacks per target table">
    DefaultTableModel tableModel = new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "Spieler", "Dorf", "Angriffe" }) {

        Class[] types = new Class[] { Tribe.class, Village.class, String.class };

        @Override
        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }
    };
    List<Village> notFullTargets = new LinkedList<Village>();
    Iterator<Village> keys = attackMappings.keySet().iterator();
    while (keys.hasNext()) {
        Village key = keys.next();
        Tribe t = key.getTribe();
        //int notAssignedAmount = attackMappings.get(key);
        String attackCount = attackMappings.get(key);
        String[] split = attackCount.split("/");
        int notAssignedAmount = Integer.parseInt(split[1]) - Integer.parseInt(split[0]);
        if (t != Barbarians.getSingleton()) {
            tableModel.addRow(new Object[] { t, key, attackCount });
        } else {
            tableModel.addRow(new Object[] { "Barbaren", key, attackCount });
        }
        if (notAssignedAmount > 0) {
            notFullTargets.add(key);
        }
    }
    jTargetDetailsTable.setModel(tableModel);
    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
    jTargetDetailsTable.setRowSorter(sorter);
    DefaultTableCellRenderer coloredRenderer = new DefaultTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Component c = new DefaultTableCellRenderer().getTableCellRendererComponent(table, value, isSelected,
                    hasFocus, row, row);
            String t = ((DefaultTableCellRenderer) c).getText();
            ((DefaultTableCellRenderer) c).setText(t);
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            int r = table.convertRowIndexToModel(row);
            String sVal = (String) model.getValueAt(r, 2);
            String[] split = sVal.split("/");
            long max = Long.parseLong(split[1]);
            long v = Long.parseLong(split[0]);
            long diff = max - v;
            Color back = Color.RED;
            if (v == 0) {
                //color stays red
            } else if (v == max) {
                back = Color.GREEN;
            } else {
                float posv = 100.0f * (float) diff / (float) max;
                posv = ((int) posv / 10) * 10;
                posv /= 100;
                Color LAST_SEGMENT = new Color(255, 100, 0);
                int red = (int) Math.rint(
                        (float) LAST_SEGMENT.getRed() * (1.0f - posv) + (float) Color.YELLOW.getRed() * posv);
                int green = (int) Math.rint((float) LAST_SEGMENT.getGreen() * (1.0f - posv)
                        + (float) Color.YELLOW.getGreen() * posv);
                int blue = (int) Math.rint(
                        (float) LAST_SEGMENT.getBlue() * (1.0f - posv) + (float) Color.YELLOW.getBlue() * posv);
                if (red < 0) {
                    red = 0;
                }
                if (green < 0) {
                    green = 0;
                }
                if (blue < 0) {
                    blue = 0;
                }
                if (red > 254) {
                    red = 254;
                }
                if (green > 254) {
                    green = 254;
                }
                if (blue > 254) {
                    blue = 254;
                }
                back = new Color(red, green, blue);
            }
            DefaultTableCellRenderer renderer = ((DefaultTableCellRenderer) c);
            if (!isSelected) {
                renderer.setBackground(back);
            }
            return c;
        }
    };
    jTargetDetailsTable.setDefaultRenderer(Village.class, coloredRenderer);
    jTargetDetailsTable.setDefaultRenderer(Integer.class, coloredRenderer);
    jTargetDetailsTable.setDefaultRenderer(String.class, coloredRenderer);
    jTargetDetailsTable.setDefaultRenderer(Tribe.class, coloredRenderer);
    for (int i = 0; i < jTargetDetailsTable.getColumnCount(); i++) {
        jTargetDetailsTable.getColumn(jTargetDetailsTable.getColumnName(i)).setHeaderRenderer(headerRenderer);
    }
    jTargetDetailsTable.revalidate();
    //</editor-fold>
}

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   ww  w.jav 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 ww.  j  a va 2s  .com
 * @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.
 * /*from   w  w w  .  java  2 s  . com*/
 * @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.j a v a 2s  .c  om
 * 
 * @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,
 * //from w ww .  java 2  s. co 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 v a  2s .co  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();

}