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

x33g5p2x  于2022-01-19 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(205)

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

GC.drawLine介绍

[英]Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
[中]使用前景色在点(x1y1和(x2y2之间绘制一条线。

代码示例

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

public void drawLine( int x, int y, int x2, int y2 ) {
 gc.drawLine( x, y, x2, y2 );
}

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

public void drawLine( int x, int y, int x2, int y2 ) {
 gc.drawLine( x, y, x2, y2 );
}

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

private void repaint( GC gc, int width, int height ) {
 ImageData imd = image.getImageData();
 double sizeOnPaperX = imd.width * factorx;
 double sizeOnPaperY = imd.height * factory;
 double actualSizeX = sizeOnPaperX * scale / 100;
 double actualSizeY = sizeOnPaperY * scale / 100;
 // What % of the screen is filled?
 // The canvas is nrcols * nrrows nr of pages large.
 double percentScreenX = actualSizeX / ( page.x * nrcols );
 double percentScreenY = actualSizeY / ( page.y * nrrows );
 gc.drawImage(
  image, 0, 0, imd.width, imd.height, 0, 0, (int) ( width * percentScreenX ),
  (int) ( height * percentScreenY ) );
 StringBuilder text = new StringBuilder();
 text.append( nrcols ).append( "x" ).append( nrrows ).append( " @ " ).append( scale ).append( "%" );
 gc.drawText( text.toString(), 0, 0 );
 for ( int c = 1; c < nrcols; c++ ) {
  gc.drawLine( c * ( width / nrcols ), 0, c * ( width / nrcols ), height );
 }
 for ( int r = 1; r < nrrows; r++ ) {
  gc.drawLine( 0, r * ( height / nrrows ), width, r * ( height / nrrows ) );
 }
}

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

private void drawMarker( GC gc, int x, int maxy ) {
 int[] triangle =
  new int[] {
   LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3,
   TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 };
 gc.fillPolygon( triangle );
 gc.drawPolygon( triangle );
 gc
  .drawLine(
   LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy );
}

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

private void drawMarker( GC gc, int x, int maxy ) {
 int[] triangle =
  new int[] {
   LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3,
   TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 };
 gc.fillPolygon( triangle );
 gc.drawPolygon( triangle );
 gc
  .drawLine(
   LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy );
}

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

gc.drawLine( x1, y1, x2, y2 );

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

/**
 * Get the image for when all other fallbacks have failed.  This is an image
 * drawn on the canvas, a square with a red X.
 *
 * @param display the device to render the image to
 * @return the missing image
 */
public static SwtUniversalImage getMissingImage( Display display ) {
 Image img = new Image( display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE );
 GC gc = new GC( img );
 gc.setForeground( new Color( display, 0, 0, 0 ) );
 gc.drawRectangle( 4, 4, ConstUI.ICON_SIZE - 8, ConstUI.ICON_SIZE - 8 );
 gc.setForeground( new Color( display, 255, 0, 0 ) );
 gc.drawLine( 4, 4, ConstUI.ICON_SIZE - 4, ConstUI.ICON_SIZE - 4 );
 gc.drawLine( ConstUI.ICON_SIZE - 4, 4, 4, ConstUI.ICON_SIZE - 4 );
 gc.dispose();
 return new SwtUniversalImageBitmap( img );
}

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

gc.setBackground( bg );
gc.drawLine( LEFT + MARGIN, linepos, area.x, linepos );
  gc.drawLine(
   LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x,
   linepos - 5 );
 } else {
  gc.drawLine(
   LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x,
   linepos - 3 );
gc.fillRectangle( 0, TOP, LEFT, area.y );
gc.drawLine( LEFT, TOP, LEFT, area.y );
 int numsize = number.length() * fontwidth;
 gc.drawText( number, LEFT - 5 - numsize, TOP + i * ( fontheight + 2 ) + offset.y, true );
 gc.drawLine( LEFT, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y, LEFT - 5, TOP
  + ( i + 1 ) * ( fontheight + 2 ) + offset.y );

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

gc.setBackground( bg );
gc.drawLine( LEFT + MARGIN, linepos, area.x, linepos );
  gc.drawLine(
   LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x,
   linepos - 5 );
 } else {
  gc.drawLine(
   LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x,
   linepos - 3 );
gc.fillRectangle( 0, TOP, LEFT, area.y );
gc.drawLine( LEFT, TOP, LEFT, area.y );
 int numsize = number.length() * fontwidth;
 gc.drawText( number, LEFT - 5 - numsize, TOP + i * ( fontheight + 2 ) + offset.y, true );
 gc.drawLine( LEFT, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y, LEFT - 5, TOP
  + ( i + 1 ) * ( fontheight + 2 ) + offset.y );

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

@Override
public void paint(GC gc, int width, int height) {
  gc.drawLine(0, 0, width, height);
  gc.drawLine(width, 0, 0, height);
}
}

代码示例来源:origin: org.eclipse.neoscada.chart/org.eclipse.scada.chart.swt

@Override
public void drawLine ( final int x1, final int y1, final int x2, final int y2 )
{
  this.gc.drawLine ( x1, y1, x2, y2 );
}

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

private void paintMark(GC gc, int x, int y, int h) {
  gc.setForeground(markCol);
  gc.drawLine(x, y+1, x, y+h-2);
  gc.drawLine(x-1, y+1, x+1, y+1);
  gc.drawLine(x-1, y+h-2, x+1, y+h-2);
}

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

private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
  gc.setForeground(topleft);
  gc.drawLine(x, y, x+w-1, y);
  gc.drawLine(x, y, x, y+h-1);
    
  gc.setForeground(bottomright);
  gc.drawLine(x+w, y, x+w, y+h);
  gc.drawLine(x, y+h, x+w, y+h);
}
void paint(PaintEvent event) {

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

/**
 * Draw a rectangle in the given colors.
 */
private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
  gc.setForeground(bottomright);
  gc.drawLine(x+w, y,   x+w, y+h);
  gc.drawLine(x,   y+h, x+w, y+h);

  gc.setForeground(topleft);
  gc.drawLine(x, y, x+w-1, y);
  gc.drawLine(x, y, x,     y+h-1);
}
/*

代码示例来源:origin: org.eclipse.neoscada.hmi/org.eclipse.scada.swt

/**
 * Draw a rectangle in the given colors.
 */
private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
  gc.setForeground(bottomright);
  gc.drawLine(x+w, y,   x+w, y+h);
  gc.drawLine(x,   y+h, x+w, y+h);
  
  gc.setForeground(topleft);
  gc.drawLine(x, y, x+w-1, y);
  gc.drawLine(x, y, x,     y+h-1);
}
/*

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topLeft, Color bottomRight) {
  gc.setForeground(topLeft);
  gc.drawLine(x, y, x + w -1, y);
  gc.drawLine(x, y, x, y + h -1);
  gc.setForeground(bottomRight);
  gc.drawLine(x + w, y, x + w, y + h);
  gc.drawLine(x, y + h, x + w, y + h);
}

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

void drawVerticals(GC gc, int w, int h) {
 for (int i = 0; i < w; i += VERTICAL_DIST) {
  gc.setForeground(gridColor);
  gc.drawLine(i, 0, i, h);
 }
}

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

@Override
protected void paintText(GC gc, Rectangle bounds) {
  super.paintText(gc, bounds);
  if (strikeThrough) {
    Point totalSize = computeTextSize(SWT.DEFAULT, SWT.DEFAULT);
    int textWidth = Math.min(bounds.width, totalSize.x);
    int textHeight = totalSize.y;
    //			int descent = gc.getFontMetrics().getDescent();
    int lineY = bounds.y + (textHeight / 2); // - descent + 1;
    gc.drawLine(bounds.x, lineY, bounds.x + textWidth, lineY);
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

private void drawRangeIndication(GC gc, Canvas canvas, Rectangle r) {
  final int MARGIN= 3;
  /* cap the height - at least on GTK, large numbers are converted to
   * negatives at some point */
  int height= Math.min(r.y + r.height - MARGIN, canvas.getSize().y);
  gc.setForeground(canvas.getDisplay().getSystemColor(COLOR));
  gc.setLineWidth(0); // NOTE: 0 means width is 1 but with optimized performance
  gc.drawLine(r.x + 4, r.y + 12, r.x + 4, height);
  gc.drawLine(r.x + 4, height, r.x + r.width - MARGIN, height);
}

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

相关文章

GC类方法