protected List<Layer> organizeBackgroundLayers(List<Layer> layers){
  if (isForegroundUnderBackgroundLayer(layers)) {
    List<Layer> fLayers=new ArrayList<Layer>(layers.size());
    List<Layer> bLayers=new ArrayList<Layer>(layers.size());
    for (    Layer layer : layers) {
      if (layer != null) {
        if (layer.getAddAsBackground()) {
          bLayers.add(layer);
        }
 else {
          fLayers.add(layer);
        }
      }
    }
    fLayers.addAll(bLayers);
    return fLayers;
  }
 else {
    return layers;
  }
}

protected List < Layer > organizeBackgroundLayers ( List < Layer > layers ) { if ( isForegroundUnderBackgroundLayer ( layers ) ) { List < Layer > fLayers = new ArrayList < Layer > ( layers . size ( ) ) ; List < Layer > bLayers = new ArrayList < Layer > ( layers . size ( ) ) ; for ( Layer layer : layers ) { if ( layer != null ) { if ( layer . getAddAsBackground ( ) ) { bLayers . add ( layer ) ; } else { fLayers . add ( layer ) ; } } } fLayers . addAll ( bLayers ) ; return fLayers ; } else { return layers ; } }
does the check to see of foreground layers are below background layers , and then iterates through the layer [ ] switching layers around until they are in the appropriate order .
