本文整理了Java中org.eclipse.swt.widgets.Canvas.scroll()
方法的一些代码示例,展示了Canvas.scroll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Canvas.scroll()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Canvas
类名称:Canvas
方法名:scroll
[英]Scrolls a rectangular area of the receiver by first copying the source area to the destination and then causing the area of the source which is not covered by the destination to be repainted. Children that intersect the rectangle are optionally moved during the operation. In addition, all outstanding paint events are flushed before the source area is copied to ensure that the contents of the canvas are drawn correctly.
[中]滚动接收器的矩形区域,首先将源区域复制到目标,然后重新绘制目标未覆盖的源区域。与矩形相交的子对象可以在操作过程中随意移动。此外,在复制源区域之前,将刷新所有未完成的绘制事件,以确保正确绘制画布的内容。
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void scrollVertically(ScrollBar scrollBar) {
if (image == null) return;
Rectangle canvasBounds = imageCanvas.getClientArea();
int width = Math.round(imageData.width * xscale);
int height = Math.round(imageData.height * yscale);
if (height > canvasBounds.height) {
// Only scroll if the image is bigger than the canvas.
int y = -scrollBar.getSelection();
if (y + height < canvasBounds.height) {
// Don't scroll past the end of the image.
y = canvasBounds.height - height;
}
imageCanvas.scroll(ix, y, ix, iy, width, height, false);
iy = y;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void scrollHorizontally(ScrollBar scrollBar) {
if (image == null) return;
Rectangle canvasBounds = imageCanvas.getClientArea();
int width = Math.round(imageData.width * xscale);
int height = Math.round(imageData.height * yscale);
if (width > canvasBounds.width) {
// Only scroll if the image is bigger than the canvas.
int x = -scrollBar.getSelection();
if (x + width < canvasBounds.width) {
// Don't scroll past the end of the image.
x = canvasBounds.width - width;
}
imageCanvas.scroll(x, iy, ix, iy, width, height, false);
ix = x;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/**
* Handles a horizontal scroll event
*
* @param scrollbar the horizontal scroll bar that posted this event
*/
public void scrollHorizontally(ScrollBar scrollBar) {
if (image == null) return;
if (imageWidth > visibleWidth) {
final int oldOffset = displayFDC.xOffset;
final int newOffset = Math.min(scrollBar.getSelection(), imageWidth - visibleWidth);
if (oldOffset != newOffset) {
paintCanvas.update();
displayFDC.xOffset = newOffset;
paintCanvas.scroll(Math.max(oldOffset - newOffset, 0), 0, Math.max(newOffset - oldOffset, 0), 0,
visibleWidth, visibleHeight, false);
}
}
}
代码示例来源:origin: com.github.rinde/rinsim-pdptw
@Override
public void handleEvent(@Nullable org.eclipse.swt.widgets.Event e) {
final int hSelection = hBar.getSelection();
final int destX = -hSelection - origin.x;
canvas.get().scroll(destX, 0, 0, 0, timeline.getWidth(),
timeline.getHeight(), false);
barCanvas.get().scroll(destX, 0, 0, 0,
timelineBar.contents.getBounds().width,
timelineBar.contents.getBounds().height, false);
origin.x = -hSelection;
}
});
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(@Nullable org.eclipse.swt.widgets.Event e) {
final int hSelection = hBar.getSelection();
final int destX = -hSelection - origin.x;
canvas.get().scroll(destX, 0, 0, 0, timeline.getWidth(),
timeline.getHeight(), false);
barCanvas.get().scroll(destX, 0, 0, 0,
timelineBar.contents.getBounds().width,
timelineBar.contents.getBounds().height, false);
origin.x = -hSelection;
}
});
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/**
* Handles a vertical scroll event
*
* @param scrollbar the vertical scroll bar that posted this event
*/
public void scrollVertically(ScrollBar scrollBar) {
if (image == null) return;
if (imageHeight > visibleHeight) {
final int oldOffset = displayFDC.yOffset;
final int newOffset = Math.min(scrollBar.getSelection(), imageHeight - visibleHeight);
if (oldOffset != newOffset) {
paintCanvas.update();
displayFDC.yOffset = newOffset;
paintCanvas.scroll(0, Math.max(oldOffset - newOffset, 0), 0, Math.max(newOffset - oldOffset, 0),
visibleWidth, visibleHeight, false);
}
}
}
代码示例来源:origin: com.github.rinde/rinsim-pdptw
@Override
public void handleEvent(@Nullable org.eclipse.swt.widgets.Event e) {
final int vSelection = vBar.getSelection();
final int destY = -vSelection - origin.y;
canvas.get().scroll(0, destY, 0, 0, timeline.getWidth(),
timeline.getHeight(), false);
origin.y = -vSelection;
}
});
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/**
* Scrolls the canvas horizontally.
*
* @param scrollBar
*/
void scrollHorizontal (ScrollBar scrollBar) {
Rectangle bounds = canvas.getClientArea();
int x = -scrollBar.getSelection();
if (x + maxX < bounds.width) {
x = bounds.width - maxX;
}
canvas.scroll(x, cy, cx, cy, maxX, maxY, false);
cx = x;
}
代码示例来源:origin: rinde/RinSim
@Override
public void handleEvent(@Nullable org.eclipse.swt.widgets.Event e) {
final int vSelection = vBar.getSelection();
final int destY = -vSelection - origin.y;
canvas.get().scroll(0, destY, 0, 0, timeline.getWidth(),
timeline.getHeight(), false);
origin.y = -vSelection;
}
});
代码示例来源:origin: com.github.rinde/rinsim-problem
@Override
public void handleEvent(@Nullable org.eclipse.swt.widgets.Event e) {
final int vSelection = vBar.getSelection();
final int destY = -vSelection - origin.y;
canvas.scroll(0, destY, 0, 0, timeline.getWidth(),
timeline.getHeight(), false);
origin.y = -vSelection;
}
});
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/**
* Scrolls the canvas vertically.
*
* @param scrollBar
*/
void scrollVertical (ScrollBar scrollBar) {
Rectangle bounds = canvas.getClientArea();
int y = -scrollBar.getSelection();
if (y + maxY < bounds.height) {
y = bounds.height - maxY;
}
canvas.scroll(cx, y, cx, cy, maxX, maxY, false);
cy = y;
}
代码示例来源:origin: com.github.rinde/rinsim-problem
@Override
public void handleEvent(org.eclipse.swt.widgets.Event e) {
final int hSelection = hBar.getSelection();
final int destX = -hSelection - origin.x;
canvas.scroll(destX, 0, 0, 0, timeline.getWidth(),
timeline.getHeight(), false);
barCanvas.scroll(destX, 0, 0, 0,
timelineBar.contents.getBounds().width,
timelineBar.contents.getBounds().height, false);
origin.x = -hSelection;
}
});
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
super.scroll(destX, destY, x, y, width, height, false);
if (all) {
int deltaX = destX - x, deltaY = destY - y;
Control[] children = getChildren();
for (int i=0; i<children.length; i++) {
Control child = children[i];
Rectangle rect = child.getBounds();
child.setLocation(rect.x + deltaX, rect.y + deltaY);
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
@Override
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
super.scroll(destX, destY, x, y, width, height, false);
if (all) {
int deltaX = destX - x, deltaY = destY - y;
Control[] children = getChildren();
for (int i=0; i<children.length; i++) {
Control child = children[i];
Rectangle rect = child.getBounds();
child.setLocation(rect.x + deltaX, rect.y + deltaY);
}
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
@Override
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
super.scroll(destX, destY, x, y, width, height, false);
if (all) {
int deltaX = destX - x, deltaY = destY - y;
Control[] children = getChildren();
for (int i=0; i<children.length; i++) {
Control child = children[i];
Rectangle rect = child.getBounds();
child.setLocation(rect.x + deltaX, rect.y + deltaY);
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
@Override
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
super.scroll(destX, destY, x, y, width, height, false);
if (all) {
int deltaX = destX - x, deltaY = destY - y;
Control[] children = getChildren();
for (int i=0; i<children.length; i++) {
Control child = children[i];
Rectangle rect = child.getBounds();
child.setLocation(rect.x + deltaX, rect.y + deltaY);
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
@Override
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
super.scroll(destX, destY, x, y, width, height, false);
if (all) {
int deltaX = destX - x, deltaY = destY - y;
Control[] children = getChildren();
for (int i=0; i<children.length; i++) {
Control child = children[i];
Rectangle rect = child.getBounds();
child.setLocation(rect.x + deltaX, rect.y + deltaY);
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void scrollPalette(ScrollBar scrollBar) {
if (image == null) return;
Rectangle canvasBounds = paletteCanvas.getClientArea();
int paletteHeight = imageData.palette.getRGBs().length * 10 + 20;
if (paletteHeight > canvasBounds.height) {
// Only scroll if the palette is bigger than the canvas.
int y = -scrollBar.getSelection();
if (y + paletteHeight < canvasBounds.height) {
// Don't scroll past the end of the palette.
y = canvasBounds.height - paletteHeight;
}
paletteCanvas.scroll(0, y, 0, py, paletteWidth, paletteHeight, false);
py = y;
}
}
代码示例来源:origin: rinde/RinSim
void scrollVertical() {
final org.eclipse.swt.graphics.Point center = getCenteredOrigin();
final Rectangle content = image.getBounds();
final Rectangle client = canvas.getClientArea();
if (client.height > content.height) {
origin.y = 0;
} else {
final int vSelection = vBar.getSelection();
final int destY = -vSelection - center.y;
canvas.scroll(center.x, destY, center.x, center.y, content.width,
content.height, false);
origin.y = -vSelection + origin.y - center.y;
}
}
代码示例来源:origin: rinde/RinSim
void scrollHorizontal() {
final org.eclipse.swt.graphics.Point center = getCenteredOrigin();
final Rectangle content = image.getBounds();
final Rectangle client = canvas.getClientArea();
if (client.width > content.width) {
origin.x = 0;
} else {
final int hSelection = hBar.getSelection();
final int destX = -hSelection - center.x;
canvas.scroll(destX, center.y, center.x, center.y, content.width,
content.height, false);
origin.x = -hSelection + origin.x - center.x;
}
}
内容来源于网络,如有侵权,请联系作者删除!