本文整理了Java中org.eclipse.swt.graphics.GC.copyArea()
方法的一些代码示例,展示了GC.copyArea()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.copyArea()
方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:copyArea
[英]Copies a rectangular area of the receiver at the source position onto the receiver at the destination position.
[中]将源位置接收器的矩形区域复制到目标位置的接收器上。
代码示例来源:origin: stackoverflow.com
final Image image = new Image(display, browser.getBounds());
GC gc = new GC(browser);
gc.copyArea(image, 0, 0);
gc.dispose();
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
/**
* Copies a rectangular area of the receiver at the source
* position onto the receiver at the destination position.
*
* @param srcX the x coordinate in the receiver of the area to be copied
* @param srcY the y coordinate in the receiver of the area to be copied
* @param width the width of the area to copy
* @param height the height of the area to copy
* @param destX the x coordinate in the receiver of the area to copy to
* @param destY the y coordinate in the receiver of the area to copy to
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void copyArea (int srcX, int srcY, int width, int height, int destX, int destY) {
copyArea (srcX, srcY, width, height, destX, destY, true);
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
/**
* Copies a rectangular area of the receiver at the source
* position onto the receiver at the destination position.
*
* @param srcX the x coordinate in the receiver of the area to be copied
* @param srcY the y coordinate in the receiver of the area to be copied
* @param width the width of the area to copy
* @param height the height of the area to copy
* @param destX the x coordinate in the receiver of the area to copy to
* @param destY the y coordinate in the receiver of the area to copy to
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
copyArea(srcX, srcY, width, height, destX, destY, true);
}
/**
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/**
* Copies the image to the specified position.
*
* @param img swt image to be copied
* @param x x component of position
* @param y y component of position
*/
public void copyArea(final org.eclipse.swt.graphics.Image img, final double x, final double y) {
TEMP_POINT.setLocation(x, y);
transform.transform(TEMP_POINT, TEMP_POINT);
gc.copyArea(img, (int) (TEMP_POINT.getX() + 0.5), (int) (TEMP_POINT.getY() + 0.5));
}
代码示例来源:origin: stackoverflow.com
Image image = new Image(e.display, 1, 1);
GC gc = new GC((Canvas)e.widget);
gc.copyArea(image, e.x, e.y);
代码示例来源:origin: stackoverflow.com
Tree myWidget = treeViewer.getTree();
Point size = myWidget.getSize();
Image image = new Image(display, size.x, size.y);
GC gc = new GC(myWidget);
gc.copyArea(image, 0, 0);
gc.dispose();
// Get the ImageData and create a new printer Image from it
ImageData imageData = image.getImageData();
Image printImage = new Image(printer, imageData);
http://www.eclipse.org/swt/faq.php#noprintimage
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/** {@inheritDoc} */
public void copyArea(final int x, final int y, final int width, final int height, final int dx, final int dy) {
TEMP_RECT.setRect(x, y, width, height);
SWTShapeManager.transform(TEMP_RECT, transform);
TEMP_POINT.setLocation(dx, dy);
transform.transform(TEMP_POINT, TEMP_POINT);
gc.copyArea((int) TEMP_RECT.getX(), (int) TEMP_RECT.getY(), (int) TEMP_RECT.getWidth(), (int) TEMP_RECT
.getHeight(), (int) TEMP_POINT.getX(), (int) TEMP_POINT.getY());
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private void captureImages() {
for (Iterator iterator = getStartRects().iterator(); iterator.hasNext();) {
Rectangle rect = (Rectangle) iterator.next();
Image image = new Image(display, rect.width, rect.height);
GC gc = new GC(backingStore);
gc.copyArea(image, rect.x, rect.y);
gc.dispose();
ImageCanvas canvas = new ImageCanvas(theShell, SWT.BORDER
| SWT.NO_BACKGROUND, image);
controls.add(canvas);
}
}
代码示例来源:origin: stackoverflow.com
gc.copyArea(image, this.getShell().getBounds().x, this.getShell().getBounds().y);
gc.dispose();
代码示例来源:origin: stackoverflow.com
GC gc = new GC(viewer.getControl());
Rectangle bounds = viewer.getControl().getBounds();
Image image = new Image(viewer.getControl().getDisplay(), bounds);
try {
gc.copyArea(image, 0, 0);
ImageLoader imageLoader = new ImageLoader();
imageLoader.data = new ImageData[] { image.getImageData() };
imageLoader.save("c:\\out.png", SWT.IMAGE_PNG);
} finally {
image.dispose();
gc.dispose();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void onScrollVertical (Event event) {
ScrollBar vBar = getVerticalBar ();
if (vBar == null) return;
int newSelection = vBar.getSelection ();
update ();
GC gc = new GC (this);
gc.copyArea (
0, 0,
clientArea.width, clientArea.height,
0, (topIndex - newSelection) * itemHeight);
gc.dispose ();
topIndex = newSelection;
}
void onSpace () {
代码示例来源:origin: org.eclipse.mylyn.commons/screenshots
public void run() {
disposeImageResources();
Rectangle displayBounds = display.getBounds();
originalImage = new Image(display, displayBounds.width, displayBounds.height);
workImage = new Image(display, displayBounds.width, displayBounds.height);
GC gc = new GC(display);
gc.copyArea(originalImage, displayBounds.x, displayBounds.y);
gc.copyArea(workImage, displayBounds.x, displayBounds.y);
gc.dispose();
workImageGC = new GC(workImage);
workImageGC.setLineCap(SWT.CAP_ROUND);
scrolledComposite.setEnabled(true);
clearSelection();
refreshCanvasSize();
wizardShell.setVisible(true);
stateChanged();
}
});
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void onArrowLeft (int stateMask) {
if (horizontalOffset == 0) return;
int newSelection = Math.max (0, horizontalOffset - SIZE_HORIZONTALSCROLL);
update ();
GC gc = new GC (this);
gc.copyArea (
0, 0,
clientArea.width, clientArea.height,
horizontalOffset - newSelection, 0);
gc.dispose ();
if (header.getVisible ()) {
header.update ();
Rectangle headerClientArea = header.getClientArea ();
gc = new GC (header);
gc.copyArea (
0, 0,
headerClientArea.width, headerClientArea.height,
horizontalOffset - newSelection, 0);
gc.dispose();
}
horizontalOffset = newSelection;
ScrollBar hBar = getHorizontalBar ();
if (hBar != null) hBar.setSelection (horizontalOffset);
}
void onArrowRight (int stateMask) {
代码示例来源:origin: org.xworker/xworker_swt
public static ClipScreen create(){
//获取display
Display display = Display.getCurrent();
boolean closeDisplayOnEnd = false;
if(display == null){
display = new Display();
closeDisplayOnEnd = true;
}
//截取屏幕
Rectangle screenREc = display.getBounds();
Image screenImage = new Image(display, screenREc.width, screenREc.height);
GC gc = new GC(display);
gc.copyArea(screenImage, 0, 0);
gc.dispose();
ClipScreen dialog = new ClipScreen(display, screenImage, closeDisplayOnEnd);
return dialog;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void onScrollHorizontal (Event event) {
ScrollBar hBar = getHorizontalBar ();
if (hBar == null) return;
int newSelection = hBar.getSelection ();
update ();
if (itemsCount > 0) {
GC gc = new GC (this);
gc.copyArea (
0, 0,
clientArea.width, clientArea.height,
horizontalOffset - newSelection, 0);
gc.dispose ();
} else {
redraw (); /* ensure that static focus rectangle updates properly */
}
if (drawCount <= 0 && header.isVisible ()) {
header.update ();
Rectangle headerClientArea = header.getClientArea ();
GC gc = new GC (header);
gc.copyArea (
0, 0,
headerClientArea.width, headerClientArea.height,
horizontalOffset - newSelection, 0);
gc.dispose ();
}
horizontalOffset = newSelection;
}
void onScrollVertical (Event event) {
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public void initialize(AnimationEngine engine) {
display = getAnimationShell().getDisplay();
Rectangle psRect = getAnimationShell().getBounds();
theShell = new Shell(getAnimationShell(), SWT.NO_TRIM | SWT.ON_TOP);
theShell.setBounds(getAnimationShell().getBounds());
// Capture the background image
backingStore = new Image(theShell.getDisplay(), psRect);
GC gc = new GC(display);
gc.copyArea(backingStore, psRect.x, psRect.y);
gc.dispose();
// changeCoordinates();
// captureImages();
theShell.setBackgroundImage(backingStore);
theShell.setVisible(true);
display.update();
}
代码示例来源:origin: BiglySoftware/BiglyBT
private void updateGraph(CLabelPadding label, Image img,
long newVal, long[] max) {
GC gc = new GC(img);
try {
long val = newVal;
Rectangle bounds = img.getBounds();
final int padding = 2;
int x = bounds.width - padding - padding;
if (val > max[0]) {
int y = 20 - (int) (max[0] * 20 / val);
gc.setBackground(label.getBackground());
gc.fillRectangle(padding, 0, x, y);
// gc.drawImage(imgRec, 1, 0, x, 20, 0, y, x, 20 - y);
gc.copyArea(padding + 1, 0, x, 20, padding, y);
max[0] = val;
} else {
gc.copyArea(padding + 1, 0, x, 20, padding, 0);
// gc.drawImage(imgRec, 1, 0, x, 20, 0, 0, x, 20);
}
gc.setForeground(label.getBackground());
int breakPoint = 20 - (max[0] == 0 ? 0
: (int) (val * 20 / max[0]));
gc.drawLine(x, 0, x, breakPoint);
gc.setForeground(Colors.blues[5]);
gc.drawLine(x, breakPoint, x, 20);
} finally {
gc.dispose();
}
label.redraw();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public void initialize(AnimationEngine engine) {
Rectangle psRect = getBaseShell().getBounds();
getAnimationShell().setBounds(psRect);
// Capture the background image
Display display = getBaseShell().getDisplay();
backingStore = new Image(display, psRect);
GC gc = new GC(display);
// gc.copyArea(backingStore, psRect.x, psRect.y);
gc.copyArea(backingStore, psRect.x, psRect.y);
gc.dispose();
getAnimationShell().setAlpha(254);
getAnimationShell().setBackgroundImage(backingStore);
getAnimationShell().setVisible(true);
}
代码示例来源:origin: org.eclipse.xtext/ui
public void freeze() {
release();
if (sourceViewer instanceof SourceViewer) {
Control viewerControl = ((SourceViewer) sourceViewer).getControl();
if (viewerControl instanceof Composite) {
Composite composite = (Composite) viewerControl;
Display display = composite.getDisplay();
// Flush pending redraw requests:
while (!display.isDisposed() && display.readAndDispatch()) {
}
// Copy editor area:
GC gc = new GC(composite);
Point size;
try {
size = composite.getSize();
image = new Image(gc.getDevice(), size.x, size.y);
gc.copyArea(image, 0, 0);
} finally {
gc.dispose();
gc = null;
}
// Persist editor area while executing refactoring:
label = new Label(composite, SWT.NONE);
label.setImage(image);
label.setBounds(0, 0, size.x, size.y);
label.moveAbove(null);
}
}
}
代码示例来源:origin: org.xworker/xworker_swt
gc.copyArea(screenImage, x, y);
gc.dispose();
内容来源于网络,如有侵权,请联系作者删除!