Пример #1
0
  /** Overrides <code>Graphics.drawImage</code>. */
  public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info.log(toShortString() + " Drawing image: " + img + " at: " + new Point(x, y));
    }

    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawImage(img, x, y, observer);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      int i, count = (info.flashCount * 2) - 1;
      ImageProducer oldProducer = img.getSource();
      ImageProducer newProducer =
          new FilteredImageSource(oldProducer, new DebugGraphicsFilter(info.flashColor));
      Image newImage = Toolkit.getDefaultToolkit().createImage(newProducer);
      DebugGraphicsObserver imageObserver = new DebugGraphicsObserver();

      Image imageToDraw;
      for (i = 0; i < count; i++) {
        imageToDraw = (i % 2) == 0 ? newImage : img;
        loadImage(imageToDraw);
        graphics.drawImage(imageToDraw, x, y, imageObserver);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
    }
    return graphics.drawImage(img, x, y, observer);
  }
Пример #2
0
 /** Static wrapper method for DebugGraphicsInfo.getDebugOptions(). */
 static int getDebugOptions(JComponent component) {
   DebugGraphicsInfo debugGraphicsInfo = info();
   if (debugGraphicsInfo == null) {
     return 0;
   } else {
     return debugGraphicsInfo.getDebugOptions(component);
   }
 }
Пример #3
0
  /** Overrides <code>Graphics.drawImage</code>. */
  public boolean drawImage(
      Image img,
      int dx1,
      int dy1,
      int dx2,
      int dy2,
      int sx1,
      int sy1,
      int sx2,
      int sy2,
      Color bgcolor,
      ImageObserver observer) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info.log(
          toShortString()
              + " Drawing image: "
              + img
              + " destination: "
              + new Rectangle(dx1, dy1, dx2, dy2)
              + " source: "
              + new Rectangle(sx1, sy1, sx2, sy2)
              + ", bgcolor: "
              + bgcolor);
    }

    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      int i, count = (info.flashCount * 2) - 1;
      ImageProducer oldProducer = img.getSource();
      ImageProducer newProducer =
          new FilteredImageSource(oldProducer, new DebugGraphicsFilter(info.flashColor));
      Image newImage = Toolkit.getDefaultToolkit().createImage(newProducer);
      DebugGraphicsObserver imageObserver = new DebugGraphicsObserver();

      Image imageToDraw;
      for (i = 0; i < count; i++) {
        imageToDraw = (i % 2) == 0 ? newImage : img;
        loadImage(imageToDraw);
        graphics.drawImage(
            imageToDraw, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, imageObserver);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
    }
    return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
  }
Пример #4
0
  /**
   * Returns non-zero if <b>component</b> should display with DebugGraphics, zero otherwise. Walks
   * the JComponent's parent tree to determine if any debugging options have been set.
   */
  static int shouldComponentDebug(JComponent component) {
    DebugGraphicsInfo info = info();
    if (info == null) {
      return 0;
    } else {
      Container container = (Container) component;
      int debugOptions = 0;

      while (container != null && (container instanceof JComponent)) {
        debugOptions |= info.getDebugOptions((JComponent) container);
        container = container.getParent();
      }

      return debugOptions;
    }
  }
Пример #5
0
  /** Returns a DebugGraphics for use in buffering window. */
  private Graphics debugGraphics() {
    DebugGraphics debugGraphics;
    DebugGraphicsInfo info = info();
    JFrame debugFrame;

    if (info.debugFrame == null) {
      info.debugFrame = new JFrame();
      info.debugFrame.setSize(500, 500);
    }
    debugFrame = info.debugFrame;
    debugFrame.show();
    debugGraphics = new DebugGraphics(debugFrame.getGraphics());
    debugGraphics.setFont(getFont());
    debugGraphics.setColor(getColor());
    debugGraphics.translate(xOffset, yOffset);
    debugGraphics.setClip(getClipBounds());
    if (debugFlash()) {
      debugGraphics.setDebugOptions(FLASH_OPTION);
    }
    return debugGraphics;
  }