ImageObserverAnimated.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.tree;
12
13
import javax.swing.*;
14
import javax.swing.tree.DefaultTreeModel;
15
import javax.swing.tree.TreeNode;
16
import javax.swing.tree.TreePath;
17
import java.awt.*;
18
import java.awt.image.ImageObserver;
19
20
/**
21
 * Observer to update tree node composed by the animated GIF.
22
 */
23
public class ImageObserverAnimated implements ImageObserver {
24
    
25
    private final JTree tree;
26
    private final TreePath path;
27
    
28
    /**
29
     * Build GIF animator for tree node.
30
     * @param tree Tree containing GIF node
31
     * @param node Node with a GIF to animate
32
     */
33
    public ImageObserverAnimated(JTree tree, TreeNode node) {
34
        
35
        this.tree = tree;
36
        
37
        DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();
38
        this.path = new TreePath(treeModel.getPathToRoot(node));
39
    }
40
41
    @Override
42
    public boolean imageUpdate(Image image, int flags, int x, int y, int w, int h) {
43
        
44 2 1. imageUpdate : Replaced bitwise AND with OR → NO_COVERAGE
2. imageUpdate : negated conditional → NO_COVERAGE
        if ((flags & (FRAMEBITS | ALLBITS)) != 0) {
45
            
46
            Rectangle rectangle = this.tree.getPathBounds(this.path);
47
            
48 1 1. imageUpdate : negated conditional → NO_COVERAGE
            if (rectangle != null) {
49 1 1. imageUpdate : removed call to javax/swing/JTree::repaint → NO_COVERAGE
                this.tree.repaint(rectangle);  // Unhandled StackOverflowError #92723
50
            }
51
        }
52
        
53 3 1. imageUpdate : negated conditional → NO_COVERAGE
2. imageUpdate : Replaced bitwise AND with OR → NO_COVERAGE
3. imageUpdate : replaced boolean return with true for com/jsql/view/swing/tree/ImageObserverAnimated::imageUpdate → NO_COVERAGE
        return (flags & (ALLBITS | ABORT)) == 0;
54
    }
55
}

Mutations

44

1.1
Location : imageUpdate
Killed by : none
Replaced bitwise AND with OR → NO_COVERAGE

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

48

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

49

1.1
Location : imageUpdate
Killed by : none
removed call to javax/swing/JTree::repaint → NO_COVERAGE

53

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

2.2
Location : imageUpdate
Killed by : none
Replaced bitwise AND with OR → NO_COVERAGE

3.3
Location : imageUpdate
Killed by : none
replaced boolean return with true for com/jsql/view/swing/tree/ImageObserverAnimated::imageUpdate → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1