package com.its.vds.ui;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

public class CtlrSttsDetlTableCellRenderer extends DefaultTableCellRenderer {

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

        Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        String commStts = table.getModel().getValueAt(row, 6).toString();
        if (commStts.equals("Connect")) {
            cell.setBackground(new Color(255, 255, 255, 255));
            String door = table.getModel().getValueAt(row, 7).toString();
            String fan = table.getModel().getValueAt(row, 8).toString();
            String heater = table.getModel().getValueAt(row, 9).toString();
            String video = table.getModel().getValueAt(row, 11).toString();
        } else if (commStts.equals("Login")) {
            cell.setBackground(new Color(182, 175, 97, 176));
        } else {
            cell.setBackground(new Color(182, 97, 97, 176));
        }

        if (column != 3 && column != 4) {
            setHorizontalAlignment(SwingConstants.CENTER);
        } else {
            setHorizontalAlignment(SwingConstants.LEFT);
        }

        return cell;
    }
}
