예제 #1
0
    /**
     * Starts this updater. This method initializes all the necessary resources and puts this {@link
     * Runnable} on the asynch queue. If this updater is not active or is already running, this
     * method just returns.
     */
    public void start() {
      if (!isActive() || isRunning()) return;

      isRunning = true;
      setDirty(false);
      resetTileValues();

      if (!targetSize.equals(thumbnailImageSize)) {
        resetThumbnailImage();
      }

      if (targetSize.isEmpty()) return;

      thumbnailGC =
          new GC(thumbnailImage, sourceFigure.isMirrored() ? SWT.RIGHT_TO_LEFT : SWT.NONE);
      thumbnailGraphics = new ScaledGraphics(new SWTGraphics(thumbnailGC));
      thumbnailGraphics.scale(getScaleX());
      thumbnailGraphics.translate(getSourceRectangle().getLocation().negate());

      Color color = sourceFigure.getForegroundColor();
      if (color != null) thumbnailGraphics.setForegroundColor(color);
      color = sourceFigure.getBackgroundColor();
      if (color != null) thumbnailGraphics.setBackgroundColor(color);
      thumbnailGraphics.setFont(sourceFigure.getFont());

      setScales(
          targetSize.width / (float) getSourceRectangle().width,
          targetSize.height / (float) getSourceRectangle().height);

      Display.getCurrent().asyncExec(this);
    }