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

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

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

GC.setLineWidth介绍

[英]Sets the width that will be used when drawing lines for all of the figure drawing operations (that is, drawLine, drawRectangle, drawPolyline, and so forth.

Note that line width of zero is used as a hint to indicate that the fastest possible line drawing algorithms should be used. This means that the output may be different from line width one.
[中]设置为所有地物绘制操作(即,drawLinedrawRectangledrawPolyline等)绘制线时将使用的宽度。
请注意,线宽为零表示应使用最快的线条绘制算法。这意味着输出可能与线宽不同。

代码示例

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

public void setLineWidth( int width ) {
 gc.setLineWidth( width );
}

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

public void setLineWidth( int width ) {
 gc.setLineWidth( width );
}

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

protected void drawRect( GC gc, Rectangle rect ) {
 if ( rect == null ) {
  return;
 }
 gc.setLineStyle( SWT.LINE_DASHDOT );
 gc.setLineWidth( 1 );
 gc.setForeground( GUIResource.getInstance().getColorDarkGray() );
 // PDI-2619: SWT on Windows doesn't cater for negative rect.width/height so handle here.
 Point s = new Point( rect.x + offset.x, rect.y + offset.y );
 if ( rect.width < 0 ) {
  s.x = s.x + rect.width;
 }
 if ( rect.height < 0 ) {
  s.y = s.y + rect.height;
 }
 gc.drawRoundRectangle( s.x, s.y, Math.abs( rect.width ), Math.abs( rect.height ), 3, 3 );
 gc.setLineStyle( SWT.LINE_SOLID );
}

代码示例来源:origin: stefanhaustein/flowgrid

public void drawErrorMarker(GC gc, int x, int y0) {
  int radius = Math.round(cellSize / 4);
  gc.setForeground(resourceManager.reds[2]);
  gc.setLineWidth(Math.max(1, Math.round(cellSize / 8)));
  gc.drawLine(x - radius, y0 - radius, x + radius, y0 + radius);
  gc.drawLine(x - radius, y0 + radius, x + radius, y0 - radius);
}

代码示例来源:origin: com.eclipsesource.tabris/tabris

private void restoreLastSettings( int lineWidth, Color foreground, int alpha ) {
 gc.setLineWidth( lineWidth );
 gc.setForeground( foreground );
 gc.setAlpha( alpha );
}

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

protected void drawLine(final Color color, final int x1, final int y1,
    final int x2, final int y2, final int width) {
  g.setForeground(color);
  g.setLineWidth(width);
  g.drawLine(cellX + x1, cellY + y1, cellX + x2, cellY + y2);
}

代码示例来源:origin: com.eclipsesource.tabris/tabris

private void dispatchLineWidth( JsonArray parameters ) {
 int width = parameters.get( 0 ).asInt();
 gc.setLineWidth( width );
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/** {@inheritDoc} */
public void drawPolyline(final int[] xPoints, final int[] yPoints, final int nPoints) {
  final int[] ptArray = new int[2 * nPoints];
  for (int i = 0; i < nPoints; i++) {
    TEMP_POINT.setLocation(xPoints[i], yPoints[i]);
    transform.transform(TEMP_POINT, TEMP_POINT);
    ptArray[2 * i] = xPoints[i];
    ptArray[2 * i + 1] = yPoints[i];
  }
  gc.setLineWidth(getTransformedLineWidth());
  gc.drawPolyline(ptArray);
}

代码示例来源:origin: stefanhaustein/flowgrid

public void setStrokeWidth(double sw) {
  strokeWidth = sw;
  strokeWidthPx = Math.round(canvasControl.pixelSize(sw));
  gc().setLineWidth(strokeWidthPx);
  stroke = strokeWidthPx > 0 && foreground.getAlpha() != 0;
}

代码示例来源:origin: stefanhaustein/flowgrid

public void drawConnector(GC gc, int x0, int y0, int x1, int y1, Type type) {
  Color color = resourceManager.typeColor(type, false);
  if (type instanceof ArrayType) {
    gc.setLineWidth(arrayConnectorWidth);
    gc.setForeground(color);
    gc.drawLine(x0, y0, x1, y1);
    gc.setForeground(resourceManager.background);
  } else {
    gc.setForeground(color);
  }
  gc.setLineWidth(connectorWidth);
  gc.drawLine(x0, y0, x1, y1);
}

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

protected void drawDot(final Color outline, final Color fill, final int x,
    final int y, final int w, final int h) {
  int dotX = cellX + x + 2;
  int dotY = cellY + y + 1;
  int dotW = w - 2;
  int dotH = h - 2;
  g.setBackground(fill);
  g.fillOval(dotX, dotY, dotW, dotH);
  g.setForeground(outline);
  g.setLineWidth(2);
  g.drawOval(dotX, dotY, dotW, dotH);
}

代码示例来源: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: org.eclipse.platform/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: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@Override
public void paintControl(PaintEvent e) {
  if (fTextWidget != null) {
    int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
    if (x >= 0) {
      Rectangle area= fTextWidget.getClientArea();
      e.gc.setForeground(fColor);
      e.gc.setLineStyle(fLineStyle);
      e.gc.setLineWidth(fLineWidth);
      e.gc.drawLine(x, 0, x, area.height);
    }
  }
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/**
 * Draws the outline of the specified rectangle. The left and right edges of
 * the rectangle are at x and x + width. The top and bottom edges are at y
 * and y + height. The rectangle is drawn using the graphics context's
 * current color.
 * 
 * @param x the x coordinate of the rectangle to be drawn.
 * @param y the y coordinate of the rectangle to be drawn.
 * @param width the width of the rectangle to be drawn.
 * @param height the height of the rectangle to be drawn.
 */
public void drawRect(final double x, final double y, final double width, final double height) {
  TEMP_RECT.setRect(x, y, width, height);
  SWTShapeManager.transform(TEMP_RECT, transform);
  SWTShapeManager.awtToSWT(TEMP_RECT, SWT_RECT);
  gc.setLineWidth(getTransformedLineWidth());
  gc.drawRectangle(SWT_RECT);
}

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

@Override
public void paintControl(PaintEvent e) {
  if (fTextWidget != null) {
    if (fFontForCachedWidgetX != fTextWidget.getFont()) {
      computeWidgetX();
    }
    int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
    if (x >= 0) {
      Rectangle area= fTextWidget.getClientArea();
      e.gc.setForeground(fColor);
      e.gc.setLineStyle(fLineStyle);
      e.gc.setLineWidth(fLineWidth);
      e.gc.drawLine(x, 0, x, area.height);
    }
  }
}

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

@Override
  public void paintControl(PaintEvent e) {
    Point s= fSummaryHeader.getSize();
    if (fIndicatorColor != null) {
      Display d= fSummaryHeader.getDisplay();
      e.gc.setBackground(getColor(d, fIndicatorColor));
      int min= Math.min(s.x, s.y)-2*INSET;
      Rectangle r= new Rectangle((s.x-min)/2, (s.y-min)/2, min, min);
      e.gc.fillRectangle(r);
      if (d != null)
        drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, d.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), d.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
      e.gc.setForeground(fSeparatorColor);
      e.gc.setLineWidth(0 /* 1 */);
      e.gc.drawLine(0+1, s.y-1, s.x-1-1, s.y-1);
    }
  }
}

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

public void paintControl(PaintEvent e) {
    
    Point s= fSummaryHeader.getSize();
    
    if (fIndicatorColor != null) {
      Display d= fSummaryHeader.getDisplay();
      e.gc.setBackground(getColor(d, fIndicatorColor));
      int min= Math.min(s.x, s.y)-2*INSET;
      Rectangle r= new Rectangle((s.x-min)/2, (s.y-min)/2, min, min);
      e.gc.fillRectangle(r);
      if (d != null)
        drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, d.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), d.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
      e.gc.setForeground(fSeparatorColor);
      e.gc.setLineWidth(0 /* 1 */);
      e.gc.drawLine(0+1, s.y-1, s.x-1-1, s.y-1);
    }
  }
}

代码示例来源:origin: stefanhaustein/flowgrid

public static void drawBoolean(GC gc, boolean value, int x, int y, int size) {
 Device device = gc.getDevice();
 gc.setBackground(device.getSystemColor(value ? SWT.COLOR_GREEN : SWT.COLOR_RED));
 gc.fillOval(x, y, size, size);
 gc.setForeground(device.getSystemColor(SWT.COLOR_WHITE));
 gc.setLineWidth(Math.max(1, size / 8));
 gc.setLineCap(value ? SWT.CAP_ROUND : SWT.CAP_FLAT);
 int d = size / 4;
 int cx = x + size / 2;
 int cy = y + size / 2;
 if (value) {
  gc.drawLine(cx - d, cy, cx-d/4, cy + d);
  gc.drawLine(cx-d/4, cy + d, cx + d, cy - d);
 } else {
  gc.drawLine(cx - d, cy - d, cx + d, cy + d);
  gc.drawLine(cx - d, cy + d, cx + d, cy - d);
 }
}

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

@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) {
  if (gc != null) {
    if (length < 1)
      return;
    Point left= textWidget.getLocationAtOffset(offset);
    Point right= textWidget.getLocationAtOffset(offset + length);
    Rectangle rect= textWidget.getTextBounds(offset, offset + length - 1);
    left.x= rect.x;
    right.x= rect.x + rect.width;
    int[] polyline= computePolyline(left, right, textWidget.getBaseline(offset), textWidget.getLineHeight(offset));
    gc.setLineWidth(0); // NOTE: 0 means width is 1 but with optimized performance
    gc.setLineStyle(SWT.LINE_SOLID);
    gc.setForeground(color);
    gc.drawPolyline(polyline);
  } else {
    textWidget.redrawRange(offset, length, true);
  }
}

相关文章

GC类方法