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

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

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

GC.setAdvanced介绍

[英]Sets the receiver to always use the operating system's advanced graphics subsystem for all graphics operations if the argument is true. If the argument is false, the advanced graphics subsystem is no longer used, advanced graphics state is cleared and the normal graphics subsystem is used from now on.

Normally, the advanced graphics subsystem is invoked automatically when any one of the alpha, antialias, patterns, interpolation, paths, clipping or transformation operations in the receiver is requested. When the receiver is switched into advanced mode, the advanced graphics subsystem performs both advanced and normal graphics operations. Because the two subsystems are different, their output may differ. Switching to advanced graphics before any graphics operations are performed ensures that the output is consistent.

Advanced graphics may not be installed for the operating system. In this case, this operation does nothing. Some operating system have only one graphics subsystem, so switching from normal to advanced graphics does nothing. However, switching from advanced to normal graphics will always clear the advanced graphics state, even for operating systems that have only one graphics subsystem.
[中]如果参数为[$0$],则将接收器设置为始终将操作系统的高级图形子系统用于所有图形操作。如果参数为false,则高级图形子系统将不再使用,高级图形状态将被清除,并且从现在起将使用普通图形子系统。
通常,当接收器中的任何一个alpha、抗锯齿、模式、插值、路径、剪裁或变换操作被请求时,高级图形子系统将自动调用。当接收器切换到高级模式时,高级图形子系统执行高级和正常图形操作。由于这两个子系统不同,它们的输出可能不同。在执行任何图形操作之前切换到高级图形可确保输出一致。
操作系统可能未安装高级图形。在这种情况下,此操作不执行任何操作。有些操作系统只有一个图形子系统,所以从普通图形切换到高级图形没有任何作用。但是,从高级图形切换到普通图形将始终清除高级图形状态,即使对于只有一个图形子系统的操作系统也是如此。

代码示例

代码示例来源: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: 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.e4.ui.workbench.renderers/swt

protected Point computeSize(int part, int state, GC gc, int wHint, int hHint) {
  wHint += paddingLeft + paddingRight;
  hHint += paddingTop + paddingBottom;
  if (0 <= part && part < parent.getItemCount()) {
    gc.setAdvanced(true);
    Point result = super.computeSize(part, state, gc, wHint, hHint);
    return result;
  }
  return super.computeSize(part, state, gc, wHint, hHint);
}

代码示例来源: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: org.eclipse.platform/org.eclipse.e4.ui.workbench.renderers.swt

@Override
protected Point computeSize(int part, int state, GC gc, int wHint, int hHint) {
  wHint += paddingLeft + paddingRight;
  hHint += paddingTop + paddingBottom;
  if (0 <= part && part < parent.getItemCount()) {
    gc.setAdvanced(true);
    Point result = super.computeSize(part, state, gc, wHint, hHint);
    return result;
  }
  return super.computeSize(part, state, gc, wHint, hHint);
}

代码示例来源: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
paintControl(
  PaintEvent e)
{
  e.gc.setAdvanced(true);
  Rectangle clientArea = getClientArea();
  GCStringPrinter sp =
    new GCStringPrinter(e.gc, getText(), clientArea, true, true, style);
  sp.printString(e.gc, clientArea, style);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Creates a new painter for the given text viewer.
 *
 * @param textViewer  the text viewer the painter should be attached to
 */
public WhitespaceCharacterPainter(ITextViewer textViewer) {
  super();
  fTextViewer= textViewer;
  fTextWidget= textViewer.getTextWidget();
  GC gc= new GC(fTextWidget);
  gc.setAdvanced(true);
  fIsAdvancedGraphicsPresent= gc.getAdvanced();
  gc.dispose();
  fIsFullSelectionStyle= (fTextWidget.getStyle() & SWT.FULL_SELECTION) != SWT.NONE;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Creates a new painter for the given text viewer.
 *
 * @param textViewer  the text viewer the painter should be attached to
 */
public WhitespaceCharacterPainter(ITextViewer textViewer) {
  super();
  fTextViewer= textViewer;
  fTextWidget= textViewer.getTextWidget();
  GC gc= new GC(fTextWidget);
  gc.setAdvanced(true);
  fIsAdvancedGraphicsPresent= gc.getAdvanced();
  gc.dispose();
  fIsFullSelectionStyle= (fTextWidget.getStyle() & SWT.FULL_SELECTION) != SWT.NONE;
}

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

private Point getTipCountTextSize(Composite providerButton, int tipCount) {
    GC gc2 = new GC(providerButton);
    gc2.setAdvanced(true);
    gc2.setFont(SWTResourceManager.getBoldFont(gc2.getFont()));
    Point textExtent = gc2.textExtent(tipCount + ""); //$NON-NLS-1$
    gc2.dispose();
    return textExtent;
  }
}

代码示例来源: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: com.github.rinde/rinsim-problem

void drawTimeline() {
  final GC gc = new GC(contents);
  gc.setAdvanced(true);
  // gc.setAntialias(SWT.ON);
  gc.setTextAntialias(SWT.OFF);
  final int large = (600000 / 15000);
  final int small = large / 5;
  for (int i = 0; i < contents.getBounds().width; i += small) {
   final int height = i % large == 0 ? 10 : 5;
   if (i % large == 0) {
    String time = TimeFormatter.format(15000 * i);
    time = time.substring(0, time.length() - 3);
    gc.setFont(font);
    final Point size = gc.textExtent(time);
    gc.drawText(time, i - (size.x / 2), 0);
   }
   gc.drawLine(i, 20 - height, i, 20);
  }
  gc.dispose();
 }
}

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

&& gc.getAlpha() == 255) {
clipping = gc.getClipping();
gc.setAdvanced(false);
Utils.setClipping(gc, clipping);
gc.setAdvanced(true);
Utils.setClipping(gc, clipping);

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

private static Image force16height(Image image) {
  if (image == null) {
    return image;
  }
  Rectangle bounds = image.getBounds();
  if (bounds.height != 16) {
    Image newImage = new Image(image.getDevice(), 16, 16);
    GC gc = new GC(newImage);
    try {
      if (!Constants.isUnix) {
        // drawImage doesn't work on GTK when advanced is on
        gc.setAdvanced(true);
      }
      gc.drawImage(image, 0, 0, bounds.width, bounds.height, 0, 0, 16, 16);
    } finally {
      gc.dispose();
    }
    image.dispose();
    image = newImage;
  }
  return image;
}

代码示例来源:origin: com.github.rinde/rinsim-pdptw

final void drawTimeline() {
  final GC gc = new GC(contents);
  gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
  gc.fillRectangle(0, 0, contents.getBounds().width,
   contents.getBounds().height);
  gc.setAdvanced(true);
  gc.setTextAntialias(SWT.ON);
  for (int i = 0; i < contents.getBounds().width; i += SMALL_TICK_DIST) {
   final int height = i % LARGE_TICK_DIST == 0 ? LARGE_TICK_HEIGHT
    : SMALL_TICK_HEIGHT;
   if (i % LARGE_TICK_DIST == 0) {
    final String time = FORMATTER
     .print(new Period(0L, TIME_PER_PIXEL * i));
    gc.setFont(font);
    final Point size = gc.textExtent(time);
    gc.drawText(time, i - size.x / 2, 0, true);
   }
   gc.drawLine(i, TL_BAR_HEIGHT_PX - height, i, TL_BAR_HEIGHT_PX);
  }
  gc.dispose();
 }
}

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

final void drawTimeline() {
  final GC gc = new GC(contents);
  gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
  gc.fillRectangle(0, 0, contents.getBounds().width,
   contents.getBounds().height);
  gc.setAdvanced(true);
  gc.setTextAntialias(SWT.ON);
  for (int i = 0; i < contents.getBounds().width; i += SMALL_TICK_DIST) {
   final int height = i % LARGE_TICK_DIST == 0 ? LARGE_TICK_HEIGHT
    : SMALL_TICK_HEIGHT;
   if (i % LARGE_TICK_DIST == 0) {
    final String time = FORMATTER
     .print(new Period(0L, TIME_PER_PIXEL * i));
    gc.setFont(font);
    final Point size = gc.textExtent(time);
    gc.drawText(time, i - size.x / 2, 0, true);
   }
   gc.drawLine(i, TL_BAR_HEIGHT_PX - height, i, TL_BAR_HEIGHT_PX);
  }
  gc.dispose();
 }
}

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

public void handleEvent( Event event ) {
  event.detail &= ~SWT.HOT;
  GC gc = event.gc;
  Rectangle area = table.getClientArea();
  /*
  * If you wish to paint the selection beyond the end of
  * last column, you must change the clipping region.
  */
  int columnCount = table.getColumnCount();
  if ( event.index == columnCount - 1 || columnCount == 0 ) {
   int width = area.x + area.width - event.x;
   if ( width > 0 ) {
     Region region = new Region();
     gc.getClipping(region);
     region.add(event.x, event.y, width, event.height);
     gc.setClipping(region);
     region.dispose();
   }
  }
  gc.setAdvanced(true);
  if ( gc.getAdvanced() ) gc.setAlpha(127);
  Rectangle rect = event.getBounds();
  Color background = gc.getBackground();
  gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
  gc.fillRectangle(0, rect.y, 500, rect.height);
  // restore colors for subsequent drawing
  gc.setBackground(background);
}

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

default:
  if (0 <= part && part < parent.getItemCount()) {
    gc.setAdvanced(true);
    if (bounds.width == 0 || bounds.height == 0)
      return;

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

private void paintButton(GC gc, Composite providerButton, TipProvider provider) {
  gc.setAdvanced(true);
  if (!gc.getAdvanced()) {
    throw new RuntimeException(Messages.Slider_13);
  }
  if (provider.equals(fSelectedProvider)) {
    gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
    gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
    gc.drawRectangle(0, 0, fIconSize + 3, fIconSize + 3);
  } else {
    gc.setForeground(fLeftButton.getForeground());
    gc.setBackground(fLeftButton.getBackground());
    boolean mouseIn = getDisplay().getCursorControl() == providerButton;
    if (mouseIn) {
      gc.drawRectangle(0, 0, fIconSize + 3, fIconSize + 3);
    } else {
      gc.setBackground(fScroller.getBackground());
    }
  }
  gc.fillRectangle(2, 2, fIconSize, fIconSize);
  Image overlay = getUnreadOverlay(providerButton, provider);
  gc.drawImage(overlay, 2, 2);
  if (overlay != getProviderImage(provider, selectProviderImage(provider))) {
    overlay.dispose();
  }
}

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

gc.setAdvanced(true);
gc.setAntialias(SWT.ON);

相关文章

微信公众号

最新文章

更多

GC类方法