Note that I'm still using PlayN 1.9 - this may not work correctly in 2.0!
What I have done when I'm confused about where a layer is gone off to, is to paint it completely with a colour. This way, if the reason why I'm not seeing it is accidentally painting stuff outside of the image, I can see where the image is actually at, at least.
Additionally, and I think this is more in line with what you're suggesting, I've added a name attribute to the AbstractLayer class and changed its toString to print it. Each of my classes handling layers will set their own name on it. When stopping on a breakpoint I can see the tree of named GroupLayers, their contents and each element's transformation values in the debugger.
This is needed in Layer.java:
public void setName(String layerName);
This is needed in AbstractLayer.java (note that the toString method already exists, replace it):
private String name;
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String toString () {
StringBuilder bldr = new StringBuilder();
if(name != null)
bldr.append(name);
else
{
String cname = getClass().getName();
bldr.append(cname.substring(cname.lastIndexOf(".")+1));
}
bldr.append(" [hashCode=").append(hashCode());
bldr.append(", tx=").append(transform());
if (hitTester != null) bldr.append(", hitTester=").append(hitTester);
return bldr.toString();
}
If this doesn't help me, I add calls to print out the layer structure of the root or a lower layer at given points in the code using this:
public class LayerUtil
{
public static void printLayerStructure()
{
GroupLayer root = graphics().rootLayer();
StringBuilder s = new StringBuilder();
s.append("Root\n");
for(int i = 0; i < root.size(); i++)
{
printLayerStructure(s, root.get(i), 1);
}
System.out.println(s);
}
public static void printLayerStructure(StringBuilder s, Layer l, int indent)
{
if(l instanceof GroupLayerGL || l instanceof ImageLayerGL)
{
for(int i = 0; i < indent; i++)
s.append(" ");
s.append(l.toString());
s.append("\n");
}
if(l instanceof GroupLayerGL)
{
GroupLayerGL g = (GroupLayerGL)l;
for(int i = 0; i < g.size(); i++)
{
printLayerStructure(s, g.get(i), indent + 1);
}
}
}
}
It will output stuff such as this below. You may want to fiddle with the toString method to get an output you can most easily read.
Root
MenuScreenGroup [hashCode=487694075, tx=affine [+1.0 +0.0 +0.0 +1.0 +0.0+0.0]
MenuScreenLayer [hashCode=76432244, tx=affine [+1.0 +0.0 +0.0 +1.0 +0.0+0.0]
StatusLayer [hashCode=1030228826, tx=affine [+1.0 +0.0 +0.0 +1.0 +736.0+0.0]
LoadingScreenGroup [hashCode=1264413185, tx=affine [+1.0 +0.0 +0.0 +1.0 +0.0+0.0]
LoadingScreen [hashCode=1243806178, tx=affine [+1.0 +0.0 +0.0 +1.0 +0.0+0.0]
Hope it helps!