-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditorTileButton.java
More file actions
54 lines (42 loc) · 1.16 KB
/
EditorTileButton.java
File metadata and controls
54 lines (42 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
class EditorTileButton extends JButton {
public static int SIZE = 50;
private int id;
private BufferedImage img;
private String tileSetPath;
public EditorTileButton(int id, BufferedImage img) {
super();
this.id = id;
this.img = img;
}
public EditorTileButton(int id, TileSet ts) {
super();
this.id = id;
this.img = ts.tileSet[id].getTileImage();
tileSetPath = ts.getTileSetImagePath();
loadImage(img);
}
public static void setTileButtonSize(int size) {
SIZE = size;
}
public void loadImage(BufferedImage img) {
this.setBorder(null);
try {
ImageIcon icon = new ImageIcon(img.getScaledInstance(SIZE, SIZE, Image.SCALE_SMOOTH));
this.setIcon(icon);
} catch (Exception e) {
System.out.println("Fehler beim Laden von Bild");
}
}
public BufferedImage getImg() {
return img;
}
public String getTileSetPath() {
return tileSetPath;
}
public int getId() {
return id;
}
}