• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jiangxincode / ApkToolBoxGUI / #1295

15 Nov 2025 09:45AM UTC coverage: 2.849% (-0.002%) from 2.851%
#1295

push

jiangxincode
split color table and color converter

0 of 57 new or added lines in 3 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

248 of 8706 relevant lines covered (2.85%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/edu/jiangxin/apktoolbox/convert/color/ColorTablePanel.java
1
package edu.jiangxin.apktoolbox.convert.color;
2

3
import edu.jiangxin.apktoolbox.convert.color.colortable.IColorTable;
4
import edu.jiangxin.apktoolbox.convert.color.colortable.OrdinaryColorTable;
5
import edu.jiangxin.apktoolbox.convert.color.colortable.RalColorTable;
6
import edu.jiangxin.apktoolbox.convert.color.utils.ColorUtils;
7
import edu.jiangxin.apktoolbox.swing.extend.EasyPanel;
8
import edu.jiangxin.apktoolbox.utils.Constants;
9

10
import javax.swing.*;
11
import javax.swing.table.DefaultTableCellRenderer;
12
import javax.swing.table.DefaultTableModel;
13
import java.awt.*;
14
import java.io.Serial;
15

16
public class ColorTablePanel extends EasyPanel {
17
    @Serial
18
    private static final long serialVersionUID = 1L;
19

20
    private JComboBox<IColorTable> colorTableTypeComboBox;
21

22
    private JTable colorTable;
23

24
    public ColorTablePanel() throws HeadlessException {
NEW
25
        super();
×
NEW
26
    }
×
27

28
    @Override
29
    public void initUI() {
NEW
30
        BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
×
NEW
31
        setLayout(boxLayout);
×
32

NEW
33
        add(Box.createVerticalStrut(Constants.DEFAULT_Y_BORDER));
×
NEW
34
        createColorTablePanel();
×
NEW
35
    }
×
36

37
    private void createColorTablePanel() {
NEW
38
        JPanel colorTablePanel = new JPanel();
×
NEW
39
        add(colorTablePanel);
×
NEW
40
        setLayout(new BorderLayout());
×
NEW
41
        setBorder(BorderFactory.createTitledBorder("Color Table"));
×
42

NEW
43
        JPanel yPanel = new JPanel();
×
NEW
44
        add(yPanel);
×
NEW
45
        yPanel.setLayout(new BoxLayout(yPanel, BoxLayout.Y_AXIS));
×
46

NEW
47
        colorTableTypeComboBox = new JComboBox<>();
×
NEW
48
        IColorTable ordinaryColorTable = new OrdinaryColorTable();
×
NEW
49
        IColorTable ralColorTable = new RalColorTable();
×
NEW
50
        colorTableTypeComboBox.addItem(ordinaryColorTable);
×
NEW
51
        colorTableTypeComboBox.addItem(ralColorTable);
×
NEW
52
        colorTableTypeComboBox.setSelectedItem(ordinaryColorTable);
×
NEW
53
        colorTableTypeComboBox.addItemListener(itemEvent -> {
×
NEW
54
            ColorDefaultTableModel model = (ColorDefaultTableModel) colorTable.getModel();
×
NEW
55
            IColorTable selectedColorTable = (IColorTable) itemEvent.getItem();
×
NEW
56
            model.setDataVector(selectedColorTable.getTableRowData(), selectedColorTable.getColumnNames());
×
NEW
57
            onColorTableChanged();
×
NEW
58
        });
×
59

NEW
60
        IColorTable selectedColorTable = (IColorTable) colorTableTypeComboBox.getSelectedItem();
×
NEW
61
        colorTable = new JTable(new ColorDefaultTableModel(selectedColorTable.getTableRowData(), selectedColorTable.getColumnNames()));
×
NEW
62
        JScrollPane colorTableScrollPane = new JScrollPane(colorTable);
×
NEW
63
        onColorTableChanged();
×
64

NEW
65
        yPanel.add(colorTableTypeComboBox);
×
NEW
66
        yPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
×
NEW
67
        yPanel.add(colorTableScrollPane);
×
NEW
68
    }
×
69

70
    private void onColorTableChanged() {
NEW
71
        IColorTable selectedColorTable = (IColorTable) colorTableTypeComboBox.getSelectedItem();
×
NEW
72
        int labelIndex = selectedColorTable.getLabelIndex();
×
NEW
73
        String labelName = colorTable.getColumnName(labelIndex);
×
NEW
74
        colorTable.getColumn(labelName).setCellRenderer(new ColorTableCellRenderer());
×
NEW
75
    }
×
76

77
    private class ColorDefaultTableModel extends DefaultTableModel {
78
        @Serial
79
        private static final long serialVersionUID = 1L;
80

NEW
81
        public ColorDefaultTableModel(Object[][] data, Object[] columnNames) {
×
NEW
82
            super(data, columnNames);
×
NEW
83
        }
×
84

85
        @Override
86
        public boolean isCellEditable(int row, int column) {
NEW
87
            return true;
×
88
        }
89
    }
90

NEW
91
    private class ColorTableCellRenderer extends DefaultTableCellRenderer {
×
92
        @Serial
93
        private static final long serialVersionUID = 1L;
94

95
        @Override
96
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
NEW
97
            Component renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
×
NEW
98
            IColorTable selectedColorTable = (IColorTable) colorTableTypeComboBox.getSelectedItem();
×
NEW
99
            if (selectedColorTable == null) {
×
NEW
100
                return renderer;
×
101
            }
NEW
102
            String hex = (String) colorTable.getValueAt(row, selectedColorTable.getHexIndex());
×
NEW
103
            Color color = ColorUtils.hex2Color(hex);
×
NEW
104
            renderer.setBackground(color);
×
NEW
105
            return renderer;
×
106
        }
107
    }
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc