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

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

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

GC.setLineStyle介绍

[英]Sets the receiver's line style to the argument, which must be one of the constants SWT.LINE_SOLID, SWT.LINE_DASH, SWT.LINE_DOT, SWT.LINE_DASHDOT or SWT.LINE_DASHDOTDOT.
[中]将接收方的线条样式设置为参数,该参数必须是常量SWT.LINE_SOLIDSWT.LINE_DASHSWT.LINE_DOTSWT.LINE_DASHDOTSWT.LINE_DASHDOTDOT之一。

代码示例

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

public void setLineStyle( ELineStyle lineStyle ) {
 switch ( lineStyle ) {
  case DASHDOT:
   gc.setLineStyle( SWT.LINE_DASHDOT );
   break;
  case SOLID:
   gc.setLineStyle( SWT.LINE_SOLID );
   break;
  case DOT:
   gc.setLineStyle( SWT.LINE_DOT );
   break;
  case DASH:
   gc.setLineStyle( SWT.LINE_DASH );
   break;
  case PARALLEL:
   gc.setLineAttributes( new LineAttributes(
    gc.getLineWidth(), SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_CUSTOM, new float[] { 5, 3, }, 0, 10 ) );
   break;
  default:
   break;
 }
}

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

public void setLineStyle( ELineStyle lineStyle ) {
 switch ( lineStyle ) {
  case DASHDOT:
   gc.setLineStyle( SWT.LINE_DASHDOT );
   break;
  case SOLID:
   gc.setLineStyle( SWT.LINE_SOLID );
   break;
  case DOT:
   gc.setLineStyle( SWT.LINE_DOT );
   break;
  case DASH:
   gc.setLineStyle( SWT.LINE_DASH );
   break;
  case PARALLEL:
   gc.setLineAttributes( new LineAttributes(
    gc.getLineWidth(), SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_CUSTOM, new float[] { 5, 3, }, 0, 10 ) );
   break;
  default:
   break;
 }
}

代码示例来源: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: org.piccolo2d/piccolo2d-swt

protected void paint(final PPaintContext paintContext) {
    final SWTGraphics2D s2g = (SWTGraphics2D) paintContext.getGraphics();
    s2g.gc.setLineStyle(SWT.LINE_DASH);
    super.paint(paintContext);
    s2g.gc.setLineStyle(SWT.LINE_SOLID);
  }
};

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

@Override
public void draw(FigureDrawContext fdc) {
  Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
  fdc.gc.setForeground(foregroundColor);
  fdc.gc.setBackground(backgroundColor);
  fdc.gc.setLineStyle(lineStyle);
  fdc.gc.drawOval(r.x, r.y, r.width - 1, r.height - 1);
  fdc.gc.setLineStyle(SWT.LINE_SOLID);
}
@Override

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

@Override
public void draw(FigureDrawContext fdc) {
  Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
  fdc.gc.setForeground(foregroundColor);
  fdc.gc.setBackground(backgroundColor);
  fdc.gc.setLineStyle(lineStyle);
  fdc.gc.drawRectangle(r.x, r.y, r.width - 1, r.height - 1);
  fdc.gc.setLineStyle(SWT.LINE_SOLID);
}
@Override

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

@Override
public void draw(FigureDrawContext fdc) {
  Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
  fdc.gc.setForeground(foregroundColor);
  fdc.gc.setBackground(backgroundColor);
  fdc.gc.setLineStyle(lineStyle);
  fdc.gc.drawRoundRectangle(r.x, r.y, r.width - 1, r.height - 1, diameter, diameter);
  fdc.gc.setLineStyle(SWT.LINE_SOLID);
}
@Override

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

@Override
public void draw(FigureDrawContext fdc) {
  Point p1 = fdc.toClientPoint(x1, y1);
  Point p2 = fdc.toClientPoint(x2, y2);
  fdc.gc.setForeground(foregroundColor);
  fdc.gc.setBackground(backgroundColor);
  fdc.gc.setLineStyle(lineStyle);
  fdc.gc.drawLine(p1.x, p1.y, p2.x, p2.y);
  fdc.gc.setLineStyle(SWT.LINE_SOLID);
}
@Override

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

@Override
public void paintControl(PaintEvent event) {
  GC gc = event.gc;
  if(this.drawSelected){
    //如果已经画过,判断位置是否已经变更
    return;
  }
  
  //System.out.println(event.count);
  Color color = gc.getForeground();
  gc.setForeground(event.display.getSystemColor(SWT.COLOR_BLACK));
  
  //先画一个虚线边框代表已选中
  Point size = control.getSize();
  Rectangle rect = new Rectangle(0, 0, size.x, size.y);
  gc.setLineStyle(SWT.LINE_DASHDOTDOT);
  gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
        
  //画Resize
  gc.setLineStyle(SWT.LINE_SOLID);
  if((style | EditableControl.RESIZE_LEFT) == EditableControl.RESIZE_LEFT ){
    //左面可以缩放
  }
  
  gc.setForeground(color);        
}

代码示例来源: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.eclipse/org.eclipse.ui.workbench.texteditor

protected void drawBox(GC gc, StyledText textWidget, Color color, Rectangle bounds) {
    //clean bg:
    gc.setForeground(textWidget.getBackground());
    gc.setLineStyle(SWT.LINE_SOLID);
    int x= bounds.x;
    int y= bounds.y;
    int w= bounds.width - 1;
    int h= bounds.height - 1;
    gc.drawRectangle(x, y, w, h);
    
    gc.setForeground(color);
    gc.setLineDash(new int[] { 3 });
    
    // gc.drawRectangle(x, y, w, h) is platform-dependent and can look "animated"
    gc.drawLine(x, y, x + w, y);
    gc.drawLine(x, y + h, x + w, y + h);
    gc.drawLine(x, y, x, y + h);
    gc.drawLine(x + w, y, x + w, y + h);
    //RESET (same GC is passed around!):
    gc.setLineStyle(SWT.LINE_SOLID);
  }
}

代码示例来源: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: com.miglayout/miglayout-swt

@Override
public final void paintDebugOutline(boolean useVisaualPadding)
{
  if (c.isDisposed())
    return;
  GC gc = new GC(c);
  gc.setLineJoin(SWT.JOIN_MITER);
  gc.setLineCap(SWT.CAP_SQUARE);
  gc.setLineStyle(SWT.LINE_DOT);
  gc.setForeground(DB_COMP_OUTLINE);
  gc.drawRectangle(0, 0, getWidth() - 1, getHeight() - 1);
  gc.dispose();
}

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

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

gc.setLineStyle(SWT.LINE_DASHDOTDOT);
gc.setLineWidth(1);
gc.drawRectangle(rect.x + 3, rect.y + 3, rect.width - 3, rect.height - 3);

代码示例来源:origin: org.eclipse.scout.sdk.deps/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);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.css.swt

gc.setBackground(background);
gc.setLineStyle(SWT.LINE_SOLID);
gc.setAntialias(SWT.ON);
gc.setLineWidth(1);
  gc.setBackground(oldBackground);
  gc.setAlpha(oldAlpha);
  gc.setLineStyle(oldLineStyle);
  gc.setLineWidth(oldLineWidth);
  gc.setAntialias(oldAntialias);

代码示例来源:origin: Nodeclipse/EditBox

private void drawRect(GC gc, Box b, int x, int y, int width, int height) {
  if (b.isOn && settings.getHighlightWidth() > 0 && settings.getHighlightColor(b.level) != null) {
    gc.setLineStyle(settings.getHighlightLineStyleSWTInt());
    gc.setLineWidth(settings.getHighlightWidth());
    gc.setForeground(settings.getHighlightColor(b.level));
    if (settings.getHighlightDrawLine())
      gc.drawLine(x, y, x,  y + b.rec.height);
    else{
      //3D
      //gc.drawLine(x-1, y+3, x-1,  y + b.rec.height+1);
      //gc.drawLine(x-1, y + b.rec.height +1, x+b.rec.width-1,  y + b.rec.height +1);
      //gc.drawPoint(x, y+b.rec.height);
      drawRectangle(gc, x, y, width, height);
    }
  } else if (!b.isOn && settings.getBorderWidth() > 0 && settings.getBorderColor(b.level) != null) {
    gc.setLineStyle(settings.getBorderLineStyleSWTInt());
    gc.setLineWidth(settings.getBorderWidth());
    gc.setForeground(settings.getBorderColor(b.level));
    if (settings.getBorderDrawLine())
      gc.drawLine(x, y+1, x,  y + b.rec.height-1);
    else{
      drawRectangle(gc, x, y, width, height);
    }
  }
}

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

gc.setLineStyle(SWT.LINE_SOLID);

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

gc.setLineStyle( SWT.LINE_DOT );

相关文章

微信公众号

最新文章

更多

GC类方法