Ejemplo n.º 1
0
  public void redraw() {
    // update the title of the GUI
    if (getCustomTitle() == null) {
      int id = manager.getWindowIndex(this);
      if (id != 0) setTitle(getTitle() + " (view " + (id + 1) + ")");
      else setTitle(getTitle());
    }

    stepPanZoomAnimation();

    synchronized (imgLock) {
      // redraw the scene
      manager.preRedraw(this);
      manager.redraw(this);

      // copy the image buffer into the JLabel on the JFrame
      Graphics cg = lblCanvas.getGraphics();
      if (cg != null) cg.drawImage(img, 0, 0, null);

      // save a screenshot if one was requested
      if (saveScreenshotName != null) {
        try {
          ImageIO.write(img, "png", new java.io.File(saveScreenshotName));
        } catch (java.io.IOException e) {
          DialogHelper.displayError("Screenshot could not be saved: " + e);
        }
        saveScreenshotName = null;
      }
    }
  }
Ejemplo n.º 2
0
  /** set the height, width, and zoom of this window */
  public void setMySize(int w, int h, float zoom) {
    this.zoom = zoom;
    this.zoom = 1.0f; // ET hack
    this.setBounds(getX(), getY(), w, h);
    w -= reservedWidthRight;
    h -= reservedHeightBottom;
    lblCanvas.setBounds(0, 0, w, h);

    synchronized (imgLock) {
      img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);

      Graphics2D gfx = (Graphics2D) img.getGraphics();
      gfx.setBackground(Color.WHITE);
      gfx.setFont(Constants.FONT_DEFAULT);
      gfx.setComposite(Constants.COMPOSITE_OPAQUE);
    }
  }