int[] range = layerToRange (getObjectForLayer (layer)); if (range[0] == range[1]) return 0; else return (range[1] - range[0]);
Component[] components = getComponents(); int count = 0; for (int i = components.length - 1; i >= 0; --i) { if (getLayer(components[i]) == layer) count++; } return count;
  public int getComponentCountInLayer(int layer)  {    int[] range = layerToRange (getObjectForLayer (layer));    if (range[0] == range[1])	    return 0;    else	    return (range[1] - range[0]);  }