int[] range = layerToRange (getObjectForLayer (layer)); if (range[0] == range[1]) return new Component[0]; else
Component[] inLayer = new Component[getComponentCountInLayer(layer)]; Component[] components = getComponents(); int j = 0; for (int i = 0; i < components.length; ++i) { if (layer == getLayer(components[i]))
  public Component[] getComponentsInLayer(int layer)  {    int[] range = layerToRange (getObjectForLayer (layer));    if (range[0] == range[1])	    return new Component[0];    else	    {        Component[] comps = getComponents ();        int sz = range[1] - range[0];        Component[] nc = new Component[sz];        for (int i = 0; i < sz; ++i)          nc[i] = comps[range[0] + i];        return nc;	    }  }