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

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

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

GC.setAntialias介绍

[英]Sets the receiver's anti-aliasing value to the parameter, which must be one of SWT.DEFAULT, SWT.OFF or SWT.ON. Note that this controls anti-aliasing for all non-text drawing operations.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
[中]将接收器的抗锯齿值设置为参数,该参数必须是SWT.DEFAULTSWT.OFFSWT.ON中的一个。请注意,这将控制所有非文本绘图操作的抗锯齿。
此操作需要操作系统的高级图形子系统,该子系统在某些平台上可能不可用。

代码示例

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

public void setAntialias( boolean antiAlias ) {
 if ( antiAlias ) {
  gc.setAntialias( SWT.ON );
 } else {
  gc.setAntialias( SWT.OFF );
 }
}

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

public void setAntialias( boolean antiAlias ) {
 if ( antiAlias ) {
  gc.setAntialias( SWT.ON );
 } else {
  gc.setAntialias( SWT.OFF );
 }
}

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

public void setAntialias(boolean antialias)
{
  if (antialias) {
    gc.setAntialias(SWT.ON);
  } else {
    gc.setAntialias(SWT.OFF);
  }
}

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

@Override
public void setAntialias ( final boolean state )
{
  this.gc.setAntialias ( state ? SWT.ON : SWT.OFF );
}

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

@Override
public void setAntialias ( final boolean state )
{
  this.gc.setAntialias ( state ? SWT.ON : SWT.OFF );
}

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

public void setRenderingHint(Key key, Object value) {
  if (RenderingHints.KEY_ANTIALIASING.equals(key)) {
    int antialias = SWT.DEFAULT;
    if (RenderingHints.VALUE_ANTIALIAS_OFF.equals(value)) {
      antialias = SWT.OFF;
    } else if (RenderingHints.VALUE_ANTIALIAS_ON.equals(value)) {
      antialias = SWT.ON;
    }
    _gc.setAntialias(antialias);
  }
}

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

/**
 * Constructor for SWTGraphics2D.
 * 
 * @param gc The Eclipse Graphics Context onto which all Graphics2D
 *            operations are delegating
 * @param device Device onto which ultimately all gc operations are drawn
 *            onto
 */
public SWTGraphics2D(final GC gc, final Device device) {
  this.gc = gc;
  this.device = device;
  swtTransform = new Transform(device);
  gc.setAntialias(SWT.ON);
}

代码示例来源:origin: stackoverflow.com

Image newImage = new Image(image.getDevice(), newWidth, newHeight);
GC gc = new GC(newImage);
gc.setAdvanced(true);
gc.setAntialias(SWT.ON);
gc.drawImage(image, 0, 0, origWidth, origHeight, 0, 0, newWidth, newHeight);
gc.dispose();

代码示例来源:origin: stackoverflow.com

Image scaled = new Image(Display.getDefault(), width, height);
GC gc = new GC(scaled);
gc.setAntialias(SWT.ON);
gc.setInterpolation(SWT.HIGH);
gc.drawImage(image, 0, 0,image.getBounds().width, image.getBounds().height, 0, 0, width, height);
gc.dispose();

// Image data from scaled image and transparent pixel from original

ImageData imageData = scaled.getImageData();

imageData.transparentPixel = image.getImageData().transparentPixel;

// Final scaled transparent image

Image finalImage = new Image(Display.getDefault(), imageData);

scaled.dispose();

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.forms

public static void setAntialias(GC gc, int style) {
    if (!gc.getAdvanced()) {
      gc.setAdvanced(true);
      if (!gc.getAdvanced())
        return;
    }
    gc.setAntialias(style);
  }
}

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

public static void setAntialias(GC gc, int style) {
    if (!gc.getAdvanced()) {
      gc.setAdvanced(true);
      if (!gc.getAdvanced())
        return;
    }
    gc.setAntialias(style);
  }
}

代码示例来源:origin: stackoverflow.com

public static Image resize(Image image, int width, int height) {
 Image scaled = new Image(Display.getDefault(), width, height);
 GC gc = new GC(scaled);
 gc.setAntialias(SWT.ON);
 gc.setInterpolation(SWT.HIGH);
 gc.drawImage(image, 0, 0,image.getBounds().width, image.getBounds().height, 0, 0, width, height);
 gc.dispose();
 image.dispose(); // don't forget about me!
 return scaled;
}

代码示例来源:origin: stackoverflow.com

private Image resize(Image image, int width, int height) {
Image scaled = new Image(Display.getDefault(), width, height);
GC gc = new GC(scaled);
gc.setAntialias(SWT.ON);
gc.setInterpolation(SWT.HIGH);
gc.drawImage(image, 0, 0,  image.getBounds().width, image.getBounds().height, 
0, 0, width, height);
gc.dispose();
image.dispose(); // don't forget about me!
return scaled;
}

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

@Override
  public void paintControl(PaintEvent e) {
    Control c = (Control) e.widget;
    Point size = c.getSize();
    int arrowSize = 8;
    int xStart = size.x - arrowSize;
    int yStart = size.y - (size.y + arrowSize) / 2;
    e.gc.setBackground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_FOREGROUND));
    e.gc.setAntialias(SWT.ON);
    e.gc.fillPolygon(new int[] {
      xStart,
      yStart,
      xStart + arrowSize,
      yStart + (arrowSize / 2),
      xStart,
      yStart + arrowSize,
    });
  }
};

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

@Override
  public void paintControl(PaintEvent e){
    GC gc = e.gc;
    
    gc.setAdvanced(true);
    gc.setAntialias(SWT.ON);
        
    Point pp = parent.toDisplay(0, 0);
    Point cp = child.toDisplay(0, 0 );
    
    Rectangle bounds = child.getBounds();
    
    
    int	width 	= bounds.width;
    int height	= bounds.height;
    
    gc.setForeground(Colors.fadedRed );
    
    gc.drawRectangle( cp.x-pp.x-1, cp.y-pp.y-1, width+2, height+2 );						
  }
});

代码示例来源:origin: org.eclipse.egit/ui

void paint(final Event event, Ref actHeadRef) {
  g = event.gc;
  if (this.enableAntialias)
    try {
      g.setAntialias(SWT.ON);
    } catch (SWTException e) {
      this.enableAntialias = false;
    }
  this.headRef = actHeadRef;
  cellX = event.x;
  cellY = event.y;
  cellFG = g.getForeground();
  cellBG = g.getBackground();
  if (textHeight == 0)
    textHeight = g.stringExtent("/").y; //$NON-NLS-1$
  final TableItem ti = (TableItem) event.item;
  SWTCommit commit = (SWTCommit) ti.getData();
  try {
    commit.parseBody();
  } catch (IOException e) {
    Activator.error("Error parsing body", e); //$NON-NLS-1$
    return;
  }
  paintCommit(commit , event.height);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

@Override
public void paint(GC gc, int width, int height) {
  if (!example.checkAdvancedGraphics()) return;
  Device device = gc.getDevice();

  if (ovalColorGB != null && ovalColorGB.getBgColor1() != null)
    gc.setBackground(ovalColorGB.getBgColor1());

  gc.setAntialias(aliasValues[aliasCombo.getSelectionIndex()]);

  Path path = new Path(device);
  float offsetX = 2*width/3f, offsetY = height/3f;
  for(int i=0; i < 25; i++) {
    path.addArc(offsetX-(50*i), offsetY-(25*i), 50+(100*i), 25+(50*i), 0, 360);
  }
  gc.fillPath(path);
  path.dispose();
}
}

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

@Override
protected void paintHyperlink(GC gc) {
  int as = gc.getAntialias();
  gc.setAntialias(SWT.ON);
  Color bg;
  if (!isEnabled())
    bg = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
  else if (hover && getHoverDecorationColor() != null)
    bg = getHoverDecorationColor();
  else if (getDecorationColor() != null)
    bg = getDecorationColor();
  else
    bg = getForeground();
  gc.setBackground(bg);
  int[] data;
  Point size = getSize();
  int x = (size.x - 9) / 2;
  int y = (size.y - 9) / 2;
  if (isExpanded())
    data = translate(onPoints, x, y);
  else
    data = translate(offPoints, x, y);
  gc.fillPolygon(data);
  gc.setBackground(getBackground());
  gc.setAntialias(as);
}

代码示例来源:origin: org.xworker/xworker_swt

public void draw(Canvas canvas, GC gc){
  //打开反锯齿
  int antialias = gc.getAntialias();
  if(antialias != SWT.ON) {
    gc.setAntialias(SWT.ON);
  }
  
  //先填充画面
  Color oldColor = gc.getBackground();
  gc.setBackground(canvas.getDisplay().getSystemColor(SWT.COLOR_WHITE));
  gc.fillRectangle(canvas.getClientArea());
  gc.setBackground(oldColor);
  
  if(backgroundImage != null){
    gc.drawImage(backgroundImage, 0, 0);
  }
  
  //绘画各种形状
  for(SimpleShape shape : shapes){			
    try {
      shape.draw(canvas, gc);
    }catch(Exception e) {
      logger.warn("Draw SimpleDraw2d shape exception, path=" + shape.getThing().getMetadata().getPath(), e);
    }
  }
}

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

@Override
protected void drawCompositeImage(int width, int height) {
  Display display= fParentComposite.getDisplay();
  ImageDataProvider imageProvider = zoom -> {
    Image image = new Image(display, ARROW_SIZE, ARROW_SIZE * 2);
    GC gc = new GC(image, fLTR ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT);
    gc.setAntialias(SWT.ON);
    Color triangleColor = createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 20, display);
    gc.setBackground(triangleColor);
    gc.fillPolygon(new int[] {
        0, 0, ARROW_SIZE, ARROW_SIZE, 0, ARROW_SIZE * 2 });
    gc.dispose();
    triangleColor.dispose();
    ImageData imageData = image.getImageData(zoom);
    image.dispose();
    int zoomedArrowSize = ARROW_SIZE * zoom / 100;
    for (int y1 = 0; y1 < zoomedArrowSize; y1++) {
      for (int x1 = 0; x1 <= y1; x1++) {
        imageData.setAlpha(fLTR ? x1 : zoomedArrowSize - x1 - 1, y1, 255);
      }
    }
    for (int y2 = 0; y2 < zoomedArrowSize; y2++) {
      for (int x2 = 0; x2 <= y2; x2++) {
        imageData.setAlpha(fLTR ? x2 : zoomedArrowSize - x2 - 1, zoomedArrowSize * 2 - y2 - 1, 255);
      }
    }
    return imageData;
  };
  drawImage(imageProvider, (width / 2) - (ARROW_SIZE / 2), (height / 2) - ARROW_SIZE);
}

相关文章

GC类方法