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

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

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

GC.getClipping介绍

[英]Returns the bounding rectangle of the receiver's clipping region. If no clipping region is set, the return value will be a rectangle which covers the entire bounds of the object the receiver is drawing on.
[中]返回接收器剪裁区域的边框。如果未设置剪裁区域,则返回值将是一个矩形,覆盖接收器正在绘制的对象的整个边界。

代码示例

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

public Rectangle getClipping() 
{
  return gc.getClipping();
}

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

/**
 * Returns the clip bounds.
 *
 * @return The clip bounds.
 */
@Override
public Rectangle getClipBounds() {
  org.eclipse.swt.graphics.Rectangle clip = this.gc.getClipping();
  return new Rectangle(clip.x, clip.y, clip.width, clip.height);
}

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

/**
 * Returns the current clip.
 *
 * @return The current clip.
 */
@Override
public Shape getClip() {
  return SWTUtils.toAwtRectangle(this.gc.getClipping());
}

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

/** {@inheritDoc} */
public Rectangle getClipBounds() {
  final org.eclipse.swt.graphics.Rectangle rect = gc.getClipping();
  final Rectangle aRect = new Rectangle(rect.x, rect.y, rect.width, rect.height);
  try {
    SWTShapeManager.transform(aRect, transform.createInverse());
  }
  catch (final Exception e) {
    throw new RuntimeException(e);
  }
  return aRect;
}

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

/** {@inheritDoc} */
public Shape getClip() {
  final org.eclipse.swt.graphics.Rectangle rect = gc.getClipping();
  final Rectangle2D aRect = new Rectangle2D.Double(rect.x, rect.y, rect.width, rect.height);
  try {
    SWTShapeManager.transform(aRect, transform.createInverse());
  }
  catch (final NoninvertibleTransformException e) {
    throw new RuntimeException(e);
  }
  return aRect;
}

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

protected void swt_paintComposite(PaintEvent e) {
  swt_calculateClientArea();
  if (canvasImage == null) {
    swt_paintCanvasImage(e.gc, e.gc.getClipping());
    return;
  }
  //System.out.println(e.count + " paint " + e.gc.getClipping() + ";" + e.x + "," + e.y + "," + e.width + "," + e.height + " via " + Debug.getCompressedStackTrace());
  e.gc.drawImage(canvasImage, -clientArea.x, 0);
  // test line
  //e.gc.drawLine(0, 0, cTable.getSize().x, canvasImage.getBounds().height);
}

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

/**
 * This method isn't really supported by SWT - so will use the shape bounds.
 * 
 * @param s shape of the clipping region to apply to graphics operations
 */
public void clip(final Shape s) {
  final Rectangle2D clipBds = s.getBounds2D();
  SWTShapeManager.transform(clipBds, transform);
  SWTShapeManager.awtToSWT(clipBds, SWT_RECT);
  org.eclipse.swt.graphics.Rectangle clip = gc.getClipping();
  clip = clip.intersection(SWT_RECT);
  gc.setClipping(SWT_RECT);
}

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

/**
 * Sets the clipping to the intersection of the current clip region and
 * the specified rectangle.
 *
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 * @param width  the width.
 * @param height  the height.
 */
@Override
public void clipRect(int x, int y, int width, int height) {
  org.eclipse.swt.graphics.Rectangle clip = this.gc.getClipping();
  org.eclipse.swt.graphics.Rectangle r 
      = new org.eclipse.swt.graphics.Rectangle(x, y, width, height);
  clip.intersect(r);
  this.gc.setClipping(clip);
}

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

@Override
  public void paintControl(PaintEvent e) {
    try{
      Rectangle clipping = e.gc.getClipping();
      int ofs = (labelImage.getSize().x - boundsColor.width) / 2;
      if (paintColorTo > 0) {
        e.gc.drawImage(imgSrc, 0, 0, paintColorTo, boundsColor.height, ofs, 10, paintColorTo, boundsColor.height);
      }
      if (clipping.x + clipping.width > ofs + paintColorTo && imgBounds.width - paintColorTo - 1 > 0) {
        e.gc.drawImage(image,
            paintColorTo + 1, 0, imgBounds.width - paintColorTo - 1, imgBounds.height,
            paintColorTo + 1 + ofs, 10, imgBounds.width - paintColorTo - 1, imgBounds.height);
      }
    }catch( Throwable f ){
      // seen some 'argument not valid errors spewed here, couldn't track down
      // the cause though :( parg.
    }
  }
});

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

private void drawText( Point location, Color foreground, Rectangle clipping ) {
 Rectangle previousClipping = gc.getClipping();
 if( clipping != null ) {
  gc.setClipping( clipping );
 }
 gc.setForeground( foreground );
 gc.drawText( text, location.x, location.y, SWT.DRAW_TRANSPARENT );
 if( clipping != null ) {
  gc.setClipping( previousClipping );
 }
}

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

/** {@inheritDoc} */
public void clipRect(final int x, final int y, final int width, final int height) {
  TEMP_RECT.setRect(x, y, width, height);
  SWTShapeManager.transform(TEMP_RECT, transform);
  SWTShapeManager.awtToSWT(TEMP_RECT, SWT_RECT);
  org.eclipse.swt.graphics.Rectangle clip = gc.getClipping();
  clip = clip.intersection(SWT_RECT);
  gc.setClipping(clip);
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

void fillRegion(GC gc, Region region) {
  // NOTE: region passed in to this function will be modified
  Region clipping = new Region();
  gc.getClipping(clipping);
  region.intersect(clipping);
  gc.setClipping(region);
  gc.fillRectangle(region.getBounds());
  gc.setClipping(clipping);
  clipping.dispose();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

void fillRegion(GC gc, Region region) {
  // NOTE: region passed in to this function will be modified
  Region clipping = new Region();
  gc.getClipping(clipping);
  region.intersect(clipping);
  gc.setClipping(region);
  gc.fillRectangle(region.getBounds());
  gc.setClipping(clipping);
  clipping.dispose();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

void fillRegion(GC gc, Region region) {
  // NOTE: region passed in to this function will be modified
  Region clipping = new Region();
  gc.getClipping(clipping);
  region.intersect(clipping);
  gc.setClipping(region);
  gc.fillRectangle(region.getBounds());
  gc.setClipping(clipping);
  clipping.dispose();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

void fillRegion(GC gc, Region region) {
  // NOTE: region passed in to this function will be modified
  Region clipping = new Region();
  gc.getClipping(clipping);
  region.intersect(clipping);
  gc.setClipping(region);
  gc.fillRectangle(region.getBounds());
  gc.setClipping(clipping);
  clipping.dispose();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

void fillRegion(GC gc, Region region) {
  // NOTE: region passed in to this function will be modified
  Region clipping = new Region();
  gc.getClipping(clipping);
  region.intersect(clipping);
  gc.setClipping(region);
  gc.fillRectangle(region.getBounds());
  gc.setClipping(clipping);
  clipping.dispose();
}

代码示例来源:origin: org.eclipse.mylyn.commons/workbench

private void expandRegion(Event event, Scrollable scrollable, GC gc, Rectangle area) {
    int columnCount;
    if (scrollable instanceof Table) {
      columnCount = ((Table) scrollable).getColumnCount();
    } else {
      columnCount = ((Tree) scrollable).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();
      }
    }
  }
};

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

int numColumns = orderedColumns.length;
GC gc = event.gc;
Rectangle clipping = gc.getClipping ();
int startColumn = -1, endColumn = -1;
if (numColumns > 0) {

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

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()) {
    
    // avoid painting into the margins:
    Rectangle clipping= gc.getClipping();
    Rectangle clientArea= fTextWidget.getClientArea();
    int leftMargin= fTextWidget.getLeftMargin();
    int rightMargin= fTextWidget.getRightMargin();
    clientArea.x+= leftMargin;
    clientArea.width-= leftMargin + rightMargin;
    clipping.intersect(clientArea);
    gc.setClipping(clientArea);
    if (fIsAdvancedGraphicsPresent) {
      int alpha= gc.getAlpha();
      gc.setAlpha(fAlpha);
      drawLineRange(gc, startLine, endLine, x, w);
      gc.setAlpha(alpha);
    } else {
      drawLineRange(gc, startLine, endLine, x, w);
    }
    gc.setClipping(clipping);
  }
}

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

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()) {
    // avoid painting into the margins:
    Rectangle clipping= gc.getClipping();
    Rectangle clientArea= fTextWidget.getClientArea();
    int leftMargin= fTextWidget.getLeftMargin();
    int rightMargin= fTextWidget.getRightMargin();
    clientArea.x+= leftMargin;
    clientArea.width-= leftMargin + rightMargin;
    clipping.intersect(clientArea);
    gc.setClipping(clientArea);
    if (fIsAdvancedGraphicsPresent) {
      int alpha= gc.getAlpha();
      gc.setAlpha(fAlpha);
      drawLineRange(gc, startLine, endLine, x, w);
      gc.setAlpha(alpha);
    } else {
      drawLineRange(gc, startLine, endLine, x, w);
    }
    gc.setClipping(clipping);
  }
}

相关文章

GC类方法