CustomMetalTabbedPaneUI.java

1
/*******************************************************************************
2
 * Copyhacked (H) 2012-2020.
3
 * This program and the accompanying materials
4
 * are made available under no term at all, use it like
5
 * you want, but share and discuss about it
6
 * every time possible with every body.
7
 *
8
 * Contributors:
9
 *      ron190 at ymail dot com - initial implementation
10
 *******************************************************************************/
11
package com.jsql.view.swing.ui;
12
13
import com.jsql.view.swing.util.UiUtil;
14
15
import java.awt.*;
16
import java.awt.geom.GeneralPath;
17
18
/**
19
 * Tab UI to remove inner borders on empty tabbedpane and force header height on
20
 * Linux.
21
 */
22
public class CustomMetalTabbedPaneUI extends BorderlessTabButtonUI {
23
    
24
    private static final float ADJ2 = 0f;
25
    
26
    private static final Color TAB_BACKGROUND = UiUtil.COLOR_DEFAULT_BACKGROUND;
27
    private static final Color TAB_BORDER = UiUtil.COLOR_COMPONENT_BORDER;
28
    
29
    @Override
30
    protected int calculateMaxTabHeight(int tabPlacement) {
31 1 1. calculateMaxTabHeight : replaced int return with 0 for com/jsql/view/swing/ui/CustomMetalTabbedPaneUI::calculateMaxTabHeight → NO_COVERAGE
        return 22;
32
    }
33
34
    @Override
35
    protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) {
36
        // Do nothing
37
    }
38
39
    @Override
40
    protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) {
41
        // Do nothing
42
    }
43
44
    @Override
45
    protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) {
46
        // Do nothing
47
    }
48
49
    @Override
50
    protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
51
        // Do nothing
52
    }
53
54
    @Override
55
    protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected) {
56
        // Do nothing
57
    }
58
59
    @Override
60
    protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) {
61
        // Do nothing
62
    }
63
64
    @Override
65
    protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) {
66
67
        int tabCount = this.tabPane.getTabCount();
68
69
        var iconRect = new Rectangle();
70
        var textRect = new Rectangle();
71
        Rectangle clipRect = g.getClipBounds();
72
73
        // copied from BasicTabbedPaneUI#paintTabArea(...)
74 3 1. paintTabArea : Replaced integer subtraction with addition → NO_COVERAGE
2. paintTabArea : changed conditional boundary → NO_COVERAGE
3. paintTabArea : negated conditional → NO_COVERAGE
        for (int i = this.runCount - 1 ; i >= 0 ; i--) {
75
            
76
            int start = this.tabRuns[i];
77 3 1. paintTabArea : Replaced integer subtraction with addition → NO_COVERAGE
2. paintTabArea : Replaced integer addition with subtraction → NO_COVERAGE
3. paintTabArea : negated conditional → NO_COVERAGE
            int next = this.tabRuns[(i == this.runCount - 1) ? 0 : i + 1];
78 3 1. paintTabArea : Replaced integer subtraction with addition → NO_COVERAGE
2. paintTabArea : Replaced integer subtraction with addition → NO_COVERAGE
3. paintTabArea : negated conditional → NO_COVERAGE
            int end = next == 0 ? tabCount - 1 : next - 1;
79
            
80
            // https://stackoverflow.com/questions/41566659/tabs-rendering-order-in-custom-jtabbedpane
81 2 1. paintTabArea : changed conditional boundary → NO_COVERAGE
2. paintTabArea : negated conditional → NO_COVERAGE
            for (int j = end; j >= start; j--) {
82
                
83 2 1. paintTabArea : negated conditional → NO_COVERAGE
2. paintTabArea : negated conditional → NO_COVERAGE
                if (j != selectedIndex && this.rects[j].intersects(clipRect)) {
84
                    
85 1 1. paintTabArea : removed call to com/jsql/view/swing/ui/CustomMetalTabbedPaneUI::paintTab → NO_COVERAGE
                    this.paintTab(g, tabPlacement, this.rects, j, iconRect, textRect);
86
                }
87
            }
88
        }
89
        
90 3 1. paintTabArea : changed conditional boundary → NO_COVERAGE
2. paintTabArea : negated conditional → NO_COVERAGE
3. paintTabArea : negated conditional → NO_COVERAGE
        if (selectedIndex >= 0 && this.rects[selectedIndex].intersects(clipRect)) {
91
            
92 1 1. paintTabArea : removed call to com/jsql/view/swing/ui/CustomMetalTabbedPaneUI::paintTab → NO_COVERAGE
            this.paintTab(g, tabPlacement, this.rects, selectedIndex, iconRect, textRect);
93
        }
94
    }
95
96
    @Override
97
    protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
98
        
99
        Graphics2D g2 = (Graphics2D) g.create();
100 1 1. paintTabBackground : removed call to java/awt/Graphics2D::setRenderingHint → NO_COVERAGE
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
101
102
        var textShiftOffset = 0f;
103
        var trapezoid = new GeneralPath();
104 3 1. paintTabBackground : removed call to java/awt/geom/GeneralPath::moveTo → NO_COVERAGE
2. paintTabBackground : Replaced float subtraction with addition → NO_COVERAGE
3. paintTabBackground : Replaced float addition with subtraction → NO_COVERAGE
        trapezoid.moveTo(x - ADJ2, (float) y + h);
105 3 1. paintTabBackground : Replaced float addition with subtraction → NO_COVERAGE
2. paintTabBackground : removed call to java/awt/geom/GeneralPath::lineTo → NO_COVERAGE
3. paintTabBackground : Replaced float addition with subtraction → NO_COVERAGE
        trapezoid.lineTo(x + ADJ2, y + textShiftOffset);
106 4 1. paintTabBackground : Replaced float addition with subtraction → NO_COVERAGE
2. paintTabBackground : Replaced float subtraction with addition → NO_COVERAGE
3. paintTabBackground : Replaced integer addition with subtraction → NO_COVERAGE
4. paintTabBackground : removed call to java/awt/geom/GeneralPath::lineTo → NO_COVERAGE
        trapezoid.lineTo(x + w - ADJ2, y + textShiftOffset);
107 4 1. paintTabBackground : Replaced float addition with subtraction → NO_COVERAGE
2. paintTabBackground : Replaced integer addition with subtraction → NO_COVERAGE
3. paintTabBackground : removed call to java/awt/geom/GeneralPath::lineTo → NO_COVERAGE
4. paintTabBackground : Replaced float addition with subtraction → NO_COVERAGE
        trapezoid.lineTo(x + w + ADJ2, (float) y + h);
108
109 2 1. paintTabBackground : removed call to java/awt/Graphics2D::setColor → NO_COVERAGE
2. paintTabBackground : negated conditional → NO_COVERAGE
        g2.setColor(isSelected ? UiUtil.COLOR_FOCUS_GAINED : TAB_BACKGROUND);
110 1 1. paintTabBackground : removed call to java/awt/Graphics2D::fill → NO_COVERAGE
        g2.fill(trapezoid);
111
112 1 1. paintTabBackground : removed call to java/awt/Graphics2D::setColor → NO_COVERAGE
        g2.setColor(TAB_BORDER);
113 1 1. paintTabBackground : removed call to java/awt/Graphics2D::draw → NO_COVERAGE
        g2.draw(trapezoid);
114
115 1 1. paintTabBackground : removed call to java/awt/Graphics2D::dispose → NO_COVERAGE
        g2.dispose();
116
    }
117
}

Mutations

31

1.1
Location : calculateMaxTabHeight
Killed by : none
replaced int return with 0 for com/jsql/view/swing/ui/CustomMetalTabbedPaneUI::calculateMaxTabHeight → NO_COVERAGE

74

1.1
Location : paintTabArea
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

2.2
Location : paintTabArea
Killed by : none
changed conditional boundary → NO_COVERAGE

3.3
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

77

1.1
Location : paintTabArea
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

2.2
Location : paintTabArea
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

3.3
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

78

1.1
Location : paintTabArea
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

2.2
Location : paintTabArea
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

3.3
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

81

1.1
Location : paintTabArea
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

83

1.1
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

85

1.1
Location : paintTabArea
Killed by : none
removed call to com/jsql/view/swing/ui/CustomMetalTabbedPaneUI::paintTab → NO_COVERAGE

90

1.1
Location : paintTabArea
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : paintTabArea
Killed by : none
negated conditional → NO_COVERAGE

92

1.1
Location : paintTabArea
Killed by : none
removed call to com/jsql/view/swing/ui/CustomMetalTabbedPaneUI::paintTab → NO_COVERAGE

100

1.1
Location : paintTabBackground
Killed by : none
removed call to java/awt/Graphics2D::setRenderingHint → NO_COVERAGE

104

1.1
Location : paintTabBackground
Killed by : none
removed call to java/awt/geom/GeneralPath::moveTo → NO_COVERAGE

2.2
Location : paintTabBackground
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

3.3
Location : paintTabBackground
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

105

1.1
Location : paintTabBackground
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

2.2
Location : paintTabBackground
Killed by : none
removed call to java/awt/geom/GeneralPath::lineTo → NO_COVERAGE

3.3
Location : paintTabBackground
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

106

1.1
Location : paintTabBackground
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

2.2
Location : paintTabBackground
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

3.3
Location : paintTabBackground
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

4.4
Location : paintTabBackground
Killed by : none
removed call to java/awt/geom/GeneralPath::lineTo → NO_COVERAGE

107

1.1
Location : paintTabBackground
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

2.2
Location : paintTabBackground
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

3.3
Location : paintTabBackground
Killed by : none
removed call to java/awt/geom/GeneralPath::lineTo → NO_COVERAGE

4.4
Location : paintTabBackground
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

109

1.1
Location : paintTabBackground
Killed by : none
removed call to java/awt/Graphics2D::setColor → NO_COVERAGE

2.2
Location : paintTabBackground
Killed by : none
negated conditional → NO_COVERAGE

110

1.1
Location : paintTabBackground
Killed by : none
removed call to java/awt/Graphics2D::fill → NO_COVERAGE

112

1.1
Location : paintTabBackground
Killed by : none
removed call to java/awt/Graphics2D::setColor → NO_COVERAGE

113

1.1
Location : paintTabBackground
Killed by : none
removed call to java/awt/Graphics2D::draw → NO_COVERAGE

115

1.1
Location : paintTabBackground
Killed by : none
removed call to java/awt/Graphics2D::dispose → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1