In doing some cleanup and doc work, I noticed this subtle problem that
shows up in several places:
PCamera.java:
protected void paintCameraView(final PPaintContext paintContext) {
// todo: this method is implemented inconsistently with
regards to non-final methods
// a subclass might override getLayerCount and/or getLayer,
thus this method should either
// use layers.size() and layers.get(index) or
getLayerCount() and getLayer(index)
final int count = getLayerCount();
for (int i = 0; i < count; i++) {
final PLayer each = (PLayer) layers.get(i);
each.fullPaint(paintContext);
}
}
for instance, a subclass of PCamera that duplicates a layer reference
for some reason
class MyCamera extends PCamera {
final PLayer duplicate = ...;
public int getLayerCount() {
return super.getLayerCount() + 5;
}
public PLayer getLayer(final int index) {
if (index >= getLayerCount()) { throw new
IndexOutOfBoundsException("..."); }
if (index >= super.getLayerCount()) { return duplicate; }
return super.getLayer(index);
}
}
will have broken behavior in paintCameraView above and other methods.
I'll probably commit with the todo message later tonight.
michael
--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---