Exemple #1
0
  // ---------------------------------------------------------
  private synchronized AffineTransform bufferTransform() {
    AffineTransform r = new AffineTransform();
    for (int i = 0; i < a1.size(); i++) {
      int s1 = a1.get(i);
      Object s2 = a2.get(i);
      Object s3[] = null;
      if (s2 instanceof Object[]) s3 = (Object[]) s2;

      if (s1 == setTransform) {
        r = makeTransform(s2);
      }
      if (s1 == shear) r.shear((Double) s3[0], (Double) s3[1]);
      if (s1 == rotate1) r.rotate((Double) s2);
      if (s1 == rotate2) r.rotate((Double) s3[0], (Double) s3[1], (Double) s3[2]);
      if (s1 == scale1) r.scale((Double) s3[0], (Double) s3[1]);
      if (s1 == translate1) r.translate((Double) s3[0], (Double) s3[1]);
      if (s1 == translate2) r.translate((Integer) s3[0], (Integer) s3[1]);
    }
    return r;
  }
Exemple #2
0
  /**
   * Zoom, preserving the center point on the screen. (When we draw, the center point may be moved
   * in order to maximize the amount of image seen on screen.) *
   */
  void adjustZoom(double z, Point2D cp) {
    if (cp == null) cp = new Point2D.Double(getWidth() / 2, getHeight() / 2);

    Point2D cxt = componentToImage(cp);
    double tx = cp.getX() - cxt.getX() * z;
    double ty = cp.getY() - cxt.getY() * z;

    t = new AffineTransform();
    t.translate(tx, ty);
    t.scale(z, z);

    fit = false;
    repaint();
  }