RadioMethodMouseAdapter.java

1
package com.jsql.view.swing.radio;
2
3
import com.jsql.view.swing.util.UiUtil;
4
5
import javax.swing.*;
6
import java.awt.*;
7
import java.awt.event.MouseAdapter;
8
import java.awt.event.MouseEvent;
9
import java.awt.font.TextAttribute;
10
import java.util.HashMap;
11
import java.util.Map;
12
13
/**
14
 * Mouse adapter for radio link effect (hover and click).
15
 */
16
public class RadioMethodMouseAdapter extends MouseAdapter {
17
    
18
    /**
19
     * Font to display on mouse exit: underline or bold.
20
     */
21
    private Font original;
22
23
    @Override
24
    public void mouseClicked(MouseEvent e) {
25
        
26 1 1. mouseClicked : removed call to java/awt/event/MouseAdapter::mouseClicked → NO_COVERAGE
        super.mouseClicked(e);
27
        
28
        AbstractRadioLink radio = (AbstractRadioLink) e.getComponent();
29
        
30 2 1. mouseClicked : negated conditional → NO_COVERAGE
2. mouseClicked : negated conditional → NO_COVERAGE
        if (radio.isActivable() && SwingUtilities.isLeftMouseButton(e)) {
31
            
32
            for (JLabel label: radio.getGroup()) {
33 1 1. mouseClicked : negated conditional → NO_COVERAGE
                if (e.getComponent() != label) {
34 1 1. mouseClicked : removed call to javax/swing/JLabel::setFont → NO_COVERAGE
                    label.setFont(UiUtil.FONT_NON_MONO);
35
                } else {
36 1 1. mouseClicked : removed call to com/jsql/view/swing/radio/AbstractRadioLink::action → NO_COVERAGE
                    radio.action();
37
                }
38
            }
39
40 1 1. mouseClicked : removed call to com/jsql/view/swing/radio/AbstractRadioLink::setUnderlined → NO_COVERAGE
            radio.setUnderlined();
41
42
            this.original = e.getComponent().getFont();
43 1 1. mouseClicked : removed call to com/jsql/view/swing/radio/AbstractRadioLink::setCursor → NO_COVERAGE
            radio.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
44
        }
45
    }
46
47
    @Override
48
    public void mouseEntered(MouseEvent e) {
49
        
50 1 1. mouseEntered : removed call to java/awt/event/MouseAdapter::mouseEntered → NO_COVERAGE
        super.mouseEntered(e);
51
        
52
        AbstractRadioLink radio = (AbstractRadioLink) e.getComponent();
53
        
54
        this.original = e.getComponent().getFont();
55
56 1 1. mouseEntered : negated conditional → NO_COVERAGE
        if (radio.isActivable()) {
57
            
58
            var font = radio.getFont();
59
            Map<TextAttribute, Object> attributes = new HashMap<>(font.getAttributes());
60
            attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
61 1 1. mouseEntered : removed call to com/jsql/view/swing/radio/AbstractRadioLink::setFont → NO_COVERAGE
            radio.setFont(font.deriveFont(attributes));
62 1 1. mouseEntered : removed call to com/jsql/view/swing/radio/AbstractRadioLink::setCursor → NO_COVERAGE
            radio.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
63
        }
64
    }
65
66
    @Override
67
    public void mouseExited(MouseEvent e) {
68
        
69 1 1. mouseExited : removed call to java/awt/event/MouseAdapter::mouseExited → NO_COVERAGE
        super.mouseExited(e);
70
        
71
        AbstractRadioLink radio = (AbstractRadioLink) e.getComponent();
72
        
73 1 1. mouseExited : removed call to com/jsql/view/swing/radio/AbstractRadioLink::setFont → NO_COVERAGE
        radio.setFont(this.original);
74 1 1. mouseExited : removed call to com/jsql/view/swing/radio/AbstractRadioLink::setCursor → NO_COVERAGE
        radio.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
75
    }
76
}

Mutations

26

1.1
Location : mouseClicked
Killed by : none
removed call to java/awt/event/MouseAdapter::mouseClicked → NO_COVERAGE

30

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

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

33

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

34

1.1
Location : mouseClicked
Killed by : none
removed call to javax/swing/JLabel::setFont → NO_COVERAGE

36

1.1
Location : mouseClicked
Killed by : none
removed call to com/jsql/view/swing/radio/AbstractRadioLink::action → NO_COVERAGE

40

1.1
Location : mouseClicked
Killed by : none
removed call to com/jsql/view/swing/radio/AbstractRadioLink::setUnderlined → NO_COVERAGE

43

1.1
Location : mouseClicked
Killed by : none
removed call to com/jsql/view/swing/radio/AbstractRadioLink::setCursor → NO_COVERAGE

50

1.1
Location : mouseEntered
Killed by : none
removed call to java/awt/event/MouseAdapter::mouseEntered → NO_COVERAGE

56

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

61

1.1
Location : mouseEntered
Killed by : none
removed call to com/jsql/view/swing/radio/AbstractRadioLink::setFont → NO_COVERAGE

62

1.1
Location : mouseEntered
Killed by : none
removed call to com/jsql/view/swing/radio/AbstractRadioLink::setCursor → NO_COVERAGE

69

1.1
Location : mouseExited
Killed by : none
removed call to java/awt/event/MouseAdapter::mouseExited → NO_COVERAGE

73

1.1
Location : mouseExited
Killed by : none
removed call to com/jsql/view/swing/radio/AbstractRadioLink::setFont → NO_COVERAGE

74

1.1
Location : mouseExited
Killed by : none
removed call to com/jsql/view/swing/radio/AbstractRadioLink::setCursor → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1