2014-02-02 18:39:08 -03:00
|
|
|
package com.droidquest.items;
|
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
import com.droidquest.Room;
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.image.BufferedImage;
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public class Square extends Item {
|
|
|
|
private Color color;
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public Square(int X, int Y, Room r, Color c) {
|
|
|
|
x = X;
|
|
|
|
y = Y;
|
|
|
|
room = r;
|
|
|
|
width = 28;
|
|
|
|
height = 28;
|
|
|
|
editable = true;
|
|
|
|
color = c;
|
|
|
|
GenerateIcons();
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public void GenerateIcons() {
|
|
|
|
icons = new ImageIcon[1];
|
|
|
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
|
|
|
Graphics g;
|
|
|
|
try {
|
|
|
|
g = icons[0].getImage().getGraphics();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e) {
|
|
|
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
|
|
|
return;
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
g.setColor(color);
|
|
|
|
g.fillRect(0, 0, 28, 28);
|
|
|
|
currentIcon = icons[0].getImage();
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
|
|
|
}
|