Skip to content

Commit

Permalink
Fix clipping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hube12 committed Nov 25, 2022
1 parent 7aaeed2 commit b42a8fb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G

version=1.0.24
version=1.0.25

lwjglVersion=3.3.1

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/seedfinding/minemap/ui/map/MapPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public void paintComponent(Graphics graphics) {
}

public void drawMap(Graphics graphics) {

long start = System.nanoTime();
Map<Fragment, DrawInfo> drawQueue = this.getDrawQueue();
if (MineMap.DEBUG) System.out.println("Draw queue " + " " + (System.nanoTime() - start));
Expand Down Expand Up @@ -209,7 +208,10 @@ public Map<Fragment, DrawInfo> getDrawQueue() {

public BufferedImage getScreenshot() {
BufferedImage image = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB);
this.drawMap(image.getGraphics());
Graphics graphics=image.getGraphics();
// Because this has no idea what the clip is, see #14
graphics.setClip(0,0,this.getWidth(),this.getHeight());
this.drawMap(graphics);
return image;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,17 @@ public void render(Graphics graphics, DrawInfo info, Feature<?, ?> feature, Frag
int posX = (int) (info.x + sx + (DEFAULT_VALUE - 16) * scaleFactor / 2);
int posY = (int) (info.y + sy - (DEFAULT_VALUE + 16) * scaleFactor / 2);
Shape oldClip = g2d.getClip();
if (oldClip.contains(posX - 5, posY - 5)) {
if (oldClip != null && oldClip.contains(posX - 5, posY - 5)) {
Color oldColor = g2d.getColor();
int size = (int) (16 * scaleFactor);
g2d.setClip(new Ellipse2D.Float(posX, posY, size, size));
g2d.setColor(extraIcon.getFirst());
g2d.fillRect(posX, posY, size, size);
int offset = Math.max(1, (int) (2 * scaleFactor));
paintImage(extraIcon.getSecond(), g2d, 12, new Pair<>(scaleFactor, scaleFactor), new Pair<>(posX + offset, posY + offset), false);
g2d.setClip(oldClip);
g2d.setColor(oldColor);
g2d.setClip(oldClip);
}

}
}
}
Expand Down

0 comments on commit b42a8fb

Please sign in to comment.