当前位置: 首页>>代码示例>>Java>>正文


Java GC.setAlpha方法代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.GC.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java GC.setAlpha方法的具体用法?Java GC.setAlpha怎么用?Java GC.setAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.graphics.GC的用法示例。


在下文中一共展示了GC.setAlpha方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawString

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawString(GC gc, String str, float x, float y, float width, float height, int bgAlpha) {
	if (str == null)
		return;

	org.eclipse.swt.graphics.Point size = gc.stringExtent(str);
	int posX = Math.round(x + width / 2 - size.x / 2);
	int posY = Math.round(y + height / 2 - size.y / 2);

	if (bgAlpha >= 255) {
		gc.drawString(str, posX, posY);
	} else {
		gc.drawString(str, posX, posY, true);
		if (bgAlpha > 0) {
			gc.setAlpha(bgAlpha);
			gc.fillRectangle(posX, posY, size.x, size.y);
			gc.setAlpha(255);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:GraphUtils.java

示例2: cellPaint

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
 	Object ds = cell.getDataSource();
 	if (!(ds instanceof TorrentOpenFileOptions)) {
 		return;
 	}
 	TorrentOpenFileOptions tfi = (TorrentOpenFileOptions) ds;

 	float pct = tfi.lSize / (float) tfi.parent.getTorrent().getSize();

 	Rectangle bounds = cell.getBounds();

	bounds.width = (int) (bounds.width * pct);
	if (bounds.width > 2) {
		bounds.x++;
		bounds.y++;
		bounds.height -= 2;
		bounds.width -= 2;
 		gc.setBackground(gc.getForeground());
 		int alpha = gc.getAlpha();
 		gc.setAlpha(10);
 		gc.fillRectangle(bounds);
 		gc.setAlpha(alpha);
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:26,代码来源:TableColumnOTOF_Size.java

示例3: doPaint

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
protected void doPaint(GC gc, PaintEvent event) {
	gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
	gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));

	gc.fillRectangle(event.x, event.y, event.width, event.height);

	if (graph != null) {
		final Transform tf = new Transform(gc.getDevice());
		tf.translate(-offsetX, -offsetY);
		tf.scale(scale, scale);
		gc.setTransform(tf);

		if (graphNeedsLayout) {
			graph.layout();
			graphNeedsLayout = false;
		}

		graph.getNodes().forEach(n -> n.paint(gc));

		gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));

		gc.setTransform(null);
		tf.dispose();

		if (hawkEye_active && hawkEye_target != null) {
			final int w = Math.round(getSize().x / hawkEye_oldScale * scale);
			final int h = Math.round(getSize().y / hawkEye_oldScale * scale);
			gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
			gc.setAlpha(64);
			gc.fillRectangle(
					(int) hawkEye_target.x - w / 2,
					(int) hawkEye_target.y - h / 2,
					w, h);
			gc.setAlpha(255);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:38,代码来源:VisualisationCanvas.java

示例4: draw

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private void draw(GC gc,float x,float y,float h,DHTControlContact contact,int distance,float error) {
  if(x == 0 && y == 0) return;
  if(error > 1) error = 1;
  int errDisplay = (int) (100 * error);
  int x0 = scale.getX(x,y);
  int y0 = scale.getY(x,y);

  Image img = ImageRepository.getCountryFlag( contact.getTransportContact().getTransportAddress().getAddress(), true );

  if ( img != null ){
  	Rectangle bounds = img.getBounds();
  	int old = gc.getAlpha();
  	gc.setAlpha( 150 );
  	gc.drawImage( img, x0-bounds.width/2, y0-bounds.height);
  	gc.setAlpha( old );
  }

  gc.fillRectangle(x0-1,y0-1,3,3);
  //int elevation =(int) ( 200*h/(scale.maxY-scale.minY));
  //gc.drawLine(x0,y0,x0,y0-elevation);

  //String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms \nerr:"+errDisplay+"%";
  String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms "+errDisplay+"%";

  int lineReturn = text.indexOf("\n");
  int xOffset = gc.getFontMetrics().getAverageCharWidth() * (lineReturn != -1 ? lineReturn:text.length()) / 2;
  gc.drawText(text,x0-xOffset,y0,true);

  currentPositions.add( new Object[]{ x0, y0, h, contact, x, y, distance });
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:31,代码来源:VivaldiPanel.java

示例5: setColour

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private void
setColour(
	GC		gc )
{
	if ( complete_time != -1 && draw_count > 1 ){

		int age = (int)( SystemTime.getMonotonousTime() - complete_time );

		gc.setAlpha( Math.max( 0, 200 - (255*age/FADE_OUT)));

		gc.setForeground( ColorCache.getColor( gc.getDevice(), 0, 0, 0 ));

	}else{

		gc.setAlpha( 255 );

		int type = activity.getType();

		if ( type == DHTControlActivity.AT_EXTERNAL_GET ){

			gc.setForeground( ColorCache.getColor( gc.getDevice(), 20, 200, 20 ));

		}else if ( type == DHTControlActivity.AT_INTERNAL_GET ){

			gc.setForeground( ColorCache.getColor( gc.getDevice(), 140, 160, 40 ));

		}else if ( type == DHTControlActivity.AT_EXTERNAL_PUT ){

			gc.setForeground( ColorCache.getColor( gc.getDevice(), 20, 20, 220 ));

		}else{

			gc.setForeground( ColorCache.getColor( gc.getDevice(), 40, 140, 160 ));
		}
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:37,代码来源:DHTOpsPanel.java

示例6: drawPie

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void
drawPie(
	GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border )
{
	Rectangle image_size = image.getBounds();

	int	width_pad 	= ( width - image_size.width  )/2;
	int	height_pad 	= ( height - image_size.height  )/2;

    int angle = (percent * 360) / 100;
    if(angle<4){
    	angle = 0; // workaround fillArc rendering bug
    }

	Region old_clipping = new Region();

	gc.getClipping(old_clipping);

	Path path_done = new Path(gc.getDevice());

	path_done.addArc(x,y,width,height,90,-angle);
	path_done.lineTo( x+width/2, y+height/2);
	path_done.close();

	gc.setClipping( path_done );

	gc.drawImage(image, x+width_pad, y+height_pad+1);

	Path path_undone = new Path(gc.getDevice());

	path_undone.addArc(x,y,width,height,90-angle,angle-360);
	path_undone.lineTo( x+width/2, y+height/2);
	path_undone.close();

	gc.setClipping( path_undone );

	gc.setAlpha( 75 );
	gc.drawImage(image, x+width_pad, y+height_pad+1);
	gc.setAlpha( 255 );

	gc.setClipping( old_clipping );

	if ( draw_border ){

		gc.setForeground(Colors.blue);

		if ( percent == 100 ){

			gc.drawOval(x , y , width-1, height-1);

		}else{

			if ( angle > 0 ){

				gc.drawPath( path_done );
			}
		}
	}

	path_done.dispose();
	path_undone.dispose();
	old_clipping.dispose();

}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:65,代码来源:PieUtils.java


注:本文中的org.eclipse.swt.graphics.GC.setAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。