Beispiel #1
0
  /**
   * Move layer to anotger location
   *
   * @param newBounds new bounds for this layer
   * @param x New 'x' coordinate of the layer's origin
   * @param y New 'y' coordinate of the layer's origin
   * @param w New width of the layer
   * @param h New height of the layer
   * @return true if successful, false otherwise
   */
  public boolean relocateLayer(CLayer layer, int x, int y, int w, int h) {

    if (layer != null) {
      synchronized (layers) {
        if (sweepLayer(layer) != null) {
          if (CGraphicsQ.DEBUG) {
            System.err.println("Relocate Layer: " + layer);
          }
          int[] oldBounds = {layer.bounds[X], layer.bounds[Y], layer.bounds[W], layer.bounds[H]};

          if (oldBounds[X] != x || oldBounds[Y] != y || oldBounds[W] != w || oldBounds[H] != h) {
            layer.setBounds(x, y, w, h);
            layer.addDirtyRegion();
            requestRepaint();
            layer.relocateNotify(oldBounds);
            return true;
          }
        }
      }
    }
    return false;
  }