Example #1
0
 public void fillSelected(@Nonnull final Map map) {
   final GroupAction action = new GroupAction();
   for (final MapPosition pos : map.getSelectedTiles()) {
     final MapTile tile = map.getTileAt(pos.getX(), pos.getY());
     if (tile != null) {
       paintSelected(pos.getX(), pos.getY(), map, action);
     }
   }
   if (!action.isEmpty()) {
     getHistory().addEntry(action);
   }
 }
  @Override
  public void renderMap(
      @Nonnull Map map, @Nonnull Rectangle viewport, int level, @Nonnull Graphics2D g) {
    int width = map.getWidth();
    int height = map.getHeight();
    int z = map.getZ() - level;
    AffineTransform transform = g.getTransform();

    for (int x = 0; x < width; ++x) {
      for (int y = 0; y < height; ++y) {
        MapTile tile = map.getTileAt(x, y);
        if (tile != null) {
          MapWarpPoint wp = tile.getMapWarpPoint();
          if (wp == null) {
            continue;
          }
          int xdisp = SwingLocation.displayCoordinateX(x + map.getX(), y + map.getY(), z);
          int ydisp = SwingLocation.displayCoordinateY(x + map.getX(), y + map.getY(), z);
          if (viewport.contains(
              (xdisp * getZoom()) + getTranslateX() + (getTileWidth() * getZoom()),
              (ydisp * getZoom()) + getTranslateY() + (getTileHeight() * getZoom()))) {

            g.setColor(Color.RED);
            g.drawString(
                "Warp", xdisp + (int) (XOFFSET * getZoom()), ydisp + (int) (YOFFSET * getZoom()));
            g.drawString(
                "X: " + wp.getXTarget(),
                xdisp + (int) (XOFFSET * getZoom()),
                ydisp + (int) ((YOFFSET + 10) * getZoom()));
            g.drawString(
                "Y: " + wp.getYTarget(),
                xdisp + (int) (XOFFSET * getZoom()),
                ydisp + (int) ((YOFFSET + 20) * getZoom()));
            g.drawString(
                "Z: " + wp.getZTarget(),
                xdisp + (int) (XOFFSET * getZoom()),
                ydisp + (int) ((YOFFSET + 30) * getZoom()));
          }
        }
      }
    }
    g.setTransform(transform);
  }