Exemplo n.º 1
0
 private static void paintLayer(
     Graphics2D g, String layerName, Layers layers, WmsRequest request) {
   log.info("painting " + layerName);
   final Layer layer = layers.getLayer(layerName);
   if (layer != null) {
     layer.render(g, request);
     log.info("finished painting " + layerName);
   } else log.warn("no paintImage implementation for layer: " + layerName);
 }
Exemplo n.º 2
0
 /**
  * Render a section of the tile map
  *
  * @param x The x location to render at
  * @param y The y location to render at
  * @param sx The x tile location to start rendering
  * @param sy The y tile location to start rendering
  * @param width The width of the section to render (in tiles)
  * @param height The height of the secton to render (in tiles)
  * @param lineByLine True if we should render line by line, i.e. giving us a chance to render
  *     something else between lines (@see {@link #renderedLine(int, int, int)}
  */
 public void render(int x, int y, int sx, int sy, int width, int height, boolean lineByLine) {
   switch (orientation) {
     case ORTHOGONAL:
       for (int ty = 0; ty < height; ty++) {
         for (int i = 0; i < layers.size(); i++) {
           Layer layer = (Layer) layers.get(i);
           layer.render(x, y, sx, sy, width, ty, lineByLine, tileWidth, tileHeight);
         }
       }
       break;
     case ISOMETRIC:
       renderIsometricMap(x, y, sx, sy, width, height, null, lineByLine);
       break;
     default:
       // log error or something
   }
 }
Exemplo n.º 3
0
  /**
   * Render of isometric map renders.
   *
   * @param x The x location to render at
   * @param y The y location to render at
   * @param sx The x tile location to start rendering
   * @param sy The y tile location to start rendering
   * @param width The width of the section to render (in tiles)
   * @param height The height of the section to render (in tiles)
   * @param layer if this is null all layers are rendered, if not only the selected layer is
   *     renderered
   * @param lineByLine True if we should render line by line, i.e. giving us a chance to render
   *     something else between lines (@see {@link #renderedLine(int, int, int)}
   *     <p>TODO: [Isometric map] Render stuff between lines, concept of line differs from ortho
   *     maps
   */
  protected void renderIsometricMap(
      int x, int y, int sx, int sy, int width, int height, Layer layer, boolean lineByLine) {
    ArrayList drawLayers = layers;
    if (layer != null) {
      drawLayers = new ArrayList();
      drawLayers.add(layer);
    }

    int maxCount = width * height;
    int allCount = 0;

    boolean allProcessed = false;

    int initialLineX = x;
    int initialLineY = y;

    int startLineTileX = 0;
    int startLineTileY = 0;
    while (!allProcessed) {

      int currentTileX = startLineTileX;
      int currentTileY = startLineTileY;
      int currentLineX = initialLineX;

      int min = 0;
      if (height > width)
        min =
            (startLineTileY < width - 1)
                ? startLineTileY
                : (width - currentTileX < height) ? width - currentTileX - 1 : width - 1;
      else
        min =
            (startLineTileY < height - 1)
                ? startLineTileY
                : (width - currentTileX < height) ? width - currentTileX - 1 : height - 1;

      for (int burner = 0; burner <= min; currentTileX++, currentTileY--, burner++) {
        for (int layerIdx = 0; layerIdx < drawLayers.size(); layerIdx++) {
          Layer currentLayer = (Layer) drawLayers.get(layerIdx);
          currentLayer.render(
              currentLineX,
              initialLineY,
              currentTileX,
              currentTileY,
              1,
              0,
              lineByLine,
              tileWidth,
              tileHeight);
        }
        currentLineX += tileWidth;

        allCount++;
      }

      if (startLineTileY < (height - 1)) {
        startLineTileY += 1;
        initialLineX -= tileWidth / 2;
        initialLineY += tileHeight / 2;
      } else {
        startLineTileX += 1;
        initialLineX += tileWidth / 2;
        initialLineY += tileHeight / 2;
      }

      if (allCount >= maxCount) allProcessed = true;
    }
  }