예제 #1
0
  void createErrorThumbnail() {
    int shadowSize = LARGE_SHADOWS ? SHADOW_SIZE : SMALL_SHADOW_SIZE;
    int width = getWidth();
    int height = getHeight();
    BufferedImage image =
        new BufferedImage(width + shadowSize, height + shadowSize, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g = image.createGraphics();
    g.setColor(new java.awt.Color(0xfffbfcc6));
    g.fillRect(0, 0, width, height);

    g.dispose();

    ImageOverlay imageOverlay = mCanvas.getImageOverlay();
    boolean drawShadows = imageOverlay == null || imageOverlay.getShowDropShadow();
    if (drawShadows) {
      if (LARGE_SHADOWS) {
        ImageUtils.drawRectangleShadow(
            image, 0, 0, image.getWidth() - SHADOW_SIZE, image.getHeight() - SHADOW_SIZE);
      } else {
        ImageUtils.drawSmallRectangleShadow(
            image,
            0,
            0,
            image.getWidth() - SMALL_SHADOW_SIZE,
            image.getHeight() - SMALL_SHADOW_SIZE);
      }
    }

    mThumbnail = SwtUtils.convertToSwt(mCanvas.getDisplay(), image, true /* transferAlpha */, -1);
  }
예제 #2
0
  /**
   * Sets the new image of the preview and generates a thumbnail
   *
   * @param image the full size image
   */
  void createThumbnail(BufferedImage image) {
    if (image == null) {
      mThumbnail = null;
      return;
    }

    ImageOverlay imageOverlay = mCanvas.getImageOverlay();
    boolean drawShadows = imageOverlay == null || imageOverlay.getShowDropShadow();
    double scale = getWidth() / (double) image.getWidth();
    int shadowSize;
    if (LARGE_SHADOWS) {
      shadowSize = drawShadows ? SHADOW_SIZE : 0;
    } else {
      shadowSize = drawShadows ? SMALL_SHADOW_SIZE : 0;
    }
    if (scale < 1.0) {
      if (LARGE_SHADOWS) {
        image = ImageUtils.scale(image, scale, scale, shadowSize, shadowSize);
        if (drawShadows) {
          ImageUtils.drawRectangleShadow(
              image, 0, 0, image.getWidth() - shadowSize, image.getHeight() - shadowSize);
        }
      } else {
        image = ImageUtils.scale(image, scale, scale, shadowSize, shadowSize);
        if (drawShadows) {
          ImageUtils.drawSmallRectangleShadow(
              image, 0, 0, image.getWidth() - shadowSize, image.getHeight() - shadowSize);
        }
      }
    }

    mThumbnail = SwtUtils.convertToSwt(mCanvas.getDisplay(), image, true /* transferAlpha */, -1);
  }
예제 #3
0
  public void balloonNotify(final Shell shell, final String message) {
    if (toolTip == null) return;
    try {
      if (SwtUtils.isNotUIThread()) {
        SwtUtils.DISPLAY.asyncExec(
            new Runnable() {
              @Override
              public void run() {
                balloonNotify(shell, message);
              }
            });
        return;
      }

      toolTip.setText(shell.getText());
      toolTip.setMessage(message);
      toolTip.setVisible(true);
    } catch (SWTException e) {
    }
  }