示例#1
0
  public void adjustmentValueChanged(AdjustmentEvent evt) {
    // chamado quando o usu�rio modifica o valor de uma das
    // barras de rolagem

    int r = redScroll.getValue();
    int g = greenScroll.getValue();
    int b = blueScroll.getValue();
    redLabel.setText(" R = " + r);
    greenLabel.setText(" G = " + g);
    blueLabel.setText(" B = " + b);
    colorCanvas.setBackground(new Color(r, g, b));
    colorCanvas.repaint();
    // Redraw the canvas in its new color.

  } // end adjustmentValueChanged
  protected void loop() throws Exception {
    while (isShowing()) {
      if (!paused) {
        buffer.clear(java.awt.Color.BLACK);
        world.renderScene(buffer);
        world.draw(buffer);

        camera.performMovement();
        buffer.update();
        buffer.display(canvas.getGraphics());
        canvas.repaint();

        if (System.currentTimeMillis() - startTime >= delay) {
          startTime = System.currentTimeMillis();
          wb.update();
        }
      }
      this.requestFocus();
    }
    buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
    buffer.dispose();
    dispose();
    System.exit(0);
  }
示例#3
0
 public void repaint() {
   canvas.repaint();
 }
示例#4
0
  /**
   * Stop the generation of any previous page, and draw the new one.
   *
   * @param page the PDFPage to draw.
   */
  public void showPage(PDFPage page) {
    // stop drawing the previous page
    if (currentPage != null && prevSize != null) {
      currentPage.stop(prevSize.width, prevSize.height, prevClip);
    }

    // set up the new page
    currentPage = page;

    if (page == null) {
      // no page
      currentImage = null;
      clip = null;
      currentXform = null;
      canvas.repaint();
    } else {
      // Reset highlight
      highlight = null;
      boolean resize = false;

      int newW = Math.round(zoomFactor * page.getWidth());
      int newH = Math.round(zoomFactor * page.getHeight());
      // setSize(Math.round(zoomFactor*page.getWidth()), Math.round(zoomFactor*page.getHeight()));

      Point sz = getSize();

      if (sz.x != newW || sz.y != newH) {
        sz.x = newW;
        sz.y = newH;
        resize = true;
      }

      if (sz.x + sz.y == 0) {
        // no image to draw.
        return;
      }

      // calculate the clipping rectangle in page space from the
      // desired clip in screen space.
      Rectangle2D useClip = clip;
      if (clip != null && currentXform != null) {
        useClip = currentXform.createTransformedShape(clip).getBounds2D();
      }

      Dimension pageSize = page.getUnstretchedSize(sz.x, sz.y, useClip);

      ImageInfo info = new ImageInfo(pageSize.width, pageSize.height, useClip, null);

      currentImage = new RefImage(pageSize.width, pageSize.height, BufferedImage.TYPE_INT_ARGB);

      Rectangle rect = new Rectangle(0, 0, pageSize.width, pageSize.height);
      PDFRenderer r =
          new PDFRenderer(
              page, ((BufferedImage) currentImage).createGraphics(), rect, useClip, Color.WHITE);
      page.renderers.put(info, new WeakReference<PDFRenderer>(r));
      // get the new image
      /*currentImage = page.getImage(pageSize.width, pageSize.height,
      useClip, this, true, false);*/

      // calculate the transform from screen to page space
      currentXform = page.getInitialTransform(pageSize.width, pageSize.height, useClip);
      try {
        currentXform = currentXform.createInverse();
      } catch (NoninvertibleTransformException nte) {
        System.out.println("Error inverting page transform!");
        nte.printStackTrace();
      }

      prevClip = useClip;
      prevSize = pageSize;

      r.go(true);
      if (r.getStatus() != Watchable.COMPLETED) return;

      if (resize)
        // Resize triggers repaint
        setSize(
            Math.round(zoomFactor * page.getWidth()), Math.round(zoomFactor * page.getHeight()));
      else {
        EventQueue.invokeLater(
            new Runnable() {

              @Override
              public void run() {
                // canvas.repaint();
              }
            });
      }
    }
  }