org.eclipse.swt.widgets.Canvas.getClientArea()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(214)

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

Canvas.getClientArea介绍

暂无

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

  1. protected Point getArea() {
  2. org.eclipse.swt.graphics.Rectangle rect = canvas.getClientArea();
  3. Point area = new Point( rect.width, rect.height );
  4. return area;
  5. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. gc.fillRectangle( canvas.getClientArea() );
  2. return;
  3. gc.fillRectangle( canvas.getClientArea() );
  4. gc.setBackgroundPattern( null );
  5. return;

代码示例来源:origin: org.xworker/xworker_swt

  1. @Override
  2. public void paintControl(final PaintEvent e) {
  3. if(clockDrawer != null) {
  4. Rectangle rc = canvas.getClientArea();
  5. clockDrawer.drawClock(date, rc.x, rc.y, rc.width, rc.height, e.gc);
  6. }
  7. }

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

  1. org.eclipse.swt.graphics.Point getCenteredOrigin() {
  2. final Rectangle rect = image.getBounds();
  3. final Rectangle client = canvas.getClientArea();
  4. final int zeroX = client.x + client.width / 2 - rect.width / 2;
  5. final int zeroY = client.y + client.height / 2 - rect.height / 2;
  6. return new org.eclipse.swt.graphics.Point(origin.x + zeroX, origin.y
  7. + zeroY);
  8. }

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

  1. public static void renderClientArea( Canvas canvas ) {
  2. renderProperty( canvas, PROP_CLIENT_AREA, canvas.getClientArea(), null );
  3. }

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

  1. void scrollHorizontally(ScrollBar scrollBar) {
  2. if (image == null) return;
  3. Rectangle canvasBounds = imageCanvas.getClientArea();
  4. int width = Math.round(imageData.width * xscale);
  5. int height = Math.round(imageData.height * yscale);
  6. if (width > canvasBounds.width) {
  7. // Only scroll if the image is bigger than the canvas.
  8. int x = -scrollBar.getSelection();
  9. if (x + width < canvasBounds.width) {
  10. // Don't scroll past the end of the image.
  11. x = canvasBounds.width - width;
  12. }
  13. imageCanvas.scroll(x, iy, ix, iy, width, height, false);
  14. ix = x;
  15. }
  16. }

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

  1. void scrollVertically(ScrollBar scrollBar) {
  2. if (image == null) return;
  3. Rectangle canvasBounds = imageCanvas.getClientArea();
  4. int width = Math.round(imageData.width * xscale);
  5. int height = Math.round(imageData.height * yscale);
  6. if (height > canvasBounds.height) {
  7. // Only scroll if the image is bigger than the canvas.
  8. int y = -scrollBar.getSelection();
  9. if (y + height < canvasBounds.height) {
  10. // Don't scroll past the end of the image.
  11. y = canvasBounds.height - height;
  12. }
  13. imageCanvas.scroll(ix, y, ix, iy, width, height, false);
  14. iy = y;
  15. }
  16. }

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

  1. @Override
  2. void internalSetRedraw( boolean redraw ) {
  3. super.internalSetRedraw( redraw );
  4. if( redraw ) {
  5. repaint( getClientArea() );
  6. }
  7. }

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

  1. /**
  2. * Scrolls the canvas horizontally.
  3. *
  4. * @param scrollBar
  5. */
  6. void scrollHorizontal (ScrollBar scrollBar) {
  7. Rectangle bounds = canvas.getClientArea();
  8. int x = -scrollBar.getSelection();
  9. if (x + maxX < bounds.width) {
  10. x = bounds.width - maxX;
  11. }
  12. canvas.scroll(x, cy, cx, cy, maxX, maxY, false);
  13. cx = x;
  14. }

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

  1. /**
  2. * Scrolls the canvas vertically.
  3. *
  4. * @param scrollBar
  5. */
  6. void scrollVertical (ScrollBar scrollBar) {
  7. Rectangle bounds = canvas.getClientArea();
  8. int y = -scrollBar.getSelection();
  9. if (y + maxY < bounds.height) {
  10. y = bounds.height - maxY;
  11. }
  12. canvas.scroll(cx, y, cx, cy, maxX, maxY, false);
  13. cy = y;
  14. }

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

  1. @Override
  2. public void paintControl(@Nullable PaintEvent e) {
  3. assert e != null;
  4. timelineBar.update(timeline.getWidth());
  5. e.gc.setBackground(
  6. e.display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
  7. e.gc.fillRectangle(0, 0,
  8. barCanvas.get().getClientArea().width,
  9. barCanvas.get().getClientArea().height);
  10. e.gc.drawImage(timelineBar.contents, origin.x, 0);
  11. e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED));
  12. e.gc.drawLine(origin.x + (int) (currentTime / TIME_PER_PIXEL),
  13. FONT_SIZE, origin.x + (int) (currentTime / TIME_PER_PIXEL),
  14. barCanvas.get().getClientArea().height);
  15. }
  16. });

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

  1. @Override
  2. public void preserveValues( Canvas canvas ) {
  3. WidgetLCAUtil.preserveBackgroundGradient( canvas );
  4. WidgetLCAUtil.preserveRoundedBorder( canvas );
  5. WidgetLCAUtil.preserveProperty( canvas, PROP_CLIENT_AREA, canvas.getClientArea() );
  6. }

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

  1. @Override
  2. public void handleEvent(Event e) {
  3. Rectangle bounds = paletteCanvas.getClientArea();
  4. Color color = getColorAt(bounds, e.x, e.y);
  5. if (e.button == 1) setForegroundColor(color);
  6. else setBackgroundColor(color);
  7. }
  8. private Color getColorAt(Rectangle bounds, int x, int y) {

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

  1. void scrollPalette(ScrollBar scrollBar) {
  2. if (image == null) return;
  3. Rectangle canvasBounds = paletteCanvas.getClientArea();
  4. int paletteHeight = imageData.palette.getRGBs().length * 10 + 20;
  5. if (paletteHeight > canvasBounds.height) {
  6. // Only scroll if the palette is bigger than the canvas.
  7. int y = -scrollBar.getSelection();
  8. if (y + paletteHeight < canvasBounds.height) {
  9. // Don't scroll past the end of the palette.
  10. y = canvasBounds.height - paletteHeight;
  11. }
  12. paletteCanvas.scroll(0, y, 0, py, paletteWidth, paletteHeight, false);
  13. py = y;
  14. }
  15. }

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

  1. @Override
  2. void notifyResize( Point oldSize ) {
  3. super.notifyResize( oldSize );
  4. if( !oldSize.equals( getSize() ) ) {
  5. repaint( getClientArea() );
  6. }
  7. }

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

  1. @Override
  2. public void paintControl(PaintEvent e) {
  3. timeline.update();
  4. e.gc.drawImage(timeline.contents, origin.x, origin.y);
  5. e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED));
  6. e.gc.drawLine(origin.x + (int) (currentTime / timeline.timePerPixel),
  7. 0, origin.x + (int) (currentTime / timeline.timePerPixel),
  8. canvas.getClientArea().height);
  9. hBar.setMaximum(timeline.getWidth() == 0 ? 1 : timeline.getWidth() + 20);
  10. vBar.setMaximum(timeline.getHeight() + 5);
  11. hBar.setThumb(Math.min(timeline.getWidth() + 20,
  12. canvas.getClientArea().width));
  13. vBar.setThumb(Math.min(timeline.getHeight() + 5,
  14. canvas.getClientArea().height));
  15. }
  16. });

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

  1. void updateScrollbars(boolean adaptToScrollbar) {
  2. final Rectangle rect = image.getBounds();
  3. final Rectangle client = canvas.getClientArea();
  4. hBar.setMaximum(rect.width);
  5. vBar.setMaximum(rect.height);
  6. hBar.setThumb(Math.min(rect.width, client.width));
  7. vBar.setThumb(Math.min(rect.height, client.height));
  8. if (!adaptToScrollbar) {
  9. final org.eclipse.swt.graphics.Point center = getCenteredOrigin();
  10. hBar.setSelection(-center.x);
  11. vBar.setSelection(-center.y);
  12. }
  13. }

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

  1. @Override
  2. public void handleEvent(Event e) {
  3. Rectangle clientArea = ((Canvas) e.widget).getClientArea();
  4. e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW));
  5. e.gc.drawRectangle(clientArea);
  6. clientArea.y++;
  7. e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
  8. e.gc.drawRectangle(clientArea);
  9. }
  10. });

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

  1. @Override
  2. public void handleEvent(Event e) {
  3. Rectangle clientArea = ((Canvas) e.widget).getClientArea();
  4. e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW));
  5. e.gc.drawRectangle(clientArea);
  6. clientArea.y++;
  7. e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
  8. e.gc.drawRectangle(clientArea);
  9. }
  10. });

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

  1. @Override
  2. public void paintControl(PaintEvent e) {
  3. timelineBar.update(timeline.getWidth());
  4. e.gc.drawImage(timelineBar.contents, origin.x, 0);
  5. e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED));
  6. e.gc.drawLine(origin.x + (int) (currentTime / timeline.timePerPixel),
  7. 10, origin.x + (int) (currentTime / timeline.timePerPixel),
  8. barCanvas.getClientArea().height);
  9. }
  10. });

相关文章

Canvas类方法