org.eclipse.swt.graphics.GC.setAlpha()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.eclipse.swt.graphics.GC.setAlpha()方法的一些代码示例,展示了GC.setAlpha()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.setAlpha()方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:setAlpha

GC.setAlpha介绍

[英]Sets the receiver's alpha value which must be between 0 (transparent) and 255 (opaque).

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
[中]设置接收器的alpha值,该值必须介于0(透明)和255(不透明)之间。
此操作需要操作系统的高级图形子系统,该子系统在某些平台上可能不可用。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public void setAlpha( int alpha ) {
 gc.setAlpha( alpha );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void setAlpha( int alpha ) {
 gc.setAlpha( alpha );
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.chart/org.eclipse.scada.chart.swt

@Override
public void setAlpha ( final int alpha )
{
  this.gc.setAlpha ( alpha );
}

代码示例来源:origin: org.eclipse.neoscada.chart/org.eclipse.scada.chart.swt

@Override
public void setAlpha ( final int alpha )
{
  this.gc.setAlpha ( alpha );
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/**
 * Set the transparency for this graphics context to <code>transparency</code>.
 *
 * @param transparency transparency, must be between <code>0.0f</code> and <code>1.0f</code> inclusive
 */
public void setTransparency(final float transparency) {
  if ((transparency < 0.0f) || (transparency > 1.0f)) {
    throw new IllegalArgumentException("transparency must be between 0.0f and 1.0f inclusive");
  }
  this.transparency = transparency;
  gc.setAlpha((int) (this.transparency * 255.0f));
}

代码示例来源:origin: org.jfree/swtgraphics2d

/**
 * Sets the current composite.  This implementation currently supports
 * only the {@link AlphaComposite} class.
 *
 * @param comp  the composite ({@code null} not permitted).
 */
@Override
public void setComposite(Composite comp) {
  if (comp == null) {
    throw new IllegalArgumentException("Null 'comp' argument.");
  }
  this.composite = comp;
  if (comp instanceof AlphaComposite) {
    AlphaComposite acomp = (AlphaComposite) comp;
    int alpha = (int) (acomp.getAlpha() * 0xFF);
    this.gc.setAlpha(alpha);
  }
}

代码示例来源:origin: com.eclipsesource.tabris/tabris

private void restoreLastSettings( int lineWidth, Color foreground, int alpha ) {
 gc.setLineWidth( lineWidth );
 gc.setForeground( foreground );
 gc.setAlpha( alpha );
}

代码示例来源:origin: rherrmann/eclipse-extras

private void drawBar() {
 if( barColor != null ) {
  gc.setAlpha( 200 );
  gc.setBackground( barColor );
  gc.fillRoundRectangle( 1, 1, barWidth, clientArea.height - 2 - 1, ARC_SIZE, ARC_SIZE );
 }
}

代码示例来源:origin: rinde/RinSim

@Override
public void renderDynamic(GC gc, ViewPort vp, long time) {
 adapter.adapt(gc, vp);
 if (showNodeOccupancy) {
  for (final Point p : model.getOccupiedNodes()) {
   gc.setAlpha(SEMI_TRANSPARENT);
   adapter.setBackgroundSysCol(SWT.COLOR_RED);
   adapter.fillCircle(p, vehicleLength / 2d + minDistance);
   gc.setAlpha(OPAQUE);
  }
 }
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer

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;
}

代码示例来源:origin: stefanhaustein/flowgrid

public static void drawHalo(GC gc, int x, int y, int r, Color color) {
    Color background = gc.getBackground();
    int alpha = gc.getAlpha();
    gc.setAlpha(127);
    gc.setBackground(color);
    gc.fillOval(x - r, y - r, 2 * r, 2 * r);
    gc.setAlpha(alpha);
    gc.setBackground(background);
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void
  paintControl(PaintEvent e)
  {
    Rectangle client_area = tracker_webseed_comp.getClientArea();
    Rectangle rect = new Rectangle(0,0, client_area.width-1, client_area.height-1);
    e.gc.setAlpha(50);
    e.gc.drawRectangle(rect);
  }
});

代码示例来源:origin: rherrmann/eclipse-extras

private void drawBorder() {
 if( ( style & SWT.BORDER ) != 0 ) {
  int x = clientArea.x;
  int y = clientArea.y;
  int width = clientArea.width - 1;
  int height = clientArea.height - 1 - 1;
  gc.setAlpha( 255 );
  gc.setForeground( getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
  gc.drawRoundRectangle( x, y, width, height, ARC_SIZE, ARC_SIZE );
 }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void paintControl(PaintEvent e) {
    if (bufferImage != null && !bufferImage.isDisposed()) {
      Rectangle bounds = bufferImage.getBounds();
      if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) {
        if (alpha != 255) {
          try {
            e.gc.setAlpha(alpha);
         } catch (Exception ex) {
           // Ignore ERROR_NO_GRAPHICS_LIBRARY error or any others
         }
        }
        e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y,
            e.width, e.height);
      }
    }
  }
});

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor

@Override
public void paintControl(PaintEvent event) {
  GC gc = event.gc;
  int clientAreaWidth = fMinimapTextWidget.getClientArea().width;
  gc.setBackground(fMinimapTextWidget.getSelectionBackground());
  Rectangle rect = new Rectangle(0, fTopIndexY, clientAreaWidth,
      Math.max(fBottomIndexY - fTopIndexY, fMinimalHeight));
  gc.drawRectangle(rect.x, rect.y, Math.max(1, rect.width - 1), Math.max(1, rect.height - 1));
  gc.setAdvanced(true);
  if (gc.getAdvanced()) {
    gc.setAlpha(20);
    gc.fillRectangle(rect);
    gc.setAdvanced(false);
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public void cellPaint(GC gc, TableCellSWT cell) {
 Object ds = cell.getDataSource();
 if (!(ds instanceof TorrentOpenFileOptions)) {
   return;
 }
 TorrentOpenFileOptions tfi = (TorrentOpenFileOptions) ds;
 float pct = tfi.lSize / (float) tfi.parent.getTorrent().getSize();
 Rectangle bounds = cell.getBounds();
  bounds.width = (int) (bounds.width * pct);
  if (bounds.width > 2) {
    bounds.x++;
    bounds.y++;
    bounds.height -= 2;
    bounds.width -= 2;
   gc.setBackground(gc.getForeground());
   int alpha = gc.getAlpha();
   gc.setAlpha(10);
   gc.fillRectangle(bounds);
   gc.setAlpha(alpha);
  }
}

代码示例来源:origin: rherrmann/eclipse-extras

private void drawText() {
 gc.setAlpha( 255 );
 Rectangle rect = insideBorderArea();
 Point textLocation = getTextLocation( rect );
 Color defaultForeground = getSystemColor( SWT.COLOR_WIDGET_FOREGROUND );
 drawText( textLocation, defaultForeground, null );
 Color barForeground = getBarForegroundColor();
 if( !equals( defaultForeground, barForeground ) ) {
  Rectangle clipping = new Rectangle( rect.x, rect.y, barWidth, rect.height );
  drawText( textLocation, barForeground, clipping );
 }
}

代码示例来源:origin: BiglySoftware/BiglyBT

private void
  setColour(
    GC        gc )
  {
    if ( complete_time != -1 && draw_count > 1 ){
      int age = (int)( SystemTime.getMonotonousTime() - complete_time );
      gc.setAlpha( Math.max( 0, 200 - (255*age/FADE_OUT)));
      gc.setForeground( ColorCache.getColor( gc.getDevice(), 0, 0, 0 ));
    }else{
      gc.setAlpha( 255 );
      int type = activity.getType();
      if ( type == DHTControlActivity.AT_EXTERNAL_GET ){
        gc.setForeground( ColorCache.getColor( gc.getDevice(), 20, 200, 20 ));
      }else if ( type == DHTControlActivity.AT_INTERNAL_GET ){
        gc.setForeground( ColorCache.getColor( gc.getDevice(), 140, 160, 40 ));
      }else if ( type == DHTControlActivity.AT_EXTERNAL_PUT ){
        gc.setForeground( ColorCache.getColor( gc.getDevice(), 20, 20, 220 ));
      }else{
        gc.setForeground( ColorCache.getColor( gc.getDevice(), 40, 140, 160 ));
      }
    }
  }
}

代码示例来源:origin: com.eclipsesource.tabris/tabris

private void dispatchSetForeground( JsonArray parameters ) {
 int r = parameters.get( 0 ).asInt();
 int g = parameters.get( 1 ).asInt();
 int b = parameters.get( 2 ).asInt();
 int a = parameters.get( 3 ).asInt();
 gc.setForeground( new Color( gc.getDevice(), new RGB( r, g, b ) ) );
 gc.setAlpha( a );
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.workbench.renderers.swt

void drawCorners(GC gc, Rectangle bounds) {
  Color bg = gc.getBackground();
  Color fg = gc.getForeground();
  Color toFill = parent.getParent().getBackground();
  gc.setAlpha(255);
  gc.setBackground(toFill);
  gc.setForeground(toFill);
  int radius = cornerSize / 2 + 1;
  int leftX = bounds.x - 1;
  int topY = bounds.y - 1;
  int rightX = bounds.x + bounds.width;
  int bottomY = bounds.y + bounds.height;
  drawCutout(gc, leftX, topY, radius, CirclePart.LEFT_TOP);
  drawCutout(gc, rightX, topY, radius, CirclePart.RIGHT_TOP);
  drawCutout(gc, leftX, bottomY, radius, CirclePart.LEFT_BOTTOM);
  drawCutout(gc, rightX, bottomY, radius, CirclePart.RIGHT_BOTTOM);
  gc.setBackground(bg);
  gc.setForeground(fg);
}

相关文章

GC类方法