Пример #1
0
  /**
   * returns the set of the selection items corresponding to a resize selection level and for the
   * elements and the covered area
   *
   * @param handle a svg handle
   * @param elements a set of elements
   * @param area the union of the bounds of the elements
   * @return the set of the selection items corresponding to a resize selection level and for the
   *     elements and the covered area
   */
  public Set<SelectionItem> getResizeSelectionItems(
      SVGHandle handle, Set<Element> elements, Rectangle2D area) {

    // the set of the selection items that will be returned
    Set<SelectionItem> items = new HashSet<SelectionItem>();

    // creating the items
    SelectionItem item =
        new SelectionItem(
            handle,
            elements,
            new Point((int) area.getCenterX(), (int) area.getY()),
            SelectionItem.NORTH,
            SelectionItem.ARROW_STYLE,
            0,
            false,
            null);
    items.add(item);

    items.add(
        new SelectionItem(
            handle,
            elements,
            new Point((int) area.getCenterX(), (int) area.getMaxY()),
            SelectionItem.SOUTH,
            SelectionItem.ARROW_STYLE,
            0,
            false,
            null));

    items.add(
        new SelectionItem(
            handle,
            elements,
            new Point((int) area.getMaxX(), (int) area.getCenterY()),
            SelectionItem.EAST,
            SelectionItem.ARROW_STYLE,
            0,
            false,
            null));

    items.add(
        new SelectionItem(
            handle,
            elements,
            new Point((int) area.getX(), (int) area.getCenterY()),
            SelectionItem.WEST,
            SelectionItem.ARROW_STYLE,
            0,
            false,
            null));

    if (area.getWidth() > item.getShapeBounds().width
        && area.getHeight() > item.getShapeBounds().height) {

      items.add(
          new SelectionItem(
              handle,
              elements,
              new Point((int) area.getX(), (int) area.getY()),
              SelectionItem.NORTH_WEST,
              SelectionItem.OBLIQUE_ARROW_STYLE,
              0,
              false,
              null));

      items.add(
          new SelectionItem(
              handle,
              elements,
              new Point((int) area.getMaxX(), (int) area.getMaxY()),
              SelectionItem.SOUTH_EAST,
              SelectionItem.OBLIQUE_ARROW_STYLE,
              0,
              false,
              null));

      items.add(
          new SelectionItem(
              handle,
              elements,
              new Point((int) area.getMaxX(), (int) area.getY()),
              SelectionItem.NORTH_EAST,
              SelectionItem.OBLIQUE_ARROW_STYLE,
              0,
              false,
              null));

      items.add(
          new SelectionItem(
              handle,
              elements,
              new Point((int) area.getX(), (int) area.getMaxY()),
              SelectionItem.SOUTH_WEST,
              SelectionItem.OBLIQUE_ARROW_STYLE,
              0,
              false,
              null));
    }

    return items;
  }