|
1
|
|
package g0803.bindingofshiba.textures; |
|
2
|
|
|
|
3
|
|
import g0803.bindingofshiba.math.BoundingBox; |
|
4
|
|
import g0803.bindingofshiba.math.Vec2D; |
|
5
|
|
import java.awt.*; |
|
6
|
|
import java.util.ArrayList; |
|
7
|
|
import java.util.Collections; |
|
8
|
|
import java.util.List; |
|
9
|
|
|
|
10
|
|
public class StaticTexture implements ITexture { |
|
11
|
|
|
|
12
|
|
private final int width, height; |
|
13
|
|
private final Vec2D anchorPoint; |
|
14
|
|
private final Color[] pixels; |
|
15
|
|
|
|
16
|
|
public StaticTexture(int width, int height, Vec2D anchorPoint, Color[] pixels) { |
|
17
|
2
1. <init> : Replaced integer multiplication with division → KILLED
2. <init> : negated conditional → KILLED
|
if (pixels.length != width * height) |
|
18
|
|
throw new IllegalArgumentException( |
|
19
|
|
"Pixel array dimensions don't match expected dimensions"); |
|
20
|
|
|
|
21
|
|
this.width = width; |
|
22
|
|
this.height = height; |
|
23
|
|
this.anchorPoint = anchorPoint; |
|
24
|
|
this.pixels = pixels; |
|
25
|
|
} |
|
26
|
|
|
|
27
|
|
public StaticTexture(StaticTexture texture, Vec2D anchorPoint) { |
|
28
|
|
this.width = texture.width; |
|
29
|
|
this.height = texture.height; |
|
30
|
|
this.anchorPoint = anchorPoint; |
|
31
|
|
this.pixels = texture.pixels.clone(); |
|
32
|
|
} |
|
33
|
|
|
|
34
|
|
@Override |
|
35
|
|
public int getWidth() { |
|
36
|
1
1. getWidth : replaced int return with 0 for g0803/bindingofshiba/textures/StaticTexture::getWidth → KILLED
|
return this.width; |
|
37
|
|
} |
|
38
|
|
|
|
39
|
|
@Override |
|
40
|
|
public int getHeight() { |
|
41
|
1
1. getHeight : replaced int return with 0 for g0803/bindingofshiba/textures/StaticTexture::getHeight → KILLED
|
return this.height; |
|
42
|
|
} |
|
43
|
|
|
|
44
|
|
@Override |
|
45
|
|
public Vec2D getAnchorOffset(int x, int y) { |
|
46
|
1
1. getAnchorOffset : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getAnchorOffset → KILLED
|
return this.getAnchorOffset(new Vec2D(x, y)); |
|
47
|
|
} |
|
48
|
|
|
|
49
|
|
@Override |
|
50
|
|
public Vec2D getAnchorOffset(Vec2D position) { |
|
51
|
1
1. getAnchorOffset : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getAnchorOffset → KILLED
|
return position.subtract(this.anchorPoint); |
|
52
|
|
} |
|
53
|
|
|
|
54
|
|
@Override |
|
55
|
|
public Vec2D getAnchorPoint() { |
|
56
|
1
1. getAnchorPoint : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getAnchorPoint → KILLED
|
return anchorPoint; |
|
57
|
|
} |
|
58
|
|
|
|
59
|
|
@Override |
|
60
|
|
public BoundingBox getTextureBoundingBox() { |
|
61
|
|
Vec2D textureOrigin = this.getAnchorOffset(Vec2D.zero()); |
|
62
|
1
1. getTextureBoundingBox : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getTextureBoundingBox → KILLED
|
return new BoundingBox(textureOrigin, this.width, this.height); |
|
63
|
|
} |
|
64
|
|
|
|
65
|
|
@Override |
|
66
|
|
public Color getColorAt(int x, int y) { |
|
67
|
2
1. getColorAt : Replaced integer multiplication with division → KILLED
2. getColorAt : Replaced integer addition with subtraction → KILLED
|
int pixel = x + y * width; |
|
68
|
1
1. getColorAt : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getColorAt → KILLED
|
return this.pixels[pixel]; |
|
69
|
|
} |
|
70
|
|
|
|
71
|
|
public StaticTexture rotateLeft() { |
|
72
|
|
Color[] newPixels = rotatePixels(true); |
|
73
|
|
|
|
74
|
|
double angle = Math.PI / 2; |
|
75
|
1
1. rotateLeft : Replaced integer subtraction with addition → KILLED
|
Vec2D widthVector = new Vec2D(0, this.width - 1); |
|
76
|
|
Vec2D newAnchorPoint = this.anchorPoint.rotate(angle).add(widthVector); |
|
77
|
|
|
|
78
|
1
1. rotateLeft : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::rotateLeft → KILLED
|
return new StaticTexture(this.height, this.width, newAnchorPoint, newPixels); |
|
79
|
|
} |
|
80
|
|
|
|
81
|
|
public StaticTexture rotateRight() { |
|
82
|
|
Color[] newPixels = rotatePixels(false); |
|
83
|
|
|
|
84
|
|
double angle = -Math.PI / 2; |
|
85
|
1
1. rotateRight : Replaced integer subtraction with addition → KILLED
|
Vec2D heightVector = new Vec2D(this.height - 1, 0); |
|
86
|
|
Vec2D newAnchorPoint = this.anchorPoint.rotate(angle).add(heightVector); |
|
87
|
|
|
|
88
|
1
1. rotateRight : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::rotateRight → KILLED
|
return new StaticTexture(this.height, this.width, newAnchorPoint, newPixels); |
|
89
|
|
} |
|
90
|
|
|
|
91
|
|
public StaticTexture flipVertically() { |
|
92
|
|
Color[] newPixels = flipPixels(false); |
|
93
|
|
|
|
94
|
1
1. flipVertically : Replaced double subtraction with addition → KILLED
|
double distanceToBottom = height - this.anchorPoint.getY(); |
|
95
|
|
Vec2D newAnchorPoint = this.anchorPoint.setY(distanceToBottom); |
|
96
|
|
|
|
97
|
1
1. flipVertically : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::flipVertically → KILLED
|
return new StaticTexture(this.width, this.height, newAnchorPoint, newPixels); |
|
98
|
|
} |
|
99
|
|
|
|
100
|
|
public StaticTexture flipHorizontally() { |
|
101
|
|
Color[] newPixels = flipPixels(true); |
|
102
|
|
|
|
103
|
1
1. flipHorizontally : Replaced double subtraction with addition → KILLED
|
double distanceToRight = width - this.anchorPoint.getX(); |
|
104
|
|
Vec2D newAnchorPoint = this.anchorPoint.setX(distanceToRight); |
|
105
|
|
|
|
106
|
1
1. flipHorizontally : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::flipHorizontally → KILLED
|
return new StaticTexture(this.width, this.height, newAnchorPoint, newPixels); |
|
107
|
|
} |
|
108
|
|
|
|
109
|
|
private Color[] flipPixels(boolean horizontal) { |
|
110
|
|
java.util.List<Color> newPixels = new ArrayList<>(this.pixels.length); |
|
111
|
|
|
|
112
|
4
1. flipPixels : changed conditional boundary → KILLED
2. flipPixels : Changed increment from -1 to 1 → KILLED
3. flipPixels : Replaced integer subtraction with addition → KILLED
4. flipPixels : negated conditional → KILLED
|
for (int y = height - 1; y >= 0; y--) { |
|
113
|
3
1. flipPixels : changed conditional boundary → KILLED
2. flipPixels : Changed increment from 1 to -1 → KILLED
3. flipPixels : negated conditional → KILLED
|
for (int x = 0; x < width; x++) { |
|
114
|
|
Color color = this.getColorAt(x, y); |
|
115
|
|
newPixels.add(color); |
|
116
|
|
} |
|
117
|
|
} |
|
118
|
|
|
|
119
|
2
1. flipPixels : negated conditional → KILLED
2. flipPixels : removed call to java/util/Collections::reverse → KILLED
|
if (horizontal) Collections.reverse(newPixels); |
|
120
|
1
1. flipPixels : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::flipPixels → KILLED
|
return newPixels.toArray(new Color[0]); |
|
121
|
|
} |
|
122
|
|
|
|
123
|
|
private Color[] rotatePixels(boolean left) { |
|
124
|
|
List<Color> newPixels = new ArrayList<>(this.pixels.length); |
|
125
|
|
|
|
126
|
3
1. rotatePixels : changed conditional boundary → KILLED
2. rotatePixels : Changed increment from 1 to -1 → KILLED
3. rotatePixels : negated conditional → KILLED
|
for (int x = 0; x < width; x++) { |
|
127
|
4
1. rotatePixels : changed conditional boundary → KILLED
2. rotatePixels : Changed increment from -1 to 1 → KILLED
3. rotatePixels : Replaced integer subtraction with addition → KILLED
4. rotatePixels : negated conditional → KILLED
|
for (int y = height - 1; y >= 0; y--) { |
|
128
|
|
Color color = this.getColorAt(x, y); |
|
129
|
|
newPixels.add(color); |
|
130
|
|
} |
|
131
|
|
} |
|
132
|
|
|
|
133
|
2
1. rotatePixels : negated conditional → KILLED
2. rotatePixels : removed call to java/util/Collections::reverse → KILLED
|
if (left) Collections.reverse(newPixels); |
|
134
|
1
1. rotatePixels : replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::rotatePixels → KILLED
|
return newPixels.toArray(new Color[0]); |
|
135
|
|
} |
|
136
|
|
} |
| | Mutations |
| 17 |
|
1.1 Location : <init> Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getColorAt()] Replaced integer multiplication with division → KILLED 2.2 Location : <init> Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getColorAt()] negated conditional → KILLED
|
| 36 |
|
1.1 Location : getWidth Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] replaced int return with 0 for g0803/bindingofshiba/textures/StaticTexture::getWidth → KILLED
|
| 41 |
|
1.1 Location : getHeight Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] replaced int return with 0 for g0803/bindingofshiba/textures/StaticTexture::getHeight → KILLED
|
| 46 |
|
1.1 Location : getAnchorOffset Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getAnchorOffset()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getAnchorOffset → KILLED
|
| 51 |
|
1.1 Location : getAnchorOffset Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getTextureBoundingBox()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getAnchorOffset → KILLED
|
| 56 |
|
1.1 Location : getAnchorPoint Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:copiesPixels()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getAnchorPoint → KILLED
|
| 62 |
|
1.1 Location : getTextureBoundingBox Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getTextureBoundingBox()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getTextureBoundingBox → KILLED
|
| 67 |
|
1.1 Location : getColorAt Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getColorAt()] Replaced integer multiplication with division → KILLED 2.2 Location : getColorAt Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getColorAt()] Replaced integer addition with subtraction → KILLED
|
| 68 |
|
1.1 Location : getColorAt Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:getColorAt()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::getColorAt → KILLED
|
| 75 |
|
1.1 Location : rotateLeft Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] Replaced integer subtraction with addition → KILLED
|
| 78 |
|
1.1 Location : rotateLeft Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::rotateLeft → KILLED
|
| 85 |
|
1.1 Location : rotateRight Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateRight()] Replaced integer subtraction with addition → KILLED
|
| 88 |
|
1.1 Location : rotateRight Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateRight()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::rotateRight → KILLED
|
| 94 |
|
1.1 Location : flipVertically Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipVertically()] Replaced double subtraction with addition → KILLED
|
| 97 |
|
1.1 Location : flipVertically Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipVertically()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::flipVertically → KILLED
|
| 103 |
|
1.1 Location : flipHorizontally Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] Replaced double subtraction with addition → KILLED
|
| 106 |
|
1.1 Location : flipHorizontally Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::flipHorizontally → KILLED
|
| 112 |
|
1.1 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] changed conditional boundary → KILLED 2.2 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] Changed increment from -1 to 1 → KILLED 3.3 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] Replaced integer subtraction with addition → KILLED 4.4 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] negated conditional → KILLED
|
| 113 |
|
1.1 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] changed conditional boundary → KILLED 2.2 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] Changed increment from 1 to -1 → KILLED 3.3 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] negated conditional → KILLED
|
| 119 |
|
1.1 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] negated conditional → KILLED 2.2 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] removed call to java/util/Collections::reverse → KILLED
|
| 120 |
|
1.1 Location : flipPixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:flipHorizontally()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::flipPixels → KILLED
|
| 126 |
|
1.1 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] changed conditional boundary → KILLED 2.2 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] Changed increment from 1 to -1 → KILLED 3.3 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] negated conditional → KILLED
|
| 127 |
|
1.1 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] changed conditional boundary → KILLED 2.2 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] Changed increment from -1 to 1 → KILLED 3.3 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] Replaced integer subtraction with addition → KILLED 4.4 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] negated conditional → KILLED
|
| 133 |
|
1.1 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] negated conditional → KILLED 2.2 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] removed call to java/util/Collections::reverse → KILLED
|
| 134 |
|
1.1 Location : rotatePixels Killed by : g0803.bindingofshiba.textures.StaticTextureTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.textures.StaticTextureTest]/[method:rotateLeft()] replaced return value with null for g0803/bindingofshiba/textures/StaticTexture::rotatePixels → KILLED
|