예제 #1
0
  protected void drawBlockInPlace(TileBlock[] blocks, WritableRaster wr) {
    // System.out.println("Ending Splits: " + blocks.length);

    for (int i = 0; i < blocks.length; i++) {
      TileBlock curr = blocks[i];

      // System.out.println("Block " + i + ":\n" + curr);

      int xloc = curr.getXLoc() * tileWidth + tileGridXOff;
      int yloc = curr.getYLoc() * tileHeight + tileGridYOff;
      Rectangle tb =
          new Rectangle(xloc, yloc, curr.getWidth() * tileWidth, curr.getHeight() * tileHeight);
      tb = tb.intersection(bounds);

      WritableRaster child =
          wr.createWritableChild(tb.x, tb.y, tb.width, tb.height, tb.x, tb.y, null);
      // System.out.println("Computing : " + child);
      genRect(child);

      if (Thread.currentThread().isInterrupted()) return;
    }
  }
예제 #2
0
  protected void drawBlockAndCopy(TileBlock[] blocks, WritableRaster wr) {
    if (blocks.length == 1) {
      TileBlock curr = blocks[0];
      int xloc = curr.getXLoc() * tileWidth + tileGridXOff;
      int yloc = curr.getYLoc() * tileHeight + tileGridYOff;
      if ((xloc == wr.getMinX()) && (yloc == wr.getMinY())) {
        // Safe to draw in place...
        drawBlockInPlace(blocks, wr);
        return;
      }
    }

    int maxSz = 0;
    for (int i = 0; i < blocks.length; i++) {
      int sz = ((blocks[i].getWidth() * tileWidth) * (blocks[i].getHeight() * tileHeight));
      if (sz > maxSz) maxSz = sz;
    }
    DataBufferInt dbi = new DataBufferInt(maxSz);
    int[] masks = {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000};
    boolean use_INT_PACK = GraphicsUtil.is_INT_PACK_Data(wr.getSampleModel(), false);

    for (int i = 0; i < blocks.length; i++) {
      TileBlock curr = blocks[i];
      int xloc = curr.getXLoc() * tileWidth + tileGridXOff;
      int yloc = curr.getYLoc() * tileHeight + tileGridYOff;
      Rectangle tb =
          new Rectangle(xloc, yloc, curr.getWidth() * tileWidth, curr.getHeight() * tileHeight);
      tb = tb.intersection(bounds);
      Point loc = new Point(tb.x, tb.y);
      WritableRaster child =
          Raster.createPackedRaster(dbi, tb.width, tb.height, tb.width, masks, loc);
      genRect(child);
      if (use_INT_PACK) GraphicsUtil.copyData_INT_PACK(child, wr);
      else GraphicsUtil.copyData_FALLBACK(child, wr);

      if (Thread.currentThread().isInterrupted()) return;
    }
  }
예제 #3
0
  protected void drawBlock(TileBlock block, WritableRaster wr) {
    TileBlock[] blocks = block.getBestSplit();
    if (blocks == null) return;

    drawBlockInPlace(blocks, wr);
  }