/*
 * Copyright 2000-2012 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.designer.designSurface.selection;

import com.intellij.designer.designSurface.ComponentDecorator;
import com.intellij.designer.designSurface.DecorationLayer;
import com.intellij.designer.designSurface.tools.InputTool;
import com.intellij.designer.model.RadComponent;

import java.awt.*;

/**
 * @author Alexander Lobas
 */
public abstract class ResizePoint extends ComponentDecorator {
  private static final int DEFAULT_SIZE = 5;
  private final Color myColor;
  private final Color myBorder;

  public ResizePoint() {
    this(Color.GREEN, Color.BLACK);
  }

  public ResizePoint(Color color, Color border) {
    myColor = color;
    myBorder = border;
  }

  @Override
  public InputTool findTargetTool(DecorationLayer layer, RadComponent component, int x, int y) {
    Point location = getLocation(layer, component);
    Rectangle bounds = new Rectangle(location.x, location.y, getSize(), getSize());

    if (bounds.contains(x, y)) {
      return createTool(component);
    }

    return null;
  }

  @Override
  protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
    Point location = getLocation(layer, component);

    g.setColor(myColor);
    g.fillRect(location.x, location.y, getSize(), getSize());

    g.setColor(myBorder);
    g.drawRect(location.x, location.y, getSize(), getSize());
  }

  public abstract Object getType();

  protected abstract InputTool createTool(RadComponent component);

  protected abstract Point getLocation(DecorationLayer layer, RadComponent component);

  protected int getSize() {
    return DEFAULT_SIZE;
  }
}
@@ -1515,24 +1515,151 @@
  getSize());
+%0A    int neighborhood = getNeighborhoodSize();%0A    if (neighborhood %3E 0) %7B%0A      bounds.grow(neighborhood, neighborhood);%0A    %7D
 %0A%0A    if (bo
@@ -2328,9 +2328,280 @@
 ZE;%0A  %7D%0A
-%7D
+%0A  /**%0A   * Additional space range around the resize point that will also be considered a match.%0A   * This lets you get near but not necessarily right on top of the resize point in order%0A   * to act on it.%0A   */%0A  protected int getNeighborhoodSize() %7B%0A    return 0;%0A  %7D%0A%7D%0A

Make resize point matching more tolerant