You could wrap the image in your own class, which contains appropriate attributes.
Quick and dirty:
class MyImage
{
private String resourceName;
private GImage gImage;
public MyImage(String resourceName,int x, int y){
this.resourceName = resourceName;
this.gImage = new GImage(resourceName,x,y)
}
public String getResourceName()
{
return resourceName;
}
//.
//.
//.
}
public static final String RES_IMG_SUNSET = "sunset.jpg";
//.
//.
//.
MyImage image1 = new MyImage("bar.jpg", 0, 0);
MyImage image2 = new MyImage(RES_IMG_SUNSET, 100, 0);
MyImage image3 = new MyImage("bar.jpg", 200, 0);
if(image2.getResourceName().equals(RES_IMG_SUNSET))
{
}
You might want to have some sort of unique resource names, so you could use normalized, canonical filenames or URI's. Another way would be to define a global constant for these names, as in above example. Of course, GImage must support that format.