Exemple #1
0
  public ViewPort getTileViewPort(ViewPort viewPort, int tileNr)
      throws NoninvertibleTransformException {
    /*
     * if(viewPortList == null) this.calcViewPort(viewPort); return
     * viewPortList[tileNr];
     */

    if (tile.length == 1) return viewPort;

    double[] dstPts = new double[8];
    double[] srcPts = getTilePts(tileNr);
    Rectangle tile = getTile(tileNr);
    // Rectangle newRect = new Rectangle((int)srcPts[0], (int)srcPts[1],
    // tileSz[0], tileSz[1]);

    mat.inverseTransform(srcPts, 0, dstPts, 0, 4);
    double x = dstPts[0], w = dstPts[2] - dstPts[0];
    double y = dstPts[1], h = dstPts[5] - dstPts[3];
    if (w < 0) {
      x = dstPts[2];
      w = dstPts[0] - dstPts[2];
    }
    if (h < 0) {
      y = dstPts[5];
      h = dstPts[3] - dstPts[5];
    }
    Rectangle2D.Double rectCuadricula = new Rectangle2D.Double(x, y, w, h);
    // Extent extent = new Extent(rectCuadricula);

    ViewPort vp = viewPort.cloneViewPort();
    vp.setImageSize(tile.getSize());
    // vp.setOffset(tile.getLocation());
    vp.setExtent(rectCuadricula);
    vp.setAffineTransform(mat);

    if (debug)
      System.out.println(
          "Tiling.print(): tile "
              + tileNr
              + " de "
              + getNumTiles()
              + "\n, Extent = "
              + vp.getAdjustedExtent()
              + " tile: "
              + tile);

    return vp;
  }