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

x33g5p2x  于2022-01-29 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(120)

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

Region.subtract介绍

[英]Subtracts the given rectangle from the collection of polygons the receiver maintains to describe its area.
[中]从接收器用来描述其面积的多边形集合中减去给定的矩形。

代码示例

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

@Override
public void updateRegion(Region region) {
  outerRect = new Rectangle(innerRect.x - width, innerRect.y - width,
      innerRect.width + (2 * width), innerRect.height
          + (2 * width));
  region.add(outerRect);
  region.subtract(innerRect);
}

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

@Override
public void updateRegion(Region region) {
  outerRect = new Rectangle(innerRect.x - width, innerRect.y - width,
      innerRect.width + (2 * width), innerRect.height
          + (2 * width));
  region.add(outerRect);
  region.subtract(innerRect);
}

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

/**
 * Subtracts the given rectangle from the collection of polygons
 * the receiver maintains to describe its area.
 *
 * @param rect the rectangle to subtract from the receiver
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
 *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
 * </ul>
 * 
 * @since 3.0
 */
public void subtract(Rectangle rect) {
  if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
  if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
  subtract (rect.x, rect.y, rect.width, rect.height);
}

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

@Override
public void renderStep(AnimationEngine engine) {
  if (shellRegion != null) {
    shellRegion.dispose();
    shellRegion = new Region(getAnimationShell().getDisplay());
  }
  // Iterate across the set of start/end rects
  Iterator currentRects = getCurrentRects(engine.amount()).iterator();
  while (currentRects.hasNext()) {
    Rectangle curRect = (Rectangle) currentRects.next();
    Rectangle rect = Geometry.toControl(getAnimationShell(), curRect);
    shellRegion.add(rect);
    rect.x += LINE_WIDTH;
    rect.y += LINE_WIDTH;
    rect.width = Math.max(0, rect.width - 2 * LINE_WIDTH);
    rect.height = Math.max(0, rect.height - 2 * LINE_WIDTH);
    shellRegion.subtract(rect);
  }
  getAnimationShell().setRegion(shellRegion);
  getAnimationShell().getDisplay().update();
}

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

/**
 * Subtracts the given rectangle from the collection of polygons
 * the receiver maintains to describe its area.
 *
 * @param x the x coordinate of the rectangle
 * @param y the y coordinate of the rectangle
 * @param width the width coordinate of the rectangle
 * @param height the height coordinate of the rectangle
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
 * </ul>
 *
 * @since 3.1
 */
public void subtract(int x, int y, int width, int height) {
  if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
  if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
  subtract(new Rectangle(x, y, width, height));
}

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

/**
 * Subtracts the given rectangle from the collection of polygons
 * the receiver maintains to describe its area.
 *
 * @param x the x coordinate of the rectangle
 * @param y the y coordinate of the rectangle
 * @param width the width coordinate of the rectangle
 * @param height the height coordinate of the rectangle
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
 * </ul>
 *
 * @since 3.1
 */
public void subtract(int x, int y, int width, int height) {
  if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
  if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
  subtract(new Rectangle(x, y, width, height));
}

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

/**
 * Subtracts the given rectangle from the collection of polygons
 * the receiver maintains to describe its area.
 *
 * @param x the x coordinate of the rectangle
 * @param y the y coordinate of the rectangle
 * @param width the width coordinate of the rectangle
 * @param height the height coordinate of the rectangle
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
 * </ul>
 *
 * @since 3.1
 */
public void subtract(int x, int y, int width, int height) {
  if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
  if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
  subtract(new Rectangle(x, y, width, height));
}

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

public void setDragHost(Shell hostingShell, int xOffset, int yOffset) {
  dragHost = hostingShell;
  offsetX = xOffset;
  offsetY = yOffset;
  dragHostBounds = null;
  if (dragHost == null)
    return;
  // Punch a 'hole' where the cursor is using a region
  Region rgn = dragHost.getRegion();
  // if (rgn != null && !rgn.isDisposed())
  // rgn.dispose();
  // rgn = new Region(display);
  Rectangle bounds = dragHost.getBounds();
  rgn.add(0, 0, bounds.width, bounds.height);
  rgn.subtract(offsetX, offsetY, 1, 1);
  dragHost.setRegion(rgn);
  initialHostSize = dragHost.getSize();
  // Do an initial 'track'
  Point curLoc = dragHost.getDisplay().getCursorLocation();
  dragHost.setLocation(curLoc.x - offsetX, curLoc.y - offsetY);
  dragHost.layout(true);
}

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

public void setDragHost(Shell hostingShell, int xOffset, int yOffset) {
  dragHost = hostingShell;
  offsetX = xOffset;
  offsetY = yOffset;
  dragHostBounds = null;
  if (dragHost == null) {
    return;
  }
  // Punch a 'hole' where the cursor is using a region
  Region rgn = dragHost.getRegion();
  // if (rgn != null && !rgn.isDisposed())
  // rgn.dispose();
  // rgn = new Region(display);
  Rectangle bounds = dragHost.getBounds();
  rgn.add(0, 0, bounds.width, bounds.height);
  rgn.subtract(offsetX, offsetY, 1, 1);
  dragHost.setRegion(rgn);
  initialHostSize = dragHost.getSize();
  // Do an initial 'track'
  Point curLoc = dragHost.getDisplay().getCursorLocation();
  dragHost.setLocation(curLoc.x - offsetX, curLoc.y - offsetY);
  dragHost.layout(true);
}

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

private void defineRegion() {
  Region rgn = new Region();
  for (Rectangle r : rects) {
    rgn.add(r);
    rgn.subtract(r.x + 2, r.y + 2, r.width - 4, r.height - 4);
  }
  if (feedbackShell.getRegion() != null && !feedbackShell.getRegion().isDisposed())
    feedbackShell.getRegion().dispose();
  feedbackShell.setRegion(rgn);
  feedbackShell.redraw();
  display.update();
}

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

public void update() {
  final Display display = Display.getCurrent();
  if (display == null)
    return;
  reset();
  cursorPos = display.getCursorLocation();
  if (dragHost != null && !dragHost.isDisposed() && dragHost.getVisible()) {
    if (dragHostBounds == null) {
      // First move the dragHost so that its 'hole' is where the mouse is
      dragHost.setLocation(cursorPos.x - offsetX, cursorPos.y - offsetY);
    } else {
      // Move the 'hole' to where the cursor is
      Point cursorLoc = display.getCursorLocation();
      cursorLoc = display.map(null, dragHost, cursorLoc);
      Region rgn = dragHost.getRegion();
      Rectangle bounds = dragHost.getBounds();
      rgn.add(0, 0, bounds.width, bounds.height);
      rgn.subtract(cursorLoc.x, cursorLoc.y, 1, 1);
    }
  }
  curCtrl = display.getCursorControl();
  if (curCtrl == null)
    return;
  curElement = getModelElement(curCtrl);
  setItemInfo();
}

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

public void setDragHostBounds(Rectangle displayRect) {
  if (dragHost == null) {
    return;
  }
  dragHostBounds = displayRect;
  // Re-attach the drag host to the cursor
  if (dragHostBounds == null) {
    dragHost.setSize(initialHostSize);
    setDragHost(dragHost, offsetX, offsetY);
    return;
  }
  // dragHost.setVisible(false);
  dragHost.setAlpha(200);
  dragHost.setBounds(dragHostBounds);
  // punch a 'hole' where the cursor *is*
  Point cursorLoc = display.getCursorLocation();
  cursorLoc = display.map(null, dragHost, cursorLoc);
  Region rgn = dragHost.getRegion();
  Rectangle bounds = dragHost.getBounds();
  rgn.add(0, 0, bounds.width, bounds.height);
  rgn.subtract(cursorLoc.x, cursorLoc.y, 1, 1);
  display.update();
}

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

public void setDragHostBounds(Rectangle displayRect) {
  if (dragHost == null)
    return;
  dragHostBounds = displayRect;
  // Re-attach the drag host to the cursor
  if (dragHostBounds == null) {
    dragHost.setSize(initialHostSize);
    setDragHost(dragHost, offsetX, offsetY);
    return;
  }
  // dragHost.setVisible(false);
  dragHost.setAlpha(200);
  dragHost.setBounds(dragHostBounds);
  // punch a 'hole' where the cursor *is*
  Point cursorLoc = display.getCursorLocation();
  cursorLoc = display.map(null, dragHost, cursorLoc);
  Region rgn = dragHost.getRegion();
  Rectangle bounds = dragHost.getBounds();
  rgn.add(0, 0, bounds.width, bounds.height);
  rgn.subtract(cursorLoc.x, cursorLoc.y, 1, 1);
  display.update();
}

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

rgn.add(outerBounds);
  Rectangle innerBounds = new Rectangle(x, y, frameRect.width, frameRect.height);
  rgn.subtract(innerBounds);
} else {
  Rectangle itemBounds = new Rectangle(x, y, frameRect.width, frameRect.height);

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

Rectangle bounds = dragHost.getBounds();
rgn.add(0, 0, bounds.width, bounds.height);
rgn.subtract(cursorLoc.x, cursorLoc.y, 1, 1);

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

private void defineRegion() {
  Region rgn = new Region();
  for (Rectangle r : rects) {
    rgn.add(r);
    rgn.subtract(r.x + 2, r.y + 2, r.width - 4, r.height - 4);
  }
  // Workaround: Some window managers draw a drop shadow even if the shell
  // is set to NO_TRIM. By making the shell contain a component in the
  // bottom-right of its parent shell, SWT won't resize it and any extra
  // shadows will end up being drawn on top of the shadows for the parent
  // shell rather than in the middle of the workbench window.
  Composite parent = feedbackShell.getParent();
  if (parent instanceof Shell) {
    Shell parentShell = (Shell) parent;
    Rectangle bounds = parentShell.getBounds();
    rgn.add(bounds.width - 1, bounds.height - 1, 1, 1);
  }
  if (feedbackShell.getRegion() != null && !feedbackShell.getRegion().isDisposed()) {
    feedbackShell.getRegion().dispose();
  }
  feedbackShell.setRegion(rgn);
  feedbackShell.redraw();
  display.update();
}

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

rgn.add(outerBounds);
  Rectangle innerBounds = new Rectangle(x, y, frameRect.width, frameRect.height);
  rgn.subtract(innerBounds);
} else {
  Rectangle itemBounds = new Rectangle(x, y, frameRect.width, frameRect.height);

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

simpleCurveClose[index++] = bounds.width;
simpleCurveClose[index++] = bounds.height;
r.subtract(simpleCurveClose);
Region clipping = new Region();
gc.getClipping(clipping);

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

invertedSelection.subtract(inside);
gc.setClipping(invertedSelection);
gc.fillRectangle(canvas.getClientArea());

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

case 3:
  region1.subtract(region2);
  break;
case 4:

相关文章