ArrowIcon.java

1
package com.jsql.view.swing.combomenu;
2
3
import com.jsql.util.LogLevelUtil;
4
import org.apache.logging.log4j.LogManager;
5
import org.apache.logging.log4j.Logger;
6
7
import javax.swing.*;
8
import javax.swing.plaf.basic.BasicArrowButton;
9
import java.awt.*;
10
11
public class ArrowIcon implements Icon, SwingConstants {
12
    
13
    /**
14
     * Log4j logger sent to view.
15
     */
16
    private static final Logger LOGGER = LogManager.getRootLogger();
17
    
18
    private static final int DEFAULT_SIZE = 9;
19
20
    private final int size;
21
    private final int iconSize;
22
    private final int direction;
23
    private final boolean isEnabled;
24
    private final BasicArrowButton iconRenderer;
25
26
    public ArrowIcon(int direction, boolean isPressedView) {
27
        this(DEFAULT_SIZE, direction, isPressedView);
28
    }
29
30
    public ArrowIcon(int iconSize, int direction, boolean isEnabled) {
31
        
32 1 1. <init> : Replaced integer division with multiplication → NO_COVERAGE
        this.size = iconSize / 2;
33
        this.iconSize = iconSize;
34
        this.direction = direction;
35
        this.isEnabled = isEnabled;
36
        this.iconRenderer = new BasicArrowButton(direction);
37
    }
38
39
    @Override
40
    public void paintIcon(Component c, Graphics g, int x, int y) {
41
        
42
        // Fix #4731: ClassCastException on paintTriangle()
43
        // Implementation by sun.awt.image
44
        try {
45 2 1. paintIcon : removed call to javax/swing/plaf/basic/BasicArrowButton::paintTriangle → NO_COVERAGE
2. paintIcon : Replaced integer addition with subtraction → NO_COVERAGE
            this.iconRenderer.paintTriangle(g, x, y + 3, this.size, this.direction, this.isEnabled);
46
        } catch(ClassCastException e) {
47
            LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
48
        }
49
    }
50
51
    @Override
52
    public int getIconWidth() {
53
        switch (this.direction) {
54
            case NORTH:
55 1 1. getIconWidth : replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconWidth → NO_COVERAGE
            case SOUTH: return this.iconSize;
56
            case EAST:
57
            case WEST:
58 1 1. getIconWidth : replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconWidth → NO_COVERAGE
            default: return this.size;
59
        }
60
    }
61
62
    @Override
63
    public int getIconHeight() {
64
        switch (this.direction) {
65
            case NORTH:
66 1 1. getIconHeight : replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconHeight → NO_COVERAGE
            case SOUTH: return this.size;
67
            case EAST:
68
            case WEST:
69 1 1. getIconHeight : replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconHeight → NO_COVERAGE
            default: return this.iconSize;
70
        }
71
    }
72
}

Mutations

32

1.1
Location : <init>
Killed by : none
Replaced integer division with multiplication → NO_COVERAGE

45

1.1
Location : paintIcon
Killed by : none
removed call to javax/swing/plaf/basic/BasicArrowButton::paintTriangle → NO_COVERAGE

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

55

1.1
Location : getIconWidth
Killed by : none
replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconWidth → NO_COVERAGE

58

1.1
Location : getIconWidth
Killed by : none
replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconWidth → NO_COVERAGE

66

1.1
Location : getIconHeight
Killed by : none
replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconHeight → NO_COVERAGE

69

1.1
Location : getIconHeight
Killed by : none
replaced int return with 0 for com/jsql/view/swing/combomenu/ArrowIcon::getIconHeight → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1