Пример #1
0
  /**
   * Returns a polygon framing the specified scene footprint.
   *
   * @param x the x tile coordinate of the "upper-left" of the footprint.
   * @param y the y tile coordinate of the "upper-left" of the footprint.
   * @param width the width in tiles of the footprint.
   * @param height the height in tiles of the footprint.
   */
  public static Polygon getFootprintPolygon(
      MisoSceneMetrics metrics, int x, int y, int width, int height) {
    SmartPolygon footprint = new SmartPolygon();
    Point tpos = MisoUtil.tileToScreen(metrics, x, y, new Point());

    // start with top-center point
    int rx = tpos.x + metrics.tilehwid, ry = tpos.y;
    footprint.addPoint(rx, ry);
    // right point
    rx += width * metrics.tilehwid;
    ry += width * metrics.tilehhei;
    footprint.addPoint(rx, ry);
    // bottom-center point
    rx -= height * metrics.tilehwid;
    ry += height * metrics.tilehhei;
    footprint.addPoint(rx, ry);
    // left point
    rx -= width * metrics.tilehwid;
    ry -= width * metrics.tilehhei;
    footprint.addPoint(rx, ry);
    // end with top-center point
    rx += height * metrics.tilehwid;
    ry -= height * metrics.tilehhei;
    footprint.addPoint(rx, ry);

    return footprint;
  }