Revision: 8689
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 3, 2008 07:06 by nickmeinhold
Initial Code
package project;
import java.awt.Image;
import java.io.File;
import javax.imageio.ImageIO;
/**
*
* @author Mihir
*/
public class Item {
private boolean visible;
private String itemtype;
private String tooltip;
private String imgpath;
// added these two for drawing the item (Nick)
private Image image;
private Position pos;
/** Creates a new instance of Item */
public Item() {
pos = new Position(); // added this so position is not null, otherwise throws null pointer exception (Nick)
// please add super(); to all subclasses
}
// added copy constructor for creating a new item to add to the canvas_items array list (Nick)
public Item(Item original) {
this.visible = original.visible;
this.itemtype = new String(original.itemtype);
this.tooltip = new String(original.tooltip);
this.imgpath = new String(original.imgpath);
this.image = original.image;
this.pos = new Position(original.pos);
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public String getItemtype() {
return itemtype;
}
public void setItemtype(String itemtype) {
this.itemtype = itemtype;
}
public String getTooltip() {
return tooltip;
}
public void setTooltip(String tooltip) {
this.tooltip = tooltip;
}
public String getImgpath() {
return imgpath;
}
public void setImgpath(String imgpath) {
this.imgpath = imgpath;
// added this so here so that it's needs to be called once (Nick)
try{
this.image = ImageIO.read(new File (imgpath));
}
catch(Exception e) {
System.out.println("Problem reading iage path" + e);
}
}
// added these next three methods to draw the item (Nick)
public Image getImg() {
return image;
}
public void setPos(int x, int y) {
this.pos.x = x;
this.pos.y = y;
}
Position getPos() {
return this.pos;
}
}
Initial URL
Initial Description
Initial Title
NickMeinholdItem v0.1
Initial Tags
Initial Language
Java