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

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

本文整理了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

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

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

gc.fillRectangle( canvas.getClientArea() );
return;
gc.fillRectangle( canvas.getClientArea() );
gc.setBackgroundPattern( null );
return;

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

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

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

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

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

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

代码示例来源: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

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.rap/org.eclipse.rap.rwt

@Override
void internalSetRedraw( boolean redraw ) {
 super.internalSetRedraw( redraw );
 if( redraw ) {
  repaint( getClientArea() );
 }
}

代码示例来源: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: 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-pdptw

@Override
 public void paintControl(@Nullable PaintEvent e) {
  assert e != null;
  timelineBar.update(timeline.getWidth());
  e.gc.setBackground(
   e.display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
  e.gc.fillRectangle(0, 0,
   barCanvas.get().getClientArea().width,
   barCanvas.get().getClientArea().height);
  e.gc.drawImage(timelineBar.contents, origin.x, 0);
  e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED));
  e.gc.drawLine(origin.x + (int) (currentTime / TIME_PER_PIXEL),
   FONT_SIZE, origin.x + (int) (currentTime / TIME_PER_PIXEL),
   barCanvas.get().getClientArea().height);
 }
});

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

@Override
public void preserveValues( Canvas canvas ) {
 WidgetLCAUtil.preserveBackgroundGradient( canvas );
 WidgetLCAUtil.preserveRoundedBorder( canvas );
 WidgetLCAUtil.preserveProperty( canvas, PROP_CLIENT_AREA, canvas.getClientArea() );
}

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

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

代码示例来源: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: org.eclipse.rap/org.eclipse.rap.rwt

@Override
void notifyResize( Point oldSize ) {
 super.notifyResize( oldSize );
 if( !oldSize.equals( getSize() ) ) {
  repaint( getClientArea() );
 }
}

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

@Override
 public void paintControl(PaintEvent e) {
  timeline.update();
  e.gc.drawImage(timeline.contents, origin.x, origin.y);
  e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED));
  e.gc.drawLine(origin.x + (int) (currentTime / timeline.timePerPixel),
    0, origin.x + (int) (currentTime / timeline.timePerPixel),
    canvas.getClientArea().height);
  hBar.setMaximum(timeline.getWidth() == 0 ? 1 : timeline.getWidth() + 20);
  vBar.setMaximum(timeline.getHeight() + 5);
  hBar.setThumb(Math.min(timeline.getWidth() + 20,
    canvas.getClientArea().width));
  vBar.setThumb(Math.min(timeline.getHeight() + 5,
    canvas.getClientArea().height));
 }
});

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

void updateScrollbars(boolean adaptToScrollbar) {
 final Rectangle rect = image.getBounds();
 final Rectangle client = canvas.getClientArea();
 hBar.setMaximum(rect.width);
 vBar.setMaximum(rect.height);
 hBar.setThumb(Math.min(rect.width, client.width));
 vBar.setThumb(Math.min(rect.height, client.height));
 if (!adaptToScrollbar) {
  final org.eclipse.swt.graphics.Point center = getCenteredOrigin();
  hBar.setSelection(-center.x);
  vBar.setSelection(-center.y);
 }
}

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

@Override
  public void handleEvent(Event e) {
    Rectangle clientArea = ((Canvas) e.widget).getClientArea();
    e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW));
    e.gc.drawRectangle(clientArea);
    clientArea.y++;
    e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
    e.gc.drawRectangle(clientArea);
  }
});

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

@Override
  public void handleEvent(Event e) {
    Rectangle clientArea = ((Canvas) e.widget).getClientArea();
    e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW));
    e.gc.drawRectangle(clientArea);
    clientArea.y++;
    e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
    e.gc.drawRectangle(clientArea);
  }
});

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

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

相关文章

Canvas类方法