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


Java Path.addArc方法代码示例

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


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

示例1: paintControl

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
@Override
	public void paintControl(PaintEvent e) {
		GC gc = e.gc;
		gc.setAntialias(SWT.ON);
		Rectangle bounds = getBounds();
		Path path = new Path(getDisplay());
		path.addArc(bounds.x, bounds.y, arcSize, arcSize, 90, 180);
//		path.addRectangle(bounds.x + arcSize / 2, bounds.y, bounds.width - arcSize,
//				arcSize);
		path.addArc(bounds.x + bounds.width - arcSize, bounds.y, arcSize, arcSize,
				270, 180);
//		gc.setClipping(path);
		Color b = gc.getBackground();
		gc.setBackground(backgroundColor);
		gc.fillPath(path);
		path.dispose();
		gc.setAntialias(SWT.OFF);
		gc.setBackground(b);
	}
 
开发者ID:Talend,项目名称:tesb-studio-se,代码行数:20,代码来源:SearchControl.java

示例2: getTopRoundedRectangle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static Path getTopRoundedRectangle(PrecisionRectangle tempRect, float radius,boolean drawLeftSide,boolean drawRightSide){
	if (radius <= 0) return getRoundedRectangle(tempRect, radius,drawLeftSide,drawRightSide);
	float width = radius * 2;
	float dy = radius - tempRect.height;
	float dx = radius - (float) Math.sqrt(radius*radius - dy*dy);
	float alpha =  dy > 0 ? (float)(Math.acos(dy/radius)*180/Math.PI) : 90;
	Path p = new Path(null);
	float x = (float) tempRect.preciseX;
	float y = (float) tempRect.preciseY;
	float right = (float) tempRect.preciseRight();
	float bottom = (float) tempRect.preciseBottom();
	
	if (dy < 0){
		p.moveTo(x, y + radius);
	} else {
		p.moveTo(x + dx, y - dy);
	}
	p.addArc(x, y, width, width, 90 + alpha, -alpha);
	p.addArc(right-width, y, width, width, 90, -alpha);
	
	if (dy < 0){
		p.lineTo(right, bottom);//rightBottom
		p.lineTo(x, bottom);//leftBottom
	}
			
	return p;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:28,代码来源:Drawer.java

示例3: getBottomRoundedRectangle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static Path getBottomRoundedRectangle(PrecisionRectangle tempRect, float radius,boolean drawLeftSide,boolean drawRightSide){
	if (radius <= 0) return getRoundedRectangle(tempRect, radius,drawLeftSide,drawRightSide);
	float width = radius * 2;
	float dy = radius - tempRect.height;
	float dx = radius - (float) Math.sqrt(radius*radius - dy*dy);
	float alpha =  dy > 0 ? (float)(Math.acos(dy/radius)*180/Math.PI) : 90;
	Path p = new Path(null);
	float x = (float) tempRect.preciseX;
	float y = (float) tempRect.preciseY;
	float right = (float) tempRect.preciseRight();
	float bottom = (float) tempRect.preciseBottom();
	
	if (dy < 0){
		p.moveTo(x, bottom - radius);
	} else {
		p.moveTo(x + dx, y);
	}
	p.addArc(x, bottom - 2*radius, width, width, 270 - alpha, alpha);
	p.addArc(right-width, bottom - 2*radius, width, width, 270, alpha);
	
	if (dy < 0){
		p.lineTo(right, y);//rightTop
		p.lineTo(x, y);//leftTop
	}
			
	return p;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:28,代码来源:Drawer.java

示例4: paint

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
@Override
public void paint(Graphics graphics) {
	graphics.pushState();
	graphics.setForegroundColor(getForegroundColor());
	graphics.setBackgroundColor(getBackgroundColor());
	super.paint(graphics);
	Path path = new Path(Display.getDefault());
	path.addArc(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height - 1, 0, 360);
	graphics.setClip(path);
	graphics.setLineWidth(2);
	graphics.drawLine(bounds.getTopLeft(), bounds.getBottomRight());
	graphics.drawLine(bounds.getTopRight(), bounds.getBottomLeft());
	path.dispose();
	graphics.popState();
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:16,代码来源:ExitFigure.java

示例5: drawArea

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public void drawArea( AreaRenderEvent are ) throws ChartException
{
	iv.modifyEvent( are );
	
	// CHECK IF THE LINE ATTRIBUTES ARE CORRECTLY DEFINED
	final LineAttributes lia = are.getOutline( );
	if ( !validateLineAttributes( are.getSource( ), lia ) )
	{
		return;
	}

	// SETUP THE FOREGROUND COLOR (DARKER BACKGROUND IF DEFINED AS NULL)
	final Color cFG = (Color) validateEdgeColor( lia.getColor( ),
			are.getBackground( ),
			_ids );
	if ( cFG == null ) // IF UNDEFINED, EXIT
	{
		return;
	}

	// BUILD THE GENERAL PATH STRUCTURE
	final Path gp = new Path( ( (SwtDisplayServer) _ids ).getDevice( ) );
	PrimitiveRenderEvent pre;
	for ( int i = 0; i < are.getElementCount( ); i++ )
	{
		pre = are.getElement( i );
		if ( pre instanceof ArcRenderEvent )
		{
			final ArcRenderEvent acre = (ArcRenderEvent) pre;

			gp.addArc( (float) acre.getTopLeft( ).getX( ),
					(float) acre.getTopLeft( ).getY( ),
					(float) acre.getWidth( ),
					(float) acre.getHeight( ),
					(float) acre.getStartAngle( ),
					(float) acre.getAngleExtent( ) );
		}
		else if ( pre instanceof LineRenderEvent )
		{
			final LineRenderEvent lre = (LineRenderEvent) pre;
			gp.moveTo( (float) lre.getStart( ).getX( ),
					(float) lre.getStart( ).getY( ) );
			gp.lineTo( (float) lre.getEnd( ).getX( ), (float) lre.getEnd( )
					.getY( ) );
		}
	}

	// DRAW THE PATH
	final int iOldLineStyle = _gc.getLineStyle( );
	final int iOldLineWidth = _gc.getLineWidth( );
	int iLineStyle = SWT.LINE_SOLID;
	switch ( lia.getStyle( ).getValue( ) )
	{
		case ( LineStyle.DOTTED                                                                                                                                                                                                                                                                  ) :
			iLineStyle = SWT.LINE_DOT;
			break;
		case ( LineStyle.DASH_DOTTED                                                                                                                                                                                                                                                                  ) :
			iLineStyle = SWT.LINE_DASHDOT;
			break;
		case ( LineStyle.DASHED                                                                                                                                                                                                                                                                  ) :
			iLineStyle = SWT.LINE_DASH;
			break;
	}
	_gc.setLineStyle( iLineStyle );
	_gc.setLineWidth( lia.getThickness( ) );
	_gc.setForeground( cFG );

	R31Enhance.setAlpha( _gc, lia.getColor( ) );

	_gc.drawPath( gp );

	// Restore state
	_gc.setLineStyle( iOldLineStyle );
	_gc.setLineWidth( iOldLineWidth );

	// Free resource
	gp.dispose( );
	cFG.dispose( );

}
 
开发者ID:eclipse,项目名称:birt,代码行数:81,代码来源:SwtRendererImpl.java

示例6: fillArea

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public void fillArea( AreaRenderEvent are ) throws ChartException
{
	iv.modifyEvent( are );
	
	Fill flBackground = validateMultipleFill( are.getBackground( ) );

	if ( isFullTransparent( flBackground ) )
	{
		return;
	}

	// BUILD THE GENERAL PATH STRUCTURE
	final Path pt = new Path( ( (SwtDisplayServer) _ids ).getDevice( ) );
	PrimitiveRenderEvent pre;
	for ( int i = 0; i < are.getElementCount( ); i++ )
	{
		pre = are.getElement( i );
		if ( pre instanceof ArcRenderEvent )
		{
			final ArcRenderEvent acre = (ArcRenderEvent) pre;

			pt.addArc( (float) acre.getTopLeft( ).getX( ),
					(float) acre.getTopLeft( ).getY( ),
					(float) acre.getWidth( ),
					(float) acre.getHeight( ),
					(float) acre.getStartAngle( ),
					(float) acre.getAngleExtent( ) );
		}
		else if ( pre instanceof LineRenderEvent )
		{
			final LineRenderEvent lre = (LineRenderEvent) pre;
			if ( i == 0 )
			{
				pt.moveTo( (float) lre.getStart( ).getX( ),
						(float) lre.getStart( ).getY( ) );
			}
			pt.lineTo( (float) lre.getEnd( ).getX( ), (float) lre.getEnd( )
					.getY( ) );
		}
	}

	try
	{
		if ( flBackground instanceof ColorDefinition )
		{
			fillPathColor( pt, (ColorDefinition) flBackground );
		}
		else if ( flBackground instanceof Gradient )
		{
			final Bounds bo = are.getBounds( );
			final Rectangle r = new Rectangle( (int) ( ( bo.getLeft( ) + dTranslateX ) * dScale ),
					(int) ( ( bo.getTop( ) + dTranslateY ) * dScale ),
					(int) ( bo.getWidth( ) * dScale ),
					(int) ( bo.getHeight( ) * dScale ) );
			fillPathGradient( pt, (Gradient) flBackground, r );
		}
		else if ( flBackground instanceof org.eclipse.birt.chart.model.attribute.Image )
		{
			fillPathImage( pt,
					(org.eclipse.birt.chart.model.attribute.Image) flBackground );
		}
	}
	finally
	{
		pt.dispose( );
	}
	

}
 
开发者ID:eclipse,项目名称:birt,代码行数:70,代码来源:SwtRendererImpl.java

示例7: fillOval

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public void fillOval( OvalRenderEvent ore ) throws ChartException
{
	iv.modifyEvent( ore );
	
	final Fill flBackground = validateMultipleFill( ore.getBackground( ) );

	if ( isFullTransparent( flBackground ) )
	{
		return;
	}

	final Bounds bo = ore.getBounds( );
	final Rectangle r = new Rectangle( (int) ( ( bo.getLeft( ) + dTranslateX ) * dScale ),
			(int) ( ( bo.getTop( ) + dTranslateY ) * dScale ),
			(int) ( bo.getWidth( ) * dScale ),
			(int) ( bo.getHeight( ) * dScale ) );
	Path pt = new Path( ( (SwtDisplayServer) _ids ).getDevice( ) );
	pt.addArc( r.x, r.y, r.width, r.height, 0, 360 );

	try
	{
		if ( flBackground instanceof ColorDefinition )
		{
			fillPathColor( pt, (ColorDefinition) flBackground );
		}
		else if ( flBackground instanceof Gradient )
		{
			fillPathGradient( pt, (Gradient) flBackground, r );
		}
		else if ( flBackground instanceof org.eclipse.birt.chart.model.attribute.Image )
		{
			fillPathImage( pt,
					(org.eclipse.birt.chart.model.attribute.Image) flBackground );
		}
	}
	finally
	{
		pt.dispose( );
	}
	

}
 
开发者ID:eclipse,项目名称:birt,代码行数:43,代码来源:SwtRendererImpl.java

示例8: drawPie

import org.eclipse.swt.graphics.Path; //导入方法依赖的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

示例9: drawPie

import org.eclipse.swt.graphics.Path; //导入方法依赖的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:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:65,代码来源:PieUtils.java


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