Exemplo n.º 1
0
 @Override
 public void paintChild(MapValues map, GC gc, Location each) {
   // draw semi-transparent background
   gc.setAlpha(196);
   gc.fillOval(each.px - diameter / 2, each.py - diameter / 2, diameter, diameter);
   gc.setAlpha(255);
   // draw image
   gc.drawImage(image, each.px - bounds.width / 2, each.py - bounds.height / 2);
 }
 @Override
 public void paint(GC gc) {
   CanvasViewInfo lastRoot = mViewHierarchy.getRoot();
   if (lastRoot != null) {
     gc.setForeground(mOutlineColor);
     gc.setLineStyle(SwtDrawingStyle.OUTLINE.getLineStyle());
     int oldAlpha = gc.getAlpha();
     gc.setAlpha(SwtDrawingStyle.OUTLINE.getStrokeAlpha());
     drawOutline(gc, lastRoot);
     gc.setAlpha(oldAlpha);
   }
 }
Exemplo n.º 3
0
 /**
  * Draw characters in view range.
  *
  * @param gc
  * @param x
  * @param y
  * @param w
  * @param h
  */
 private void handleDrawRequest(GC gc, int x, int y, int w, int h) {
   int startLine = fTextWidget.getLineIndex(y);
   int endLine = fTextWidget.getLineIndex(y + h - 1);
   if (startLine <= endLine && startLine < fTextWidget.getLineCount()) {
     if (fIsAdvancedGraphicsPresent) {
       int alpha = gc.getAlpha();
       gc.setAlpha(100);
       drawLineRange(gc, startLine, endLine, x, w);
       gc.setAlpha(alpha);
     } else drawLineRange(gc, startLine, endLine, x, w);
   }
 }
Exemplo n.º 4
0
  private AutoCloseable configGC(final GC gc) {
    final int lineStyle = gc.getLineStyle();
    final int alpha = gc.getAlpha();
    final int[] lineDash = gc.getLineDash();

    final Color foreground = gc.getForeground();
    final Color background = gc.getBackground();

    gc.setForeground(this.indentGuide.getColor(styledText));
    gc.setBackground(styledText.getBackground());
    gc.setAlpha(this.indentGuide.getTransparency());
    gc.setLineStyle(SWT.LINE_CUSTOM);
    gc.setLineDash(new int[] {1, 2});
    return new AutoCloseable() {

      @Override
      public void close() throws Exception {
        gc.setForeground(foreground);
        gc.setBackground(background);
        gc.setAlpha(alpha);
        gc.setLineStyle(lineStyle);
        gc.setLineDash(lineDash);
      }
    };
  }
Exemplo n.º 5
0
 /** @param gc */
 private void paintRanges(GC gc, Rectangle bounds) {
   // draw a rectangle for each range
   gc.setAlpha(200);
   for (RangeAnnotation a : items) {
     if (a == selectedAnnotation) {
       continue;
     }
     if (a.isDisposed()) continue;
     int visualLow = toVisualValue(a.getOffset()) + bounds.x;
     int visualHigh = toVisualValue(a.getLength()) + visualLow;
     if (visualLow < bounds.x + HANDLE_SIZE) {
       visualLow = bounds.x + HANDLE_SIZE;
     }
     if (visualHigh > bounds.x + bounds.width - HANDLE_SIZE) {
       visualHigh = bounds.x + bounds.width - HANDLE_SIZE;
     }
     Color fg = a.getForeground();
     if (a == selectedAnnotation) {
       fg = gc.getDevice().getSystemColor(SWT.COLOR_WHITE);
     }
     if (fg == null) {
       fg = getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
     }
     Color bg = a.getBackground();
     if (bg == null) {
       bg = getDisplay().getSystemColor(SWT.COLOR_GRAY);
     }
     gc.setForeground(fg);
     gc.setBackground(bg);
     gc.fillRectangle(visualLow, bounds.y, visualHigh - visualLow, bounds.height - 1);
     gc.drawRectangle(visualLow, bounds.y, visualHigh - visualLow - 1, bounds.height - 1);
   }
   // paint the selected annotation
   if (selectedAnnotation != null) {
     RangeAnnotation a = selectedAnnotation;
     if (a.isDisposed()) return;
     int visualLow = toVisualValue(a.getOffset()) + bounds.x;
     int visualHigh = toVisualValue(a.getLength()) + visualLow;
     if (visualLow < bounds.x + HANDLE_SIZE) {
       visualLow = bounds.x + HANDLE_SIZE;
     }
     if (visualHigh > bounds.x + bounds.width - HANDLE_SIZE) {
       visualHigh = bounds.x + bounds.width - HANDLE_SIZE;
     }
     Color fg = gc.getDevice().getSystemColor(SWT.COLOR_WHITE);
     if (fg == null) {
       fg = getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
     }
     Color bg = a.getBackground();
     if (bg == null) {
       bg = getDisplay().getSystemColor(SWT.COLOR_GRAY);
     }
     gc.setForeground(fg);
     gc.setBackground(bg);
     gc.fillRectangle(visualLow, bounds.y, visualHigh - visualLow, bounds.height - 1);
     gc.drawRectangle(visualLow, bounds.y, visualHigh - visualLow - 1, bounds.height - 1);
   }
 }
Exemplo n.º 6
0
 private void apply(GC gc, SvgGradientStop stop, boolean foreground) {
   Color c = new Color(gc.getDevice(), stop.color.red(), stop.color.green(), stop.color.blue());
   if (foreground) {
     gc.setForeground(c);
   } else {
     gc.setBackground(c);
   }
   c.dispose();
   gc.setAlpha((int) (255 * stop.opacity));
 }
  @Override
  public boolean paint(GC gc, int pass) {
    initColors();

    Map<Area, Double> fill;
    synchronized (this) {
      fill = new HashMap<>(trafficDensity.getRoadSegmentFill());
    }
    int oldAlpha = gc.getAlpha();
    gc.setAlpha(ALPHA);
    for (Map.Entry<Area, Double> entry : fill.entrySet()) {
      int colorIdx = Math.min((int) Math.round(entry.getValue() * COLOR_STEPS), COLOR_STEPS - 1);
      if (colorIdx > 0) {
        gc.setBackground(colors[colorIdx]);
        gc.fillRectangle(entry.getKey().getDrawArea());
      }
    }
    gc.setAlpha(oldAlpha);
    mustRedraw.set(false);
    return false;
  }
Exemplo n.º 8
0
  @Override
  public void paint(GC gc) {
    if (mHoverRect != null) {
      // Translate the hover rectangle (in canvas coordinates) to control
      // coordinates
      int x = mHScale.translate(mHoverRect.x);
      int y = mVScale.translate(mHoverRect.y);
      int w = mHScale.scale(mHoverRect.width);
      int h = mVScale.scale(mHoverRect.height);

      boolean hoverIsSelected = false;
      List<SelectionItem> selections = mCanvas.getSelectionManager().getSelections();
      for (SelectionItem item : selections) {
        if (mHoverRect.equals(item.getViewInfo().getSelectionRect())) {
          hoverIsSelected = true;
          break;
        }
      }

      Color stroke = hoverIsSelected ? mHoverSelectStrokeColor : mHoverStrokeColor;
      Color fill = hoverIsSelected ? mHoverSelectFillColor : mHoverFillColor;

      if (stroke != null) {
        int oldAlpha = gc.getAlpha();
        gc.setForeground(stroke);
        gc.setLineStyle(hoverIsSelected ? HOVER_SELECTION.getLineStyle() : HOVER.getLineStyle());
        gc.setAlpha(hoverIsSelected ? HOVER_SELECTION.getStrokeAlpha() : HOVER.getStrokeAlpha());
        gc.drawRectangle(x, y, w, h);
        gc.setAlpha(oldAlpha);
      }

      if (fill != null) {
        int oldAlpha = gc.getAlpha();
        gc.setAlpha(hoverIsSelected ? HOVER_SELECTION.getFillAlpha() : HOVER.getFillAlpha());
        gc.setBackground(fill);
        gc.fillRectangle(x, y, w, h);
        gc.setAlpha(oldAlpha);
      }
    }
  }
Exemplo n.º 9
0
  private void drawFinalImage(Image swtImage) {
    Display display = getDisplay();
    // this is only done if an overlay image exists

    // create a new image
    Image tmpImage = new Image(display, curPaintArea.width, curPaintArea.height);
    GC tmpGc = new GC(tmpImage);
    tmpGc.setBackground(white);
    tmpGc.fillRectangle(0, 0, curPaintArea.width, curPaintArea.height);
    if (swtImage != null) {
      // set the alpha to the new image
      tmpGc.setAlpha(alpha);
      /*
       * draw the background image into it
       * (this means everything but the overlay image)
       */
      tmpGc.drawImage(swtImage, imageOrigin.x, imageOrigin.y);
      /*
       * set the alpha back to opaque so it doesn't influence the
       * overlay image
       */
      tmpGc.setAlpha(255);
    }
    if (overlayImage != null) {
      // finally draw the overlay image on top
      doOverlayImage(tmpGc);
    }
    // draw the created new image on the pane
    if (gc != null && !gc.isDisposed()) gc.drawImage(tmpImage, imageOrigin.x, imageOrigin.y);

    if (tmpImage != null && !tmpImage.isDisposed()) {
      tmpImage.dispose();
      tmpImage = null;
    }
    if (tmpGc != null && !tmpGc.isDisposed()) {
      tmpGc.dispose();
      tmpGc = null;
    }
  }
Exemplo n.º 10
0
  public void setColor(java.awt.Color color) {
    if (color.equals(_awt_color)) {
      return;
    }

    Color col = new Color(_gc.getDevice(), color.getRed(), color.getGreen(), color.getBlue());
    _gc.setForeground(col);
    _gc.setBackground(col);
    _gc.setAlpha(color.getAlpha());
    if (_color != null) {
      _color.dispose();
    }
    _color = col;
    _awt_color = color;
  }
Exemplo n.º 11
0
  private void paint(PaintEvent event) {
    GC gc = event.gc;

    gc.setAntialias(SWT.ON);
    gc.setLineWidth(1);
    Rectangle rect = getClientArea();
    gc.setClipping(rect);
    gc.setForeground(getForeground());
    gc.setBackground(getForeground());

    Color[] palette = new Color[32];
    for (int i = 0; i < palette.length; i++) {
      float hue = 270.0f * i / (palette.length - 1);
      palette[palette.length - 1 - i] = new Color(Display.getDefault(), new RGB(hue, 1.0f, 1.0f));
      //			gc.setBackground(palette[i]);
      //			gc.fillRectangle(rect.x + i*rect.width/palette.length, rect.y, rect.width/palette.length,
      // 100);
    }

    frame.adjust();

    int x = (int) (rect.x - frame.offsetX);
    int y = (int) (rect.y - frame.offsetY);
    int extent = (int) (Math.min(rect.width, rect.height) * frame.scale);
    treeMap.paint(x, y, extent, gc, curve, palette);

    for (Color color : palette) color.dispose();

    gc.setAlpha(255);
    gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    gc.setLineStyle(SWT.LINE_DASHDOT);
    gc.setLineWidth(1);
    gc.drawRectangle(x - 1, y - 1, extent + 2, extent + 2);

    if (selection.size() > 0) {
      gc.setLineStyle(SWT.LINE_SOLID);
      gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION));
      for (TreeMap subtree : selection) {
        gc.drawRectangle(getItemBounds(subtree));
      }
    }
  }
Exemplo n.º 12
0
  private void paintCanvas(GC gc, int px, int py, int pw, int ph) {
    if (canvas == null || canvas.isDisposed()) return;

    Rectangle r = canvas.getBounds();
    Color b1 = canvas.getBackground();

    gc.setAntialias(SWT.ON);
    gc.setTextAntialias(SWT.ON);

    // Draw selection background:
    if (isSelected()) {
      gc.setBackground(selectedBackground);
      gc.fillRoundRectangle(0, 0, r.width, r.height, CORNER, CORNER);
    } else if (showingHover) {
      int oldAlpha = gc.getAlpha();
      gc.setAlpha(96 * oldAlpha / 255);
      gc.setBackground(selectedBackground);
      gc.fillRoundRectangle(0, 0, r.width, r.height, CORNER, CORNER);
      gc.setAlpha(oldAlpha);
    }

    // Draw edit indicator:
    if (showingEditorHover) {
      int oldAlpha = gc.getAlpha();
      gc.setAlpha(192 * oldAlpha / 255);
      gc.setBackground(b1);
      gc.fillRoundRectangle(
          r.width / 2 + HOVER_SHRINK_H,
          HOVER_SHRINK_V,
          r.width / 2 - HOVER_SHRINK_H - HOVER_SHRINK_H,
          r.height - HOVER_SHRINK_V - HOVER_SHRINK_V,
          HOVER_CORNER,
          HOVER_CORNER);
      gc.setAlpha(oldAlpha);
      //
      //            Control ec = editor == null ? null : editor.getControl();
      //            if (ec != null && !ec.isDisposed()) {
      //                Rectangle eb = ec.getBounds();
      //                gc.setAlpha(192);
      //                gc.setBackground(b1);
      //                gc.fillRoundRectangle(eb.x, eb.y, eb.width, eb.height, 8, 8);
      //                gc.setAlpha(255);
      //            }
    }

    // Draw property name label:
    gc.setForeground(canvas.getForeground());
    gc.setFont(canvas.getFont());
    if (nameLayout != null && !nameLayout.isDisposed()) {
      Rectangle nb = nameLayout.getBounds();
      nameLayout.draw(gc, MARGIN_H, (r.height - nb.height) / 2);
    }

    // Draw property value repsentating image:
    int right = r.width - MARGIN_H;
    if (valueImage != null && !valueImage.isDisposed()) {
      Rectangle ib = valueImage.getBounds();
      int iw, ih;
      if (ib.height > r.height) {
        ih = r.height;
        iw = ib.width * r.height / ib.height;
      } else {
        ih = ib.height;
        iw = ib.width;
      }
      gc.drawImage(valueImage, 0, 0, ib.width, ib.height, right - iw, (r.height - ih) / 2, iw, ih);
      right = right - iw - 3;
    }

    // Draw property value label:
    if (valueLayout != null && !valueLayout.isDisposed()) {
      Rectangle vb = valueLayout.getBounds();
      valueLayout.draw(gc, right - vb.width, (r.height - vb.height) / 2);
    }
  }
    @Override
    public void paintControl(PaintEvent pe) {
      if (mNinePatchedImage == null || mProjection == null) {
        return;
      }

      Point size = getSize();

      // relative scaling
      float ratio = 1.0f;
      float wRatio = ((float) size.x / mSize.x);
      ratio = Math.min(wRatio, ratio);
      float hRatio = ((float) size.y / mSize.y);
      ratio = Math.min(hRatio, ratio);

      int width = Math.round(mSize.x * ratio);
      int height = Math.round(mSize.y * ratio);

      calcPaddings(width, height);

      Rectangle dest = new Rectangle(0, 0, 0, 0);

      GC gc = pe.gc;

      int backgroundLayerWidth = mBackgroundLayer.getImageData().width;
      int backgroundLayerHeight = mBackgroundLayer.getImageData().height;

      int yCount = size.y / backgroundLayerHeight + ((size.y % backgroundLayerHeight) > 0 ? 1 : 0);
      int xCount = size.x / backgroundLayerWidth + ((size.x % backgroundLayerWidth) > 0 ? 1 : 0);

      // draw background layer
      for (int y = 0; y < yCount; y++) {
        for (int x = 0; x < xCount; x++) {
          gc.drawImage(mBackgroundLayer, x * backgroundLayerWidth, y * backgroundLayerHeight);
        }
      }

      // draw the border line
      gc.setAlpha(0x88);
      gc.drawRectangle(0, 0, size.x, size.y);
      gc.setAlpha(0xFF);

      int yLen = mProjection.length;
      int xLen = mProjection[0].length;
      for (int yPos = 0; yPos < yLen; yPos++) {
        for (int xPos = 0; xPos < xLen; xPos++) {
          Projection p = mProjection[yPos][xPos];

          // consider the scale
          dest.x = (int) Math.ceil(p.dest.x * ratio);
          dest.y = (int) Math.ceil(p.dest.y * ratio);
          dest.width = (int) Math.ceil(p.dest.width * ratio);
          dest.height = (int) Math.ceil(p.dest.height * ratio);

          gc.drawImage(
              mNinePatchedImage.getImage(),
              p.src.x,
              p.src.y,
              p.src.width,
              p.src.height,
              (mPadding.x + dest.x),
              (mPadding.y + dest.y),
              dest.width,
              dest.height);

          if (mIsContentAreaShown) {
            gc.drawImage(
                mContentAreaImage,
                p.src.x,
                p.src.y,
                p.src.width,
                p.src.height,
                (mPadding.x + dest.x),
                (mPadding.y + dest.y),
                dest.width,
                dest.height);
          }
        }
      }
    }
Exemplo n.º 14
0
  protected void paintControl(PaintEvent e) {

    long start = System.currentTimeMillis();

    for (int c = 0; c < chan.length; c++) {

      // if (chan[c].tailSize <= 0) {
      // chan[c].stack.popNegate(0);
      // continue;
      // }

      // Go calculate the line
      Object[] result = calculate(c);
      int[] l1 = (int[]) result[0];
      int[] l2 = (int[]) result[1];

      PositionPolyLine(l1);
      PositionPolyLine(l2);
      // System.out.print(System.currentTimeMillis() - start + "-");

      // Draw it
      GC gc = e.gc;
      gc.setForeground(getForeground(c));
      gc.setAdvanced(true);
      gc.setAntialias(SWT.ON);
      gc.setLineWidth(getLineWidth(c));

      // Fade tail
      if (isFade(c)) {
        gc.setAlpha(0);
        double fade = 0;
        double fadeOutStep = (double) 125 / (double) ((getTailSize(c) * (getTailFade(c)) / 100));
        for (int i = 0; i < l1.length - 4; ) {
          fade += (fadeOutStep / 2);
          setAlpha(gc, fade);

          gc.drawLine(l1[i], l1[i + 1], l1[i + 2], l1[i + 3]);
          i += 2;
        }

        for (int i = 0; i < l2.length - 4; ) {
          fade += (fadeOutStep / 2);
          setAlpha(gc, fade);
          gc.drawLine(l2[i], l2[i + 1], l2[i + 2], l2[i + 3]);
          i += 2;
        }

      } else {
        long time = System.nanoTime();
        gc.drawPolyline(l1);
        gc.drawPolyline(l2);
        // System.out.println(System.nanoTime() - time + " nanoseconds");
      }

      // Connects the head with the tail
      if (isConnect(c)
          && !isFade(c)
          && chan[c].originalTailSize == TAILSIZE_MAX
          && l1.length > 0
          && l2.length > 0) {
        gc.drawLine(l2[l2.length - 2], l2[l2.length - 1], l1[0], l1[1]);
      }
    }

    // System.out.println(System.currentTimeMillis() - start + " milliseconds for all channels");

  }
Exemplo n.º 15
0
  /** @param e */
  protected void paintCanvas(PaintEvent e) {
    Rectangle bounds = canvas.getClientArea();

    Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
    GC gc = e.gc;
    gc.setBackground(getBackground());
    gc.fillRectangle(bounds);
    gc.setAntialias(SWT.OFF);
    // paint the edges the same colour as the parent, so that it
    // is apparent that they don't belong to the range of this slider.
    gc.setBackground(getParent().getBackground());
    gc.fillRectangle(bounds.x, bounds.y, HANDLE_SIZE, bounds.height);
    gc.fillRectangle(bounds.x + bounds.width - HANDLE_SIZE, bounds.y, HANDLE_SIZE, bounds.height);

    // the actual area for the range will actually be a few pixels in from the
    // sides so that there will be room for the small arrow handles
    int visualLow = getVisualLow();
    int visualHigh = getVisualHigh();

    gc.setBackground(getForeground());

    paintRanges(gc, bounds);
    gc.setAlpha(100);
    gc.setForeground(getForeground());
    gc.setBackground(getForeground());
    // draw a rectangle for the selected range
    gc.fillRectangle(visualLow + bounds.x, bounds.y, visualHigh - visualLow, bounds.height);
    gc.setForeground(black);
    gc.setBackground(black);

    // draw triangle handles;
    gc.setAlpha(255);
    // the minimum handles
    gc.fillPolygon(
        new int[] {
          visualLow + bounds.x - HANDLE_SIZE,
          bounds.y,
          visualLow + bounds.x,
          bounds.y,
          visualLow + bounds.x,
          bounds.y + HANDLE_SIZE
        });

    gc.fillPolygon(
        new int[] {
          visualLow + bounds.x - HANDLE_SIZE,
          bounds.y + bounds.height,
          visualLow + bounds.x,
          bounds.y + bounds.height,
          visualLow + bounds.x,
          bounds.y + bounds.height - HANDLE_SIZE
        });

    // the max handles
    gc.fillPolygon(
        new int[] {
          visualHigh + bounds.x + HANDLE_SIZE, bounds.y,
          visualHigh + bounds.x, bounds.y,
          visualHigh + bounds.x, bounds.y + HANDLE_SIZE + 1
        });

    gc.fillPolygon(
        new int[] {
          visualHigh + bounds.x + HANDLE_SIZE, bounds.y + bounds.height,
          visualHigh + bounds.x, bounds.y + bounds.height,
          visualHigh + bounds.x, bounds.y + bounds.height - HANDLE_SIZE - 1
        });

    // draw separater lines
    gc.drawLine(visualLow, bounds.y, visualLow, bounds.y + bounds.height);
    gc.drawLine(visualHigh - 1, bounds.y, visualHigh - 1, bounds.y + bounds.height);
  }
Exemplo n.º 16
0
  /**
   * Paints the preview at the given x/y position
   *
   * @param gc the graphics context to paint it into
   * @param x the x coordinate to paint the preview at
   * @param y the y coordinate to paint the preview at
   */
  void paint(GC gc, int x, int y) {
    mTitleHeight = paintTitle(gc, x, y, true /*showFile*/);
    y += mTitleHeight;
    y += 2;

    int width = getWidth();
    int height = getHeight();
    if (mThumbnail != null && mError == null) {
      gc.drawImage(mThumbnail, x, y);

      if (mActive) {
        int oldWidth = gc.getLineWidth();
        gc.setLineWidth(3);
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
        gc.drawRectangle(x - 1, y - 1, width + 2, height + 2);
        gc.setLineWidth(oldWidth);
      }
    } else if (mError != null) {
      if (mThumbnail != null) {
        gc.drawImage(mThumbnail, x, y);
      } else {
        gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BORDER));
        gc.drawRectangle(x, y, width, height);
      }

      gc.setClipping(x, y, width, height);
      Image icon = IconFactory.getInstance().getIcon("renderError"); // $NON-NLS-1$
      ImageData data = icon.getImageData();
      int prevAlpha = gc.getAlpha();
      int alpha = 96;
      if (mThumbnail != null) {
        alpha -= 32;
      }
      gc.setAlpha(alpha);
      gc.drawImage(icon, x + (width - data.width) / 2, y + (height - data.height) / 2);

      String msg = mError;
      Density density = mConfiguration.getDensity();
      if (density == Density.TV || density == Density.LOW) {
        msg =
            "Broken rendering library; unsupported DPI. Try using the SDK manager "
                + "to get updated layout libraries.";
      }
      int charWidth = gc.getFontMetrics().getAverageCharWidth();
      int charsPerLine = (width - 10) / charWidth;
      msg = SdkUtils.wrap(msg, charsPerLine, null);
      gc.setAlpha(255);
      gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
      gc.drawText(msg, x + 5, y + HEADER_HEIGHT, true);
      gc.setAlpha(prevAlpha);
      gc.setClipping((Region) null);
    } else {
      gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BORDER));
      gc.drawRectangle(x, y, width, height);

      Image icon = IconFactory.getInstance().getIcon("refreshPreview"); // $NON-NLS-1$
      ImageData data = icon.getImageData();
      int prevAlpha = gc.getAlpha();
      gc.setAlpha(96);
      gc.drawImage(icon, x + (width - data.width) / 2, y + (height - data.height) / 2);
      gc.setAlpha(prevAlpha);
    }

    if (mActive) {
      int left = x;
      int prevAlpha = gc.getAlpha();
      gc.setAlpha(208);
      Color bg = mCanvas.getDisplay().getSystemColor(SWT.COLOR_WHITE);
      gc.setBackground(bg);
      gc.fillRectangle(left, y, x + width - left, HEADER_HEIGHT);
      gc.setAlpha(prevAlpha);

      y += 2;

      // Paint icons
      gc.drawImage(CLOSE_ICON, left, y);
      left += CLOSE_ICON_WIDTH;

      gc.drawImage(ZOOM_IN_ICON, left, y);
      left += ZOOM_IN_ICON_WIDTH;

      gc.drawImage(ZOOM_OUT_ICON, left, y);
      left += ZOOM_OUT_ICON_WIDTH;

      gc.drawImage(EDIT_ICON, left, y);
      left += EDIT_ICON_WIDTH;
    }
  }
Exemplo n.º 17
0
  private void setAlpha(GC gc, double fade) {

    if (gc.getAlpha() == fade) return;
    if (fade >= 255) gc.setAlpha(255);
    else gc.setAlpha((int) fade);
  }